One pixel colliding with image
BlitzMax Forums/BlitzMax Programming/One pixel colliding with image
| ||
How can I check if a single pixel is overlapping an image considering alpha transparency without too large a hit on performance? |
| ||
Will the image be rotated and scaled?? If not, keep a copy in system memory with a TPixmap and look directly into that, taking into account it's relative position on screen and the pixel you're looking at; ie If the image is drawn at 100,100 and your pixel is at screen position 140,125, look into the pixmap at (40,25). |
| ||
use 1x1 size image and use imagescollide() if no rotation, or if rotation use imagescollide2() small example: |
| ||
Are you using collision layers? If so, the easiest way it to use: CollideRect(MouseX(),MouseY(),1,1,layerID%,0) |
| ||
The fastest way by far is you use a pixmap in main memory and use pointers to access the pixels to find out if they collide. |