Results 1 to 2 of 2
- 07-16-2012, 05:31 AM #1
Senior Member
- Join Date
- Jul 2010
- Posts
- 124
- Rep Power
- 0
Getting pixel coordinates of int[] from raster getPixels method
Suppose I have a BufferedImage 100x100 in size. To get the pixels of it,
for some reason, "image_out" looks really strange and looks nothing like "image". How should I successfully get the pixel location and get its RGBA data?Java Code:BufferedImage image = ImageIO.read("./images/test.png"); BufferedImage image_out = new BufferedImage(100,100,BufferedImage.TYPE_INT_ARGB); int[] data = null; data = image.getRaster().getPixels(0,0,100,100, data); for (int y = 0; y < image.getHeight() - 1; y ++){ for (int x = 0; x <image.getWidth() -1; x ++){ image_out.setRGB(x, y, new Color(data[i],data[i++],data[i++],data[i++]).getRGB()); } }
- 07-18-2012, 09:50 PM #2
Similar Threads
-
Scanning Image Pixel by Pixel
By the_transltr in forum Advanced JavaReplies: 5Last Post: 08-28-2012, 04:01 PM -
converting double to pixel coordinates
By mkj in forum New To JavaReplies: 2Last Post: 02-05-2012, 06:43 PM -
Can this be done better with the Raster class? Or some other way?
By Paul Richards in forum Advanced JavaReplies: 6Last Post: 01-15-2011, 03:03 PM -
method to check which type of object with which name is located at given coordinates
By stringargs in forum Java 2DReplies: 5Last Post: 11-14-2010, 04:28 PM -
compare two images pixel by pixel
By java_bond in forum Advanced JavaReplies: 6Last Post: 03-02-2010, 11:27 AM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks