Do you understand the fundamental idea behind the pixel perfect collision detection though?
I mean, take two rectangles, then see if they intersect. If they do, make third rectangle from the part which intersects. Then scan trough that rectangle. Per every pixel, see if both of the two inital rectangles have pixel on that coord. If yes, return true. Else keep scanning.
The idea is simple. If you get errors, then the code is wrong. If you get no errors but the code doesn't work, then the logic is wrong.