Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Swing / AWT / SWT
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
paul wheaton
Ron McLeod
Jeanne Boyarsky
Sheriffs:
Paul Clapham
Saloon Keepers:
Tim Holloway
Roland Mueller
Bartenders:
Forum:
Swing / AWT / SWT
Thumbnail
Phanikanth Munukutla
Greenhorn
Posts: 3
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi,
When I run the program ImageUtil1.java using JRE 1.6 ,I am getting a thumb image with good quality.
But If I change the jre version to 1.5 then the quality of the thumb image is not good.
code :
import java.awt.Graphics2D; import java.awt.Image; import java.awt.RenderingHints; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import javax.imageio.ImageIO; import com.sun.image.codec.jpeg.JPEGCodec; import com.sun.image.codec.jpeg.JPEGEncodeParam; import com.sun.image.codec.jpeg.JPEGImageEncoder; public class ImageUtil1 { public static void main (String [] args) { try { File myDicomFile = new File("D:\\thumbImages\\i1.jpg"); FileInputStream fin = new FileInputStream(myDicomFile); byte [] imageBytes = new byte[ (int) myDicomFile.length () ]; System.out.println("ImageUtil1.main() "+imageBytes.length); fin.read (imageBytes); saveThumbImage(imageBytes, "QC_i1"); } catch (Exception e) { e.printStackTrace (); } } public static void saveThumbImage(byte[] image,String fileName){ try{ Image thumb; ByteArrayInputStream bis = new ByteArrayInputStream(image); thumb = ImageIO.read(bis); int thumbWidth = Integer.parseInt("128"); int thumbHeight = Integer.parseInt("128"); int width = thumb.getWidth(null); int height = thumb.getHeight(null); BufferedImage bi = new BufferedImage(thumbWidth,thumbHeight,BufferedImage.TYPE_INT_RGB); Graphics2D g = bi.createGraphics(); g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,RenderingHints.VALUE_INTERPOLATION_BICUBIC); g.drawImage(thumb, 0, 0,thumbWidth,thumbHeight, null); ByteArrayOutputStream out1 = new ByteArrayOutputStream(); JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out1); JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bi); param.setQuality((float)(75/100.0), true); encoder.encode(bi, param); byte[] buf = out1.toByteArray(); String thumbImagePath = "D:\\thumbImages\\"; FileOutputStream os = new FileOutputStream(new File(thumbImagePath+fileName+".jpg")); os.write(buf); } catch(IOException ioException){ ioException.printStackTrace(); } } }
I need it to run it on jre1.5
Please help me
Thanks in advance..
-Phanikanth
Ulf Dittmer
Rancher
Posts: 43081
77
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
It's possible that Sun's internal JPEG handling was improved between
Java
5 and Java 6.
If you're concerned about quality, why are you using a setting of only 75%?
Phanikanth Munukutla
Greenhorn
Posts: 3
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Even If I make it 100, no use. Its the same result I am getting.
Rob Spoor
Sheriff
Posts: 22862
132
I like...
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Moving to Swing / AWT.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions
How To Answer Questions
What I don't understand is how they changed the earth's orbit to fit the metric calendar. Tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
image resizing
Thumbnail
Calling of a PHP file in JSP
Thumbnail
How to create a jpeg image using jasperreport?
More...