dcsimg
Looseless JPG image manipulation. Help with preserving image quality.
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   buzzwordy_garbage
Posted On:   Monday, November 15, 2004 02:07 PM

I'm using the new Java API for image manipulation and I notice a decrease in QUality: for instance this simple load a file write back generates a smaller image. What should be done to preserve image quality? Thank you, Adrian : public void doCopy(String originalImage) { File f = new File(originalImage); try { BufferedImage bufi = ImageIO.read(f); // BufferedImage bi = new BufferedImage(bufi.getWidth(this), bufi.getHeight(this), BufferedImage.TYPE_INT_RGB); Graphics2D big = bi.createGraphics(); big.drawImage(bufi, 0, 0, this); String newName = originalImage.substring(0, originalImage.indexOf(".")) + "Copy.jpg";    More>>

I'm using the new Java API for image manipulation and I notice a decrease in QUality:

for instance this simple load a file write back generates a smaller image.
What should be done to preserve image quality?


Thank you,
Adrian

:

public void doCopy(String originalImage) {
File f = new File(originalImage);
try {
BufferedImage bufi = ImageIO.read(f);
//
BufferedImage bi = new BufferedImage(bufi.getWidth(this), bufi.getHeight(this), BufferedImage.TYPE_INT_RGB);
Graphics2D big = bi.createGraphics();
big.drawImage(bufi, 0, 0, this);
String newName = originalImage.substring(0, originalImage.indexOf(".")) + "Copy.jpg";
ImageIO.write(bi, "jpg", new File(newName));
//
BufferedImage bi1 = new BufferedImage(bufi.getWidth(this), bufi.getHeight(this), BufferedImage.SCALE_DEFAULT);
Graphics2D big1 = bi.createGraphics();
big1.drawImage(bufi, 0, 0, this);
String newName1 = originalImage.substring(0, originalImage.indexOf(".")) + "CopySCALE_DEFAULT.jpg";
ImageIO.write(bi1, "jpg", new File(newName1));
//
String newName3 = originalImage.substring(0, originalImage.indexOf(".")) + "CopyScreateJPEGEncoder.jpg";
OutputStream out = new FileOutputStream(newName3);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
encoder.encode(bufi);
out.close();
//
} catch (Exception ex) {
ex.printStackTrace();
}
}

   <<Less
About | Sitemap | Contact