Android Register Touch Events On Visible Portion Of Image?
I've currently been thinking about how I could register only touch events on the visible (non-transparent) parts of a .PNG image. -I've been testing around with AndEngine and it se
Solution 1:
One simple way to do it would be to grab the the pixel color at the touch location. Then you can check if the pixel is transparent:
intcolor= Bitmap.getPixel(x,y); // x and y are the location of the touch event in Bitmap spaceintalpha= Color.getAlpha(color);
booleanisTransparent= (alpha==0);
Note: Depending on how you implement your touch listener will might need to convert the x,y location of the touch event to the x,y coordinates of the image view.
Post a Comment for "Android Register Touch Events On Visible Portion Of Image?"