Results 1 to 5 of 5
Thread: Error in saving an Image????
- 11-06-2009, 07:36 AM #1
Error in saving an Image????
I try to save an image but it does not work...
javax.imageio.ImageIO.write(ProcessingImages.tmpSi deA, "tstSideA", new File("d:\\yourImageName.JPG"));
I wrote above code to save the image when clicking a button. Then the first line executed and image displayed in jLabel3 as it supposed. zoomOut() is used just to reduce the size in 8 times.
In D drive a image file of size 0bytes created but when it clicked to open there were a message displaying
"Windows photo viewer cannot open the file because file is empty"
I hope you could explain me how to correct the error....
Last edited by LankanSniper; 11-06-2009 at 07:38 AM.
- 11-07-2009, 02:45 AM #2
Looking up the method in the ImageIO class api
static boolean write(RenderedImage im, String formatName, File output)
Try using "jpg" instead of "tstSideA".
- 11-07-2009, 04:57 AM #3
Thank you for your answer.. It works... But now i got a another problem... Size of the image I browse for the system was 1.83MB but when it saved to the hard disk with out any modification size reduce to 503KB. Which means it reduces the quality.. Since my target is to develop Character Recognition System it is necessary that the image should be in high quality.
Therefore is there any way i can get the original size of the image file when saving to the hard disk????
- 11-07-2009, 05:40 AM #4
The jpg format is lossy, ie, it uses compression.
Try the png format; it is supposed to preserve everything.
- 11-07-2009, 05:48 AM #5
- By Manfizy in forum New To JavaReplies: 9Last Post: 12-03-2011, 05:16 PM
- By dudejonne in forum New To JavaReplies: 5Last Post: 11-03-2009, 03:01 PM
- By angelinehelena in forum Advanced JavaReplies: 1Last Post: 02-10-2009, 11:08 AM
- By Goseph in forum Java 2DReplies: 2Last Post: 12-21-2008, 08:36 PM
- By testtest in forum CLDC and MIDPReplies: 1Last Post: 09-23-2008, 05:16 AM