I would combine a collision with a bounding box and a pixel perfect collision.
Thus, all objects in your game will have bounding rectangles, but only frames equal to the width and height of your sprite. Use this as a first level collision test. After that, and you have a collision, use the collision maps to get a finer level of detail.
This optimization will help speed up and add flexibility to the engine so that not all collisions need to be perfect for pixels.
As for the real perfect pixel collision algorithm, what you described will work. However, if you are going for speed, you can try the following:
come up with a bitmask for each sprite (for example, a pixel map, but only one bit per pixel) for example:
00000000 00100000 01100000 01110000
when one sprite collides with another, create a new bitmask from a smaller bit mask of the same size and larger and “shift” it by the difference in position between the sprites.
Once this is done, bit wise and all bytes in these two masks. If any byte result> 0, you have a collision.
Stephan van den heuvel
source share