I am writing an image library for fun, and I ran into a problem that I cannot solve. The class is quite simple: take a picture, process it, show it through a JFrame, and finally save it as a BufferedImage (javax.imageio.ImageIO). Here's what my picture looks like through JFrame (this is my ColorEnhance class ... on the Drustan Nebula):

Here is the saved version (png, but all ImageIO.write () types are supported the same way):

I'm not sure where the change happens, but when I run it through my blur method, all lines appear from nothing in png ... Anyway, here is some 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); }
The last thing that saving works for some processing classes is better than others, if you need to see more code, just ask, thanks
source share