Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Still having problems getting RBG values for an image

843829Apr 6 2006 — edited Apr 6 2006
Hello, i am still having problems getting RGB values at a specific coordinate of an image. This is the code i have so far, but for some reason all the values that it obtains are equal to zero.
//Gets Size
ImageIcon icon =new ImageIcon (filename);
int height = icon.getIconHeight();
int width = icon.getIconWidth();

Image image = Toolkit.getDefaultToolkit().getImage("C://image.gif");
BufferedImage bufIm = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics g = bufIm.getGraphics();
g.drawImage(image, 0, 0, null);

ColorModel cModel = bufIm.getColorModel();

colorInt = bufIm.getRGB(some width, some height);
		int Red = cModel.getRed(colorInt);
		int Green = cModel.getGreen(colorInt); 
		int Blue = cModel.getBlue(colorInt);
I think that the problem is that bufIm is never filled with the image but remains blank which is why R, G, and B values all read as zero, but i am not sure how to fix it. Any help would be greatly appreciated. Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 4 2006
Added on Apr 6 2006
1 comment
115 views