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?

Similar Messages

  • 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();
    }

  • "out of memeory" error with Adobe Reader x & IE8

    Hello,
    Getting an "out of memory" error with Adobe Reader X & IE8. This is a locked down bank environment so upgrading to a higher version of Adobe is out of the question.
    I looked around on the web and noticed that many people are experiencing this "out of memory error" but no fix has been provided.
    Can you help?

    Thanks for the reply and suggestion - unfortunately, I get this error when I open Adobe Reader X itself in addition to launching a pdf within IE9 (my OS is Win7x64 Ultimate).  I can launch Adobe Reader X, but when I open any kind of PDF file (local copy, remote, web, etc...) the error dialog box pops up.  Everything seems functional with Reader, it's just a frustrating (er, irritating!) thing!  I think after the weekend I will 'give up' and remove the Reader X and go back to my 'old' (but functioning!) Reader - thanks for the comment and suggestion tho!

  • 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

  • Error in oDataModel READ method

    Hi Experts,
    I am using read method in oDataModel. The code is below:
    sap.ui.getCore().getModel().read("/E_EXCISE_DATA_SET", exData, null,true,
                                                             function(e){ alert("success"); },
                                                             function(oError){ alert("Insert Failure");  } );
    It is throwing an error - "Uncaught TypeError: Object [object Array] has no method 'getPath' "
    Actually I want to call the HTTP get method from the UI. In debugging mode I am getting above error. How to resolve this?
    What are the parameters for read method I need to pass? Kindly provide the code example for the read method.
    Thanks in advanced,
    Regards,
    Arindam Samanta.

    Hi Arindam,
    check once if you are getting object for sap.ui.getCore().getModel() (you should set model to the core before this code.) .
    Here is the model defination :
    var oDataModel=new sap.ui.model.odata.ODataModel("serviceUrl", true,"uName","Password");
    and here is the read on that model and various paramaters:(This you can get in eclipse help)
    oDataModel.read(sPath, oContext, oUrlParams, bAsync, fnSuccess, fnError);
    Parameters: {string} sPath A string containing the path to the data which should be retrieved. The path is concatenated to the sServiceUrl which was specified in the model constructor.
                       {object} [oContext] If specified the sPath has to be is relative to the path given with the context.
                        {any[]} [oUrlParams] An map of url parameters which will be concatenated to the read url
                       {boolean} [bAsync] true for asynchronous requests. Default is true.
                        {function} [fnSuccess] a callback function which is called when the data has been successfully retrieved. The handler can have the following parameters: oData and response.
                       {function} [fnError] a callback function which is called when the request failed. The handler can have the parameter: oError which contains additional error information.
    Ex :
    Lets say you want to read the data from this service path :
    http://<host>:<port>/sap/opu/odata/<service>/Employee('10000')
    in that case you can define model as
    var oDataModel=new sap.ui.model.odata.ODataModel("http://<host>:<port>/sap/opu/odata/<service>/", true,"uName","Password");
    and read as
    oDataModel.read("/Employee('10000')", null, null, false, function fnSuccess(oData){
    alert("result :"oData);
    },function fnError(response){
    on success, fnSuccess will get fired and you should see resut : object alert message.
    regards,
    Vijay.

  • BufferedImage 'null' with ImageIO.read(url)

    Hi,
    I am trying to display a JSP as an image which can be used in another JSP's img tags.
    Here is how I coded image.jsp.
    I observed that for 'bmp' image type, image object is 'null'. When I directly open 'bmp' image url in browser, it opens correctly.
    <%@ page import = "java.io.*" %>
    <%@ page import = "java.awt.image.BufferedImage"%>
    <%@ page import = "javax.imageio.ImageIO"%>
    <%@ page import = "javax.imageio.spi.IIORegistry"%>
    <%@ page import = "java.net.URL"%>
    <%@ page import = "java.net.URLEncoder"%>
    <%
         try{ 
              String imgUrl = URLEncoder.encode(request.getParameter("imgUrl"));
              imgUrl = imgUrl.replaceAll("%3A",":");
              imgUrl = imgUrl.replaceAll("%2F","/");     
              imgUrl = imgUrl.replaceAll("\\+","%20");     
              String[] urlSplit = imgUrl.split("\\.");          
              String imgTyp = urlSplit[urlSplit.length-1];
              URL url = new URL(imgUrl);
              BufferedImage image = null;
              image = ImageIO.read(url);
              ByteArrayOutputStream bas = new ByteArrayOutputStream();
              ImageIO.write(image,imgTyp, bas);
              byte[] imgData = bas.toByteArray();
              response.setContentType("image/"+imgTyp);
              OutputStream o = response.getOutputStream();
              o.write(imgData);
              o.flush();
              o.close();
        catch (Exception e)
           e.printStackTrace();
        finally{
    %>Any idea, why is this happening?
    With regards,
    Amey

    Hi EJP,
    Thanks for reply.
    I now changed my code to this: -
    <%@ page import = "java.io.*" %>
    <%@ page import = "java.awt.image.BufferedImage"%>
    <%@ page import = "javax.imageio.ImageIO"%>
    <%@ page import = "javax.imageio.spi.IIORegistry"%>
    <%@ page import = "java.net.URL"%>
    <%@ page import = "java.net.URLEncoder"%>
    <%@ page import = "com.sap.tc.logging.Location"%>
    <%
         Location location = Location.getLocation("AmeyTestPar.imageJSP");
         try{
              String imgUrl = request.getParameter("imgUrl");
              location.fatalT("imgUrl = " + imgUrl);
              String[] urlSplit = imgUrl.split("\\.");          
              String imgTyp = urlSplit[urlSplit.length-1];
              URL url = new URL(imgUrl);
              BufferedImage bufferedImage = ImageIO.read(url);
              OutputStream outputStream = response.getOutputStream();
              response.setContentType("image/"+imgTyp);
              ImageIO.write(bufferedImage,imgTyp, outputStream);
              outputStream.flush();
              outputStream.close();
       }catch (Exception e){  
              location.fatalT("Exception in image.jsp : " + e.getMessage());
             e.printStackTrace();
    %>But this is running into 'java.lang.IllegalArgumentException: im == null!" at
    jvax.imageio.ImageIO.write(ImageIO.java:1413)
    and
    jvax.imageio.ImageIO.write(ImageIO.java:1508)
    Also, I heard about use of image type plugins in package 'javax.imageio.plugins'.
    I added 'jai_imageio-1.1.jar' in build path and inserted 'ImageIO.scanForPlugins()' line in code.
    But this didn't help either.
    With regards,
    Amey

  • Decode error with japanese input

    hi,
    i have no problem displaying japanese text. but i have problem accepting japanese text from my jsp application.
    i got the following error when i submit a form contains japanese text input:
    Error: 500
    Location: /proj/myProj.jsp
    Internal Servlet Error:
    java.lang.IllegalArgumentException: Decode error
         at org.apache.tomcat.util.RequestUtil.unUrlDecode(RequestUtil.java:353)
         at org.apache.tomcat.util.RequestUtil.processFormData(RequestUtil.java:233)
         at org.apache.tomcat.core.RequestImpl.handleParameters(RequestImpl.java:686)
         at org.apache.tomcat.core.RequestImpl.getParameterValues(RequestImpl.java:259)
         at org.apache.tomcat.core.RequestImpl.getParameter(RequestImpl.java:250)
         at org.apache.tomcat.facade.HttpServletRequestFacade.getParameter(HttpServletRequestFacade
    pls advice me what could be the possible error.
    thank u.

    Did you ever have any luck with that? I am having a similiar problem - displaying the Euro sign (�). But it can display it no problem when displaying it from the Database.
    Did anyone ever get a solution?
    Any help is appreciated - thanks Liam.

  • 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

  • File does not begin with '%pdf' error with adobe reader 10.1.5 onwards

      In our web application we are using activePDF toolkit (3rd party component) to fill up carrier forms on the fly which are PDF files.
    The output file processed by the above library works fine when opened with adobe reader 8, 9 and10 on end user’s browser (IE); however, it gives below error when opening with adobe reader 11.
    Till now, we have tried different settings at IIS level, Internet explorer e.t.c. suggested on different internet posts. However, we are still facing the problem.
    While analyzing this we have come across following link
    http://helpx.adobe.com/acrobat/kb/pdf-error-1015-11001-update.html
    According to this adobe 10.1.5 onward file should only start with "%pdf". If file start with other than this we get file corrupted message.
    Before we can communicate this message to client we want to confirm this for experts. Please let me know my assumption is right?

    Rahti - i'm having the same issue but I not familiar with the steps outlined in the Adobe link below
    http://helpx.adobe.com/acrobat/kb/pdf-error-1015-11001-update.html
    Would you be able to help with how I can navigate to this on my PC to correct it for me.
    Thanks.

  • Runtime error with Adobe Reader 9.x and IE

    I'm getting a runtime error with any adobe reader 9.x and Internet Explorer whenever a .pdf is being viewed online.  It will pull the .pdf up and then pop up a runtime error window and close it down completely.  It is only happening with individuals that have redirected app data folders and profiles.  I have all machines running Windows XP sp3 and IE8.  I know, I know, I can always go to Firefox or Chrome, but IE is easily managed with group policy lockdowns.  I can unintall reader 9.x and then reinstall 8.x and it works perfectly.  The only problem with that is that I have to go do every machine and physically uninstall since I buildt the windows xp installer package with it.  Does anyone know a workaround or if adobe is going to get it fixed pretty soon?

    I am experiencing exactly the same problems on one of two identical machines after something happened in the registry.
    The first problem that appered was an error 1325 "Favorites is not a valid short name".
    I did find the registry key involved (%userprofile%\Favorites) and fixed it.
    So now the the next one: yours.
    I think the solution can be found in the list of registry keys that Adobe Reader is accessing.
    btw Eusing registry cleaner did not find this key to be in error.
    Problem is that the Reader does not ask for an alternative location after stumbling on the key.
    Who can gnerate a list of keys accessed?

  • Problem with using read() method of BufferedInputStream

    Hi,
    I m using BufferedInputStream for reading from a socket and I m using read() method for getting data character by character from it . It runs successfully for sometime and then blocks indefinitely and hangs the application. Maybe , when it does not find any data to be read from socket or the LAN connection is broken, it keeps on trying and blocks further processing.
    Is there any way to solve this problem so that it does not hangs the application and comes out gracefully ?
    Thanx and regards,
    Aartee Goyal

    Most read-methods are blocking, if there is nothing to read.
    If you don't want, that your application is blocking, too, the read method has to run in a thread.
    The second possibility is, to ask, whether there is something to read
    BufferedInputStream bis = ...
    if (bis.available() > 0) {
       int b = bis.read();
    else {
       // sleep or break or ???
    }

  • Paper Form Barcode decode error with UTF8 Chinese

    I have a Paper Form Barcode
    Symbology: QR Code
    Scaning Method: Custom
    Error correction level: M
    Modul width:0.592 mm
    Character Encoding: UTF-8
    But sometime QR code decode data not equal original data
    Case 1:
    PaperFormsBarcode1.rawValue = "哈哈";
    After decode: I got "哈哈"  ==> OK
    Case 2:
    PaperFormsBarcode1.rawValue = "哈|哈哈|"
    After decoe: I got "蜩�蜩亥嶋|"  ==> Error!!!
    Case 3:
    PaperFormsBarcode1.rawValue = "A|哈哈|"
    After decode: I got "A|哈哈|"  ==> OK
    Decoder:
    I tried several Android / iOS APP on several cellphones, and they ALL got same result.
    Our client (Bank) bought Adobe Livecycle ES4 Soluction, and we need your help very much, thank you!

    do you have the asian language packs installed?  i can't comment on this specific example but i know that we've had odd issues with japanese characters because we hadn't installed the right language packs.

  • AcroExch Error with Abobe Reader (11.0.03)

    I work on a helpdesk, and we keep getting people with the following error while trying to embed PDFs into Word documents. "The program used to create this object is AcroExch. That program is either not installed on your computer or it is not responding. To edit this object, install AcroExch or ensure that any dialog boxes in AcroExch are closed." I tried most of the obvious things to solve this problem (repaired Office and Reader, reverted back to an older version of reader, ran C Cleaner). I also tried some more obscure things like deleting old keys from the resistry manually and things of that nature. I don't know what else to try. There seem to be some fixes for this problem in Adobe Reader X, but based on what I've seen, none of these work in Reader XI. Does anyone know how to fix this issue?

    I had the same problem! When I try to import a pdf object in word it gave a Package or an AcroExch error, if I'm using the drag and drop method or the insert-object menu, respectively.
    System: Win7 SP1 64bits EN + Office 2010 Professional 64bits EN + Acro Read 11 EN
    I did a survey among several computers at my workplace and discovered that only the computers with Win7 64 + Office pro 64 combo have this problem. I removed both Office 64bits and Acro Reader and installed the Office 32bits version. Afterwards reinstalled the Acro Reader (same version). The problem never appeared again. It seams an issue with the 64bits version.
    Previously, I also tried the most common solutions found on Internet and none of them solved the problem.
    Hope it helps.
    Cheers.

  • Error with declaring a method with array variable

    Hi,
    I had implemented this:
    import java.awt.*;
    import javax.swing.*;
    public class Oefening1
         public static void main(String args[])
              int array[]= new int[10];
              int getal;
              JTextArea outputArea = new JTextArea();
              Container container = getContentPane();
              container.add(outputArea);
              public void invoerRij(int array[10])
                   output +=" ";
                   for(int counter = 0; counter <10;counter++){
                        output +="Geef een getal in"+"\n"+array[counter]+"\n";
                        outputArea.setText(output);
    I had comilated this code while the compiler gave errors like these:
    A:\Oefening1.java:15: illegal start of expression
              public void invoerRij(int array[10])
    ^
    A:\Oefening1.java:24: ';' expected
    ^
    A:\Oefening1.java:12: cannot resolve symbol
    symbol : method getContentPane ()
    location: class Oefening1
              Container container = getContentPane();
    ^
    3 errors
    Tool completed with exit code 1
    Now i have read my book and finded out that the declaration of a method always starts with public.
    Can anyone halp me solving these probs? Thanks
    Crazydj1

    The problem is that you didn't close the previous method definition.
    Compiler error messages (in any language) often mistakenly report false errors on perfectly valid code immediately following the actual error.
    When you post code on these forums, please wrap in in &#91;code]&#91;/code] tags.

  • 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 :)

Maybe you are looking for