How to correctly align with a pixel perfect collision detection?

I had recently used GameMaker to do a small platform game with my friends. I was surprised that it had this function move_contact_all(direction, speed). This starts moving the object towards a direction until a collision takes place. It is working pretty well. I can’t see even a single pixel gap between even two odd shaped objects. It moved perfectly. Any ideas how to implement that behaviour?

I’m really interested in making an application which demonstrates the same effect.

If you are using OpenGL (LWJGL/JOGL) then you can use occlusion query. It gives only true or false, but this is enough in most cases.

I don’t think that it is fast enough. This the documentation for that function.

How can this be so fast?

Not in OpenGL but I use this method to detect pixel perfect collisions. isPixelPerfectCollision(float x1, float y1, BufferedImage image1, float x2, float y2, BufferedImage image2). How can I align the object perfect to it?

Thanks.