Results 1 to 2 of 2
- 10-24-2009, 02:24 AM #1
Member
- Join Date
- Jan 2009
- Posts
- 35
- Rep Power
- 0
Creating a jpeg file: "no preview available"
Hello-
When I create a jpeg file within a java program, and then (I'm using Windows) go to look at it, I can see it just fine with the thumbnail in my Windows folder, but if I open the file with the Windows Picture and Fax Viewer, it says "no preview available," and doesn't display the image.
Here's my code:
Iterator iter = ImageIO.getImageWritersByFormatName("jpeg");
ImageWriter writer = (ImageWriter) iter.next();
// instantiate an ImageWriteParam object with default compression options
ImageWriteParam iwp = writer.getDefaultWriteParam();
iwp.setCompressionMode(ImageWriteParam.MODE_EXPLIC IT);
iwp.setCompressionQuality(1); // an integer between 0 and 1
// 1 specifies minimum compression and maximum quality
FileImageOutputStream output = new FileImageOutputStream(file);
writer.setOutput(output);
IIOImage im = new IIOImage(image, null, null);
writer.write(null, im, iwp);
writer.dispose();
writer = (ImageWriter) iter.next(); // Force closing of the writer
Btw, I get an exception on that last line (the "next" call), NoSuchElementException. Maybe it's related?
-scott
- 10-24-2009, 03:31 AM #2
Senior Member
- Join Date
- Jul 2009
- Posts
- 1,143
- Rep Power
- 5
Similar Threads
-
Getting access denied error while importing file using input type="file" with IE7
By sarang1 in forum Advanced JavaReplies: 6Last Post: 02-10-2011, 09:55 AM -
"endless" eventLoop when creating new Instance
By javacafe in forum EclipseReplies: 0Last Post: 08-10-2009, 06:37 PM -
MoneyOut.println("It took you (whats wrong?>",year,"<WW?) years to repay the loan")
By soc86 in forum New To JavaReplies: 2Last Post: 01-24-2009, 06:56 PM -
"source not found" at debug time when creating new class
By rafamd11 in forum New To JavaReplies: 0Last Post: 11-22-2008, 01:49 AM -
the dollar sign "$", prints like any other normal char in java like "a" or "*" ?
By lse123 in forum New To JavaReplies: 1Last Post: 10-20-2008, 07:35 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks