Problem with ImageIO.read()

I have a problem with loading picture from file to variable Image img. Function ImageIO.read(fileIn) return always null pointer (whereas fileIn!=null). I'm using j2sdk-1_4_2_0. The same problem problem is in WindowsXP SP2 and Fedora 3 64bit.
Here is code:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.net.*;
import java.awt.image.*;
import javax.imageio.*;
import java.net.URL;
import javax.imageio.ImageIO;
import java.io.*;
public class Converter extends JPanel implements ActionListener {
JPanel mainPanel, info1Panel,info2Panel,convertionPanel, fSizePanel,displayPanel;
JCheckBox enableConvertion;
JButton selectFile,doIt,close;
JRadioButton size1,size2;
ButtonGroup sizeGroup;
ImageIcon imagePrev;
JRadioButton[] convertion = new JRadioButton[2];
Image img;
JLabel previewLabel;
JFileChooser fc;
File fileIn = new File("10.jpg");
File fileOut;
public Converter() {
// Tworzenie paneli
mainPanel=new JPanel();
mainPanel.setLayout(null);
info1Panel=new JPanel();
info2Panel=new JPanel();
convertionPanel=new JPanel(new BorderLayout());
fSizePanel=new JPanel();
displayPanel= new JPanel();
//Tworzenie pozostalych elementow
enableConvertion = new JCheckBox("Enable JPG <-> PNG");
selectFile = new JButton("Select File");
doIt = new JButton("Do it!");
close= new JButton("Close");
fc = new JFileChooser();
size1 = new JRadioButton("The same resolution");
size2= new JRadioButton("Resize image to target size of file");
JLabel previewLabel = new JLabel();
ButtonGroup sizeGroup = new ButtonGroup();
imagePrev= new ImageIcon();
// proba ulozenia elementow na ramce
Insets insets = mainPanel.getInsets();
Dimension size = selectFile.getPreferredSize();
selectFile.setBounds(15 + insets.left, 15 + insets.top,size.width, size.height);
doIt.setBounds(15 + insets.left,15+5+ insets.top+size.height,size.width, size.height);
close.setBounds(15+insets.left,15+2*(5+size.height)+insets.top,size.width,size.height);
convertionPanel.setBounds(10,150,250,90);
convertionPanel.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createTitledBorder("Convertion"),
BorderFactory.createEmptyBorder(0,5,5,5)));
info1Panel.setBounds(150,10,200,140);
info1Panel.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createTitledBorder("Source File Information"),
BorderFactory.createEmptyBorder(0,5,5,5)));
info2Panel.setBounds(360,10,200,140);
info2Panel.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createTitledBorder("Target File Information"),
BorderFactory.createEmptyBorder(0,5,5,5)));
fSizePanel.setBounds(10, 250, 250, 90);
fSizePanel.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createTitledBorder("File size"),
BorderFactory.createEmptyBorder(0,5,5,5)));
fSizePanel.setLayout(new GridLayout(2,0));
displayPanel.setBounds(270,150,290,190);
displayPanel.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createTitledBorder("Display"),
BorderFactory.createEmptyBorder(0,5,5,5)));
previewLabel.setHorizontalAlignment(JLabel.CENTER);
previewLabel.setVerticalAlignment(JLabel.CENTER);
previewLabel.setVerticalTextPosition(JLabel.CENTER);
previewLabel.setHorizontalTextPosition(JLabel.CENTER);
previewLabel.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createLoweredBevelBorder(),
BorderFactory.createEmptyBorder(5,5,5,5)));
previewLabel.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createEmptyBorder(0,0,10,0),
previewLabel.getBorder()));
size1.setSelected(true);
mainPanel.add(info1Panel);
mainPanel.add(info2Panel);
mainPanel.add(convertionPanel);
mainPanel.add(fSizePanel);
mainPanel.add(displayPanel);
//osadzamy w odpowiednich panelach elementy
mainPanel.add(selectFile);
mainPanel.add(doIt);
mainPanel.add(close);
sizeGroup.add(size1);
sizeGroup.add(size2);
fSizePanel.add(size1);
fSizePanel.add(size2);
displayPanel.add(previewLabel);
convertionPanel.add(enableConvertion);
selectFile.addActionListener(this);
public void actionPerformed(ActionEvent e) {
int returnVal = fc.showOpenDialog(Converter.this);
if (returnVal == JFileChooser.APPROVE_OPTION)
File fileIn = fc.getSelectedFile();
JFrame frame1=new JFrame();
JOptionPane.showMessageDialog(frame1, fileIn.getName());
if(fileIn==null)
JFrame frame2 = new JFrame();
JOptionPane.showMessageDialog(frame2,"FileIN==NULL");
//############## PROBLEM IS HERE ###########################
try
Image img=ImageIO.read(fileIn); // HERE IS THE PROBLEM: img==NULL
// WHERAS fileIn!=NULL
}catch (IOException event){}
if (img==null)
JFrame frame2 = new JFrame();
JOptionPane.showMessageDialog(frame2,"img==NULL");
private static void createAndShowGUI() {
//Make sure we have nice window decorations.
JFrame.setDefaultLookAndFeelDecorated(true);
//Create a new instance of LunarPhases.
Converter conv = new Converter();
//Create and set up the window.
JFrame convFrame = new JFrame("Conversion JPG <-> PNG");
convFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
convFrame.setContentPane(conv.mainPanel);
Insets insets = convFrame.getInsets();
convFrame.setSize(600 + insets.left + insets.right,400+insets.top + insets.bottom);
convFrame.setVisible(true);
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}

//############## PROBLEM IS HERE ###########################
try {
Image img=ImageIO.read(fileIn); // HERE IS THE PROBLEM: img==NULL
// WHERAS fileIn!=NULL
} catch (IOException event){}
if (img==null) {
    JFrame frame2 = new JFrame();
    JOptionPane.showMessageDialog(frame2,"img==NULL");
}1. Please use [code] tags when posting code -- it makes the code more readable.
2. When posting code, post a minimal example program. You could have filtered
out all the extraneous GUI code, for example. Remember: the shorter the code, the
more likely it is a forum member will read it! Posting long runs of code only
hurts yourself.
3. All that being said, your problem is a simple oversight: notice that the
variable "img" in your try block is a local variable, not the field named "img"
than you test after the try block.
You should have written:
try {
    img=ImageIO.read(fileIn);
} catch (IOException event){
    e.printStackTrace();
}

Similar Messages

  • Problem with ImageIO.read and ImageReader JPG colors are distorted/wrong

    (Using JDK 1.5)
    ImageIO incorrectly reads some jpg images.
    I have a jpg image that, when read by the ImageIO api, all the colors become reddish.
            try
                java.awt.image.BufferedImage bi = javax.imageio.ImageIO.read( new java.io.File("javabug.jpg") );
                javax.imageio.ImageIO.write( bi, "jpg", new java.io.File("badcolors.jpg") );
                javax.imageio.ImageIO.write( bi, "png", new java.io.File("badcolors.png") );
            catch ( java.io.IOException ioe )
                ioe.printStackTrace();
            }Why is this happening??? My guess is there is a problem with the ImageIO.read ?
    the jpg can be downloaded at http://www.alwaysvip.com/javabug.jpg
    <BufferedImage@11faace: type = 5 ColorModel: #pixelBits = 24 numComponents = 3 color space = java.awt.color.ICC_ColorSpace@1ebbfde transparency = 1 has alpha = false isAlphaPre = false ByteInterleavedRaster: width = 1691 height = 1269 #numDataElements 3 dataOff[0] = 2>
    I have even tried creating a new buffered image but still have the same problem:
    (suggested by http://forum.java.sun.com/thread.jspa?forumID=20&threadID=665585) "Java Forums - ImageIO: scaling and then saving to JPEG yields wrong colors"
            try
                java.awt.image.BufferedImage bi = javax.imageio.ImageIO.read( new java.io.File("javabug.jpg") );
                java.awt.image.BufferedImage out = new java.awt.image.BufferedImage( bi.getWidth(), bi.getHeight(), java.awt.image.BufferedImage.TYPE_INT_RGB );
                java.awt.Graphics2D g = out.createGraphics();
                g.drawRenderedImage(bi, null);
                g.dispose();
                javax.imageio.ImageIO.write( out, "jpg", new java.io.File("badcolors.jpg") );
            catch ( java.io.IOException ioe )
                ioe.printStackTrace();
            }I have used the following which works but does not use the ImageIO api. However, I tried using the ImageIO to write and it worked for writing which leads me to believe there is a problem with the reader.
    (suggested by http://developers.sun.com/solaris/tech_topics/java/articles/awt.html "Server-Side AWT")
            try
                java.awt.Image image = new javax.swing.ImageIcon(java.awt.Toolkit.getDefaultToolkit().getImage("javabug.jpg")).getImage();
                java.awt.image.BufferedImage bufferedImage = new java.awt.image.BufferedImage( image.getWidth( null ), image.getHeight( null ), java.awt.image.BufferedImage.TYPE_INT_RGB );
                java.awt.Graphics g = bufferedImage.createGraphics();
                g.setColor( java.awt.Color.white );
                g.fillRect( 0, 0, image.getWidth( null ), image.getHeight( null ) );
                g.drawImage( image, 0, 0, null );
                g.dispose();
                com.sun.image.codec.jpeg.JPEGImageEncoder encoder = com.sun.image.codec.jpeg.JPEGCodec.createJPEGEncoder( new java.io.FileOutputStream( "goodcolors.jpg" ) );
                encoder.encode( bufferedImage );
                javax.imageio.ImageIO.write( bufferedImage, "jpg", new java.io.File("goodiocolors.jpg") );
                javax.imageio.ImageIO.write( bufferedImage, "png", new java.io.File("goodiocolors.png") );
            catch ( java.io.IOException ioe )
                ioe.printStackTrace();
            }BTW, the following does not work either:
                java.util.Iterator readers = javax.imageio.ImageIO.getImageReadersByFormatName( "jpg" );
                javax.imageio.ImageReader reader = ( javax.imageio.ImageReader ) readers.next();
                javax.imageio.stream.ImageInputStream iis = javax.imageio.ImageIO.createImageInputStream( new java.io.File("javabug.jpg") );
                reader.setInput( iis, true );
                java.awt.image.BufferedImage bufferedImage = reader.read( 0 );

    I figured out the problem. It was an actual BUG in the JDK!
    The code failed with the following JDKs:
    java version "1.5.0_01"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
    Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)
    java version "1.5.0_03"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-b07)
    Java HotSpot(TM) Client VM (build 1.5.0_03-b07, mixed mode)
    The code ran sucessful with this JDK:
    java version "1.5.0_06"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
    Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)
    If you are using the ImageIO classes, I highly suggest you upgrade to the latest JDK.
    Best,
    Scott

  • Problem with ImageIO.read and ImageReader GIF becomes dark

    I am having problems with certain GIF images loading completely dark. I previously had problems with certain JPGs colors being distorted http://forum.java.sun.com/thread.jspa?threadID=713164&tstart=0. This was a problem in an old JDK.
    Here is the code:
                java.awt.image.BufferedImage bufferedImage = javax.imageio.ImageIO.read( new java.io.File("javabug.gif") );
                System.out.println( bufferedImage );
                javax.imageio.ImageIO.write( bufferedImage, "jpg", new java.io.File("badcolors.jpg") );
                javax.imageio.ImageIO.write( bufferedImage, "png", new java.io.File("badcolors.png") );BufferedImage Read is:
    BufferedImage@337838: type = 5 ColorModel: #pixelBits = 24 numComponents = 3 color space = java.awt.color.ICC_ColorSpace@119cca4 transparency = 1 has alpha = false isAlphaPre = false ByteInterleavedRaster: width = 1536 height = 1152 #numDataElements 3 dataOff[0] = 2
    Here is the GIF
    http://www.alwaysvip.com/javabug.gif
    I am using jdk1.5.0_06
    If I use java.awt.Toolkit.getDefaultToolkit().getImage instead of ImageIO.read, the problem no longer exists.
            java.awt.Image image = java.awt.Toolkit.getDefaultToolkit().getImage( file.toURL() );
            java.awt.MediaTracker mediaTracker = new java.awt.MediaTracker( new java.awt.Container() );
            mediaTracker.addImage( image, 0 );
            mediaTracker.waitForID( 0 );
            java.awt.image.BufferedImage bufferedImage = new java.awt.image.BufferedImage( image.getWidth( null ), image.getHeight( null ), java.awt.image.BufferedImage.TYPE_INT_RGB );
            java.awt.Graphics g = bufferedImage.createGraphics();
            g.setColor( java.awt.Color.white );
            g.fillRect( 0, 0, image.getWidth( null ), image.getHeight( null ) );
            g.drawImage( image, 0, 0, null );
            g.dispose();
            javax.imageio.ImageIO.write( bufferedImage, "jpg", new java.io.File("goodcolors.jpg") );
            javax.imageio.ImageIO.write( bufferedImage, "png", new java.io.File("goodcolors.png") );BufferedImage Read is:
    BufferedImage@1bf216a: type = 1 DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=0 IntegerInterleavedRaster: width = 1536 height = 1152 #Bands = 3 xOff = 0 yOff = 0 dataOffset[0] 0
    Is this another bug in the JDK? Is there a possible workaround where I can still use ImageIO.read?

    I figured out the problem. It was an actual BUG in the JDK!
    The code failed with the following JDKs:
    java version "1.5.0_01"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
    Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)
    java version "1.5.0_03"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-b07)
    Java HotSpot(TM) Client VM (build 1.5.0_03-b07, mixed mode)
    The code ran sucessful with this JDK:
    java version "1.5.0_06"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
    Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)
    If you are using the ImageIO classes, I highly suggest you upgrade to the latest JDK.
    Best,
    Scott

  • Intermittent problem with ImageIO reading BMP: Empty Region

    I am using imageIO to read in a bmp file, like this:
          ImageInputStream is = ImageIO.createImageInputStream(imgURL.openStream());
          Iterator<ImageReader> rdrs = ImageIO.getImageReaders(is);
          if (rdrs.hasNext()) {
            ImageReader r = rdrs.next();
            r.setInput(is);
            result = r.read(0);
          }(I use the same code to read in a whole bunch of images of various kinds.) In development, I got an empty image, so I added a wait:
    MediaTracker mt = new MediaTracker(new MyObserver());
        mt.addImage(iconImage, 0);
        try {
          mt.waitForID(0);
        } catch (InterruptedException e) {
        }which seemed to work fine. Except that sometimes, not always, I got a crash:
    java.lang.IllegalArgumentException: Empty region!
         at javax.imageio.ImageReader.computeRegions(Unknown Source)
         at com.sun.imageio.plugins.wbmp.WBMPImageReader.read(Unknown Source)
         at javax.imageio.ImageReader.read(Unknown Source)I got that sometimes in development, but once I produced the production version it started happening all the time!
    Anyone have an idea what's going on??

    That was very close to correct. It seems that the WBMP reader mucks up the input stream before the .ico reader can get to it. The .ico plugin, which is available at [http://www.vdburgh.net/2/f/files/ICOReader/ ] puts out a very nice error message to that effect and suggest using a fresh input stream. So this:
          ImageInputStream is = ImageIO.createImageInputStream(imgURL.openStream());
          Iterator<ImageReader> rdrs = ImageIO.getImageReaders(is);
          while (rdrs.hasNext()) {
            ImageReader r = rdrs.next();
            try {
              r.setInput(is);
              result = r.read(0);
              return result;
            } catch (IllegalArgumentException e) {
              System.out.printf("Bad Image:%s%n", e.getMessage());
              is = ImageIO.createImageInputStream(imgURL.openStream());
          }Does the trick! (So far :)

  • Problem with Adobe Reader not being able to run with Maverick  10.9.2?

    problem with Adobe Reader not being able to run with Maverick  10.9.2?

    Have you updated your version of Adobe Reader?

  • Problem with adobe reader, commenting

    one of our authors is using adobe reader x 11,1, and I send him a pdf (enabled commenting and measuring), but for some reason the commenting-fields does not show on his screen?
    should I save the pdf in another way?

    What do you mean by "commenting fields" exactly? By “commenting filds” I mean the tools in top of the page – delete, highlight etc. When I send the pdf, I save it as “file - save as -  reader extended pdf – enable commenting and measuring”, otherwise the commenting tools normally don’t appear by the author.
    Are they existing comments? no, it is the text in his pdf-book he needs to correct
    Is he able to access the commenting tools? no
    You can try sending a non-enabled version since Reader 11 can add comments to a non-enabled document. will try that J
    Fra: George Johnson [email protected]
    Sendt: 6. november 2012 16:16
    Til: Forlagene Idag & Nordan
    Emne: problem with adobe reader, commenting
    Re: problem with adobe reader, commenting
    created by George Johnson <http://forums.adobe.com/people/George_Johnson>  in Creating, Editing & Exporting PDFs - View the full discussion <http://forums.adobe.com/message/4826849#4826849

  • Continued problems with Adobe Reader 9.3.1

    Adobe Reader stops at the half-way mark in the progress block when loading a form to print.  Cannot get this fixed. Does anyone out there have a fix for this.  Is Adobe even recognizing that there is a problem with this.  Error message keeps telling me that there is a problem with Adobe Reader, exit and try again.

    I haven't been able to print any .pdf files since I downloaded 9.3.
    My message says Internet Explorer has closed it down because of data executable files.  I've changed my DEF settings to allow
    Adobe Reader but it still doesn't work.  I never had any problems before with newer versions.

  • Having problem with adobe reader

    Hi,
    I have a problem with adobe reader in my cell phone E71 model recently.I could open any pdf files till yesterday,but now without any reason the adobe reader icon in the office folder does not open.I wanna know what should I do.

    Might be some problem with adobe reader. You may Google another pdf app called pdf plus. Install it and see if the problem is solved or not.
    Nokia C7

  • Problems with flash reader, flash reader

    problems with flash reader, flash reader

    flash reader is an App for iPhone, iPad and iPod. Do you mean Flash Player?
    And, what is the problem?

  • Trying to open PDF getting error message " there is a problem with Acrabat /Reader. Please exit Adob

    I have windows XP, when I am trying open PDF getting a error message " there is a problem with Acrabot /Reader. Please exit Adobe Acrabat/Reader Please try again'  It was working earlier today  HELP

    If all else fails, you can try one of 2 things (I will assume you are talking about Reader - though this is not the Reader forum). Use ctrl-alt-del to go to the task list. Kill AcroRd32.exe. Then try again. If that does not work, a reboot will probably solve the problem.

  • JPEG image decode error with ImageIO.read() method

    Environment: Linux 64-bit, JDK 1.6.0_14 amd64, JAI 1.1.3 amd64
    When I tried to read this image http://farm4.static.flickr.com/3655/3591243423_a258d87ea6.jpg as URL or just the image 3591243423_a258d87ea6.jpg as a local file using ImageIO.read(URL), ImageIO.read(InputStream) or ImageIO.read(String), I got this exception:
    Caused by: java.lang.IllegalArgumentException: Numbers of source Raster bands and source color space components do not match
            at java.awt.image.ColorConvertOp.filter(ColorConvertOp.java:460)
            at com.sun.imageio.plugins.jpeg.JPEGImageReader.acceptPixels(JPEGImageReader.java:1102)
            at com.sun.imageio.plugins.jpeg.JPEGImageReader.readImage(Native Method)
            at com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(JPEGImageReader.java:1070)
            at com.sun.imageio.plugins.jpeg.JPEGImageReader.read(JPEGImageReader.java:885)
            at javax.imageio.ImageIO.read(ImageIO.java:1422)
            at javax.imageio.ImageIO.read(ImageIO.java:1326)This can be fixed by adding the jai-imageio-1.1 extension( and recent daily builds too). However, that package is not stable, with memory corruption problem from time to time indicated by this:
    *** glibc detected *** /usr/java/jdk1.6.0_13/bin/java: malloc(): memory corruption: 0x000000004d73a3a0 ***Another way to overcome this is using JAI.create("URL", url) or JAI.create("fileload", file) API, which can decode the image but unfortunately the performance is much worse than the ImageIO.read method. So I compromised by using ImageIO.read first and on exception using JAI APIs on the occasional problem image, which looks ugly.
    What would be a better way of handling this?

    Environment: Linux 64-bit, JDK 1.6.0_14 amd64, JAI 1.1.3 amd64
    When I tried to read this image http://farm4.static.flickr.com/3655/3591243423_a258d87ea6.jpg as URL or just the image 3591243423_a258d87ea6.jpg as a local file using ImageIO.read(URL), ImageIO.read(InputStream) or ImageIO.read(String), I got this exception:
    Caused by: java.lang.IllegalArgumentException: Numbers of source Raster bands and source color space components do not match
            at java.awt.image.ColorConvertOp.filter(ColorConvertOp.java:460)
            at com.sun.imageio.plugins.jpeg.JPEGImageReader.acceptPixels(JPEGImageReader.java:1102)
            at com.sun.imageio.plugins.jpeg.JPEGImageReader.readImage(Native Method)
            at com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(JPEGImageReader.java:1070)
            at com.sun.imageio.plugins.jpeg.JPEGImageReader.read(JPEGImageReader.java:885)
            at javax.imageio.ImageIO.read(ImageIO.java:1422)
            at javax.imageio.ImageIO.read(ImageIO.java:1326)This can be fixed by adding the jai-imageio-1.1 extension( and recent daily builds too). However, that package is not stable, with memory corruption problem from time to time indicated by this:
    *** glibc detected *** /usr/java/jdk1.6.0_13/bin/java: malloc(): memory corruption: 0x000000004d73a3a0 ***Another way to overcome this is using JAI.create("URL", url) or JAI.create("fileload", file) API, which can decode the image but unfortunately the performance is much worse than the ImageIO.read method. So I compromised by using ImageIO.read first and on exception using JAI APIs on the occasional problem image, which looks ugly.
    What would be a better way of handling this?

  • Problems with ImageIO.write()

    Well I am finding it very strange with ImageIO.write();
    Consider the following code snippet:
    BufferedImage img=ImageIO.read(new File("fw2.jpg"));
    BufferedImage img1=new BufferedImage(img.getWidth(),img.getHeight(),img.TYPE_INT_ARGB);
    for(int i=0;i<img.getHeight();i++)
    for(int j=0;j<img.getWidth();j++)
    img1.setRGB(j,i,img.getRGB(j,i));
    ImageIO.write(img1,"jpg",new File("fwinv.jpg"));
    So simply I am copying fw2.jpg to fwinv.jpg. fw2.jpg was also created
    using ImageIO.write().
    But the two files are having different pixel values.
    i.e If I read fwinv.jpg again I will get different pixel value that it was written.
    Why is this...Can any one please help me..

    Reading the written images back and displaying them in java works okay. The third image looks okay in RGB but wrong in ARGB when displayed by a native app. For more about this see reply 1 in Color problems and the linked bug report: Some Images written using JPEG Image Writer are not recognized by native applns.
    import java.awt.GridLayout;
    import java.awt.image.BufferedImage;
    import java.io.*;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    public class WriteTest {
        private JPanel getContent(BufferedImage src) throws IOException {
            File fileOne = new File("fileOne.jpg");
            ImageIO.write(src, "jpg", fileOne);
            BufferedImage image1 = ImageIO.read(fileOne);
            BufferedImage image2 = copy(image1);
            JPanel panel = new JPanel(new GridLayout(1,0));
            panel.add(new JLabel(new ImageIcon(src)));
            panel.add(new JLabel(new ImageIcon(image1)));
            panel.add(new JLabel(new ImageIcon(image2)));
            return panel;
        private BufferedImage copy(BufferedImage in) throws IOException {
            int w = in.getWidth();
            int h = in.getHeight();
            int type = BufferedImage.TYPE_INT_ARGB;   // problem in native apps
                       //BufferedImage.TYPE_INT_RGB;  // this one works okay
            BufferedImage out = new BufferedImage(w, h, type);
            for(int y = 0; y < h; y++) {
                for(int x = 0; x < w; x++) {
                    out.setRGB(x, y, in.getRGB(x, y));
            File fileTwo = new File("fileTwo.jpg");
            ImageIO.write(out, "jpg", fileTwo);
            return ImageIO.read(fileTwo);
        public static void main(String[] args) throws IOException {
            BufferedImage image = ImageIO.read(new File("images/cougar.jpg"));
            WriteTest test = new WriteTest();
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(test.getContent(image));
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
    }

  • Problem with Adobe Reader (GUI)

    Hi,
    I´ve got a problem with my Adobe Reader (v. 11.0.10). Everytime when I open some document, I´m getting graphical problems:
    Menu is hidden
    When I move by mouse over the menu, it dissappears.
    And when I maximize the window..
    Thanks for your help.

    Do you have any Kaspersky software installed?  If so, update to the latest version.

  • Problems with Adobe Reader and Flash Player

    I had an Adobe update last Monday and, ever since then, I can't view documents (eg credit card statements) on screen and sites that I previously visited regularly without problem suddenly say that I need to have Adobe Flash Player installed. I've downloaded Adobe Flash Player and it says it's installed correctly but when I return to the site, it still says I need Adobe Flash Player. I've also tried doing an uninstall first and then an instal but the same thing happens. I've run disk first aid and it found a problem with the Head which it fixed but I still can't open documents using Adobe in Safari. Adobe Plug ins tells me that the Internet Access plug in is not loaded but when I ran 'repair Adobe Reader installation", it said there were no missing components detected and repair was not needed. I don't know if it's relevant but I've been having problems with Safari for several weeks, quitting 3 or 4 times a day, mainly when I'm switching from Safari to another programme such as Entourage or Excel.
    Message was edited by: Aileen2

    Hi Carolyn
    I don't think I made it clear on the original post that I'm having problems with both Adobe Reader AND Adobe Flash Player. Unfortunately, all the Adobe Reader sites are confidential so I can't give you an illustration on that but for the Adobe Flash Player, try www.jacquielawson.com/ - you can preview cards without being signed in. With the Adobe Reader problems, I get a picture of a blank 'piece of paper' with a small blue square in the top right hand corner that has a white question mark inside it. The first time this happened to me, I was on the UK Inland Revenue site trying to print out some end of year forms. I phoned the Revenue's helpline and they said to try doing a 'save as' to my desktop. It seemed bizarre - saving a blank piece of paper - but lo and behold, when I opened it on my desktop, the forms appeared exactly as normal. However, I've since tried this 'save as' technique with my credit card statement and I still get a blank piece of paper with a blue square and white question mark when I open the desktop copy.
    Thanks for your help and patience. I really appreciate it.
    Aileen

  • Problem with Adobe Reader Plug-In (7, 8, and 9) on Windows XP

    We are experiencing a problem with the Adobe Reader plug-in and viewing documents hosted at our site.  The problem seems to happen with larger (over 5 MB) PDF files enabled for fast web viewing.  The problem never happens when viewing PDF image only files which are not enabled for fast web viewing.  The problem happens inside and outside our firewall, so it is not a firewall problem.  My organization has been hosting PDF files to the web at least all this decade, and this is the first time we have experienced and documented this problem on this scale.  We have ruled out the program creating the PDF file is causing the problem as I have eight sample PDF files created and modified by a variety of programs exhibiting the same issue.
    www.osti.gov/servlets/purl/945213-1jsnyF/
    Adobe Capture 3.0 / Adobe PDF Library 4.0
    www.osti.gov/servlets/purl/948577-R7PH1d/
    Adobe Capture 3.0 / Adobe PDF Library 4.0
    www.osti.gov/servlets/purl/959040-nPWEVJ/
    Adobe Acrobat 8.15 / Abbyy Recognition Server
    www.osti.gov/servlets/purl/961608-uR6ukp/
    PaperPort 10.0 / Abbyy Recognition Server
    www.osti.gov/servlets/purl/963955-8wBmHp/
    Adobe Acrobat 8.15 / Abbyy Recognition Server
    www.osti.gov/servlets/purl/964418-Ingskm/
    Adobe Acrobat 7.1 / Adobe Acrobat 7.1 Paper Capture Plug-in
    www.osti.gov/servlets/purl/963372-yhIUhW/
    Adobe Acrobat 7.08 / Abbyy Recognition Server
    www.osti.gov/servlets/purl/965399-4MBPMy/
    Xerox WorkCentre 7345 / Abbyy Recognition Server
    I can reproduce the problem with Internet Explorer 8.0.6 and Firefox 3.5.4 using Adobe Acrobat Plug-In 7.0.9.50 running on Windows XP Professional SP3.  Others have reproduced the problem with 8 and 9 versions of the plug-in on Windows XP Professional and Home.  Oddly, no one has been able to reproduce the problem with Unix/Linux versions of the plug-in or third party plug-ins.  This points to it being something wrong with Adobe Reader.
    The problem is when I attempt to view one of the eight PDFs in my browser, I can severely stall or lock it up if I attempt to view more than the first page before the whole document downloads.  Sometimes if you wait it out, the browser will unlock, but not display text on the pages.  Sometimes if you wait for the whole document to load before switching pages, it works.  Sometimes you can start switching pages and the document will not lock up at all.  All eight documents can be viewed without issue if downloaded to the PC's hard drive and then viewed with Adobe Acrobat 7.0.
    Can anyone point me to a technical document or reason why we would be experiencing this issue?  Even better, does anyone know the solution to these issues?
    Any help will be much appreciated.

    I looked at a few documents. They appear to be scans and scans that have been OCRd. It is also likely they have not been optimized for page view. This means that the document has to be fully downloaded before viewed. That means the browser may appear to freeze until the entire document is downloaded. Downloading the entire document appears to be a reasonable way to handle these files.

Maybe you are looking for