Note that there are some explanatory texts on larger screens.

plurals
  1. POJava ImagIO.write() changes quality during save
    primarykey
    data
    text
    <p>I am writing an image library for fun and i came across a problem that i can't seem to solve. The class is pretty simple: take a picture, process it, display it through JFrame, and finally save it as a BufferedImage (javax.imageio.ImageIO). Here is what my picture looks like through the JFrame (this is my ColorEnhance class... on the Drustan nebula):</p> <p><img src="https://i.stack.imgur.com/F0SCW.gif" alt="The image as seen from the JFrame"></p> <p>Here is what the saved version (a png, but all types ImageIO.write() supports look the same):</p> <p><img src="https://i.stack.imgur.com/jvcWL.gif" alt="The image as seen after it has been saved"></p> <p>I'm not sure where the change occurs, but when I run this through my blur method entire lines appear from nothing in the png... Anyways, here is some code:</p> <pre><code>public void writeToFile(BufferedImage finalPic, String nameToAppend) { String temp=fileName.replace(".", nameToAppend+"."); String ext=fileName.substring(fileName.indexOf(".")+1); File file=new File(temp); try { ImageIO.write(finalPic, ext.toUpperCase(), file); System.out.println("Successfully saved to: "+temp); } catch (Exception e) { e.getMessage(); } } public void displayImage(String titleName) { ImageIcon icon = new ImageIcon(newPic); JFrame frame = new JFrame(titleName); JLabel label = new JLabel(icon); label.setIcon(icon); frame.getContentPane().add(label, BorderLayout.CENTER); frame.setSize(WIDTH, HEIGHT+22); frame.setVisible(true); } </code></pre> <p>One last thing is that the save works for some processing classes better than others, if you need to see any more code just ask, thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload