Android Bitmap OnTouch Questions?

You could get the colour of pixel touched and compare it to the colour of pixel on the background at those co-ords EDIT: ok, ignore that, you can't get the colour of a pixel on the canvas, so instead, get the x,y of the touch, check if any of the body part images have been touched, if so, take the x,y of the image from the touch x,y, then get the pixel of the image, which should be transparent or colour public boolean onTouchEvent(MotionEvent event) { int x = (int) event.getX(); int y = (int) event.getY(); int offsetx, offsety; for(int I = 0;iTop; if(bodyPartBMPi. GetPixel(offsetx,offsety) == TRANSPARENT) { //whatever } } } }.

You could get the colour of pixel touched and compare it to the colour of pixel on the background at those co-ords. EDIT: ok, ignore that, you can't get the colour of a pixel on the canvas, so instead, get the x,y of the touch, check if any of the body part images have been touched, if so, take the x,y of the image from the touch x,y, then get the pixel of the image, which should be transparent or colour. Public boolean onTouchEvent(MotionEvent event) { int x = (int) event.getX(); int y = (int) event.getY(); int offsetx, offsety; for(int I = 0;iIntersects(x,y,x+1,y+1)) { offsetx = x - bodyPartRecti.

Left; offsety = y - bodyPartRecti. Top; if(bodyPartBMPi. GetPixel(offsetx,offsety) == TRANSPARENT) { //whatever } } } }.

Great idea, I'd never have even thought that was possible. I'll have to google how to a) discover what pixel was pressed and b) find out what colour it is, though. But thanks very much for the idea.

– JimBadger Nov 28 '10 at 17:51 I'd still be interested in any other possible solutions, though, to broaden my knowledge further. – JimBadger Nov 28 '10 at 17:54.

I've drawn 5 bitmaps from . Png files on a canvas - a head, a body and two arms and legs. How can I detect which of these has been touched on an OnTouch?

And, more specifically, can I detect if the OnTouch was within the actual shape of the body part touched? What I mean is, obviously, the . Pngs themselves are rectangular, but does Android know, or can I tell it, to ignore the transparency within the image?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions