Results 1 to 1 of 1
- 08-29-2009, 12:27 AM #1
Member
- Join Date
- Aug 2009
- Posts
- 1
- Rep Power
- 0
Reconstruct image from a pixel array
Hi everybody!
I'm working in a proyect that work with images. I loaded image from file and decode it in a int array of pixels. After manipulate that pixels I want to reconstruct the image, to save it in hard disk. I've done that:
Where imgCols and imgRows are the columns and rows of the original image, and pixelsNewImg is the int array of pixels.Java Code:Image newImg; newImg = createImage(new MemoryImageSource(imgCols, imgRows, pixelsNewImg, 0, imgCols)); File output = new File("/home/sepho/myfile.jpg"); try { [b]if (ImageIO.write((RenderedImage) newImg, "jpg", output))[/b] { System.out.println("Image stored..."); } } catch (IOException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); }
If I try to run, I get the next error:
This is in the bold line above. Any idea?Exception in thread "main" java.lang.ClassCastException: sun.awt.image.ToolkitImage cannot be cast to java.awt.image.RenderedImage
Thanks for all, and sorry for my english! :PLast edited by Sepho; 08-29-2009 at 12:36 AM.
Similar Threads
-
Scanning Image Pixel by Pixel
By the_transltr in forum Advanced JavaReplies: 5Last Post: 08-28-2012, 04:01 PM -
[SOLVED] manipulating the pixel values of an image and constructinf a new image from
By sruthi_2009 in forum AWT / SwingReplies: 14Last Post: 04-10-2009, 08:46 AM -
Pixel Array?
By AndrewM16921 in forum New To JavaReplies: 4Last Post: 04-03-2009, 12:08 AM -
how to get rgb value each pixel of an image file
By tOpach in forum New To JavaReplies: 1Last Post: 03-28-2009, 04:38 PM -
How can I get a transparent pixel from an image
By samson in forum Java 2DReplies: 1Last Post: 07-17-2007, 04:10 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks