i have set png image(image having transparent background) button background, when touch button shows me x-coordinate , y-coordinate of button’s touched position but, want know pixel color of touched position of button.
actually want know whether touched position transparent area of button or colored area of button. can check code have developed purpose. please me in respect; cordially appreciated.
button.setontouchlistener(new ontouchlistener() { public boolean ontouch(view v, motionevent event) { int x_coordinate = (int)event.getx(); int y_coordinate = (int)event.gety(); //int color = bitmap.getpixel(x,y); if (event.getaction() == motionevent.action_down) { } if (event.getaction() == motionevent.action_up) { } return true; } });
first, can bitmap bitmapfactory this:
bitmap mbitmap = bitmapfactory.decoderesource(getresources(), r.drawable.pic1);
now have bitmap. on bitmap, can call function getpixel(int x, int y)
color of pixel.
guess can alpha color..
see following links further information:
Comments
Post a Comment