Results 1 to 3 of 3
Thread: Check if image contains mouse
- 05-15-2011, 03:53 PM #1
Member
- Join Date
- Feb 2011
- Posts
- 53
- Rep Power
- 0
Check if image contains mouse
Hey, iv been trying to find a simple way to check if an image has been clicked, So far i have been using the following method below :
Im looking for a method of checking the image was clicked that does not use a rectangle, as this means you can click anywhere within a box and the image is selected, id prefer to create a shape from the image loaded, however this involves a moderately large amount of code to generate a shape based on pixel alignment. Any help in making it possible to select an image only if its pixels are clicked would be great :)Java Code://draw the image Rectangle imagebox = new Rectangle(30, 30,30, 30); TexturePaint imagepaint = new TexturePaint(image,imagebox); g2.setPaint(imagepaint); g2.fill(imagebox); //if anchor rectangle contains mouse.getx and mouse.getY perform print if (imagepaint.getAnchorRect().contains(e.getX(),e.getY())) { System.out.println("Image clicked"); }
- 05-15-2011, 05:06 PM #2
BufferedImage has a method getRGB(int x, int y) that might be useful for that.
db
- 05-15-2011, 10:49 PM #3
Member
- Join Date
- Feb 2011
- Posts
- 53
- Rep Power
- 0
Similar Threads
-
how to move an image automatically without using mouse
By saranyabaskaran in forum New To JavaReplies: 6Last Post: 03-19-2011, 10:00 AM -
Show image on glasspane while mouse button is down
By zweibieren in forum AWT / SwingReplies: 10Last Post: 09-12-2009, 06:29 AM -
Mouse Event + Image Thresholding
By ojmayolebron in forum AWT / SwingReplies: 0Last Post: 03-27-2009, 12:17 AM -
Image cropping in Jsf on the release of mouse
By HarshalAuro in forum JavaServer Faces (JSF)Replies: 0Last Post: 11-12-2008, 06:24 PM -
How to show pixel Coordinate and RGB value when mouse is tracking over an image
By Mazharul in forum Java 2DReplies: 1Last Post: 08-25-2008, 08:48 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks