Passing Image data through JNI?

Hello,
I am trying find the fastest way to pass image data from Java through JNI. Passing Java images through JNI seems to be a very common thing to do so I expect there's an oft-used approach. Can anyone give me a good explanation of this or point me to some references?
I need to pass the image data to a C++ function which operates on this data, writing the results to a destination buffer which goes back to Java and gets put back into an image.
Currently, I'm using BufferedImages and getRGB to get an int array from my source image, passing this through JNI along with another int array to be used as the destination buffer, then calling setRGB with my destination buffer after the JNI function returns. getRGB() preserves the alpha channel of png files, which is functionality I need. The problem with this approach is that getRGB is extremely slow. It can take up to two seconds with a large image on my 1.2 Ghz Athlon. It seems to be performing a copy of the entire source image's data. Maybe there is a way to decode a jpg or png directly into an int array?
-Aaron Dwyer

Here's how you could do it for TYPE_4BYTE_ABGR
BufferedImage img=new BufferedImage(13,10,BufferedImage.TYPE_4BYTE_ABGR);
img.setRGB(0,0,0xff0000);     
img.setRGB(5,1,0x00ff00);        
img.setRGB(1,1,0xcafebabe);
DataBuffer db=img.getRaster().getDataBuffer();
int dataType=db.getDataType();
if (dataType!=DataBuffer.TYPE_BYTE)
     throw new IllegalStateException("I can do it only for TYPE_BYTE");
int imgType=img.getType();
if (imgType!=BufferedImage.TYPE_4BYTE_ABGR)
     throw new IllegalStateException("I can do it only for TYPE_4BYTE_ABGR");
DataBufferByte dbi=(DataBufferByte)db;
byte[] array=dbi.getData();
SampleModel model=img.getSampleModel();
if (!(model instanceof PixelInterleavedSampleModel))
     throw new IllegalStateException("I can do it only for PixelInterleavedSampleModel");
PixelInterleavedSampleModel pisModel=(PixelInterleavedSampleModel)model;
if (pisModel.getPixelStride()!=4)
     throw new IllegalStateException("I can do it only for pixel stride of 4");
if (dbi.getNumBanks()!=1)
     throw new IllegalStateException("I can do it only for 1 band");
int scanlineBytes=pisModel.getScanlineStride();
// Access the green Pixel on Position 5,1
System.out.println( (int)array[5*4 + scanlineBytes] &0xff);     // Alpha        
System.out.println( (int)array[5*4+1 + scanlineBytes] &0xff);     // Red        
System.out.println( (int)array[5*4+2 + scanlineBytes] &0xff);     // Green        
System.out.println( (int)array[5*4+3 + scanlineBytes] &0xff);     // Blue     I've added some checks to make sure we're accessing the data the right way.

Similar Messages

  • How to pass delivery date through BAPI while creating a sale order

    Dear frndz,
         I am using 'BAPI_SALESORDER_CREATEFROMDAT1'
    to create a sale order .
        I don't have any problem..
        But I have to pass schedule line delivery date through this bapi .
       I used REQ_DATE in structure BAPISCHDL.
       But I can' t get it.
       Through which parameter can i meet this..
       The sale order should be created line item wise along with my delivery date..
      Any suggestions...
    regards.
    siva

    Dear frnd,
        Danq for your response..I can't use DLV_DATE for this requirement..
        But I used REQ_DATE in the structure BAPISCHEDULE .
       I came to know that the problem i faced previously  was only
    internal data conversion.
        Now am able to pass my delivery date..
        so I am closing the thread..
    Regards.
    siva

  • Problem in passing Modified date through Go url

    Hi All
    I am trying to pass parameters through url to report.
    Its working fine and passing row id of the record but when i try to pass modified date also, it takes me to no result view where i can see that value has been passed to report but the results are not filtered, instead no result view.
    While passing date in url as parameter do we have extra consideration?
    Anybody has faced smilar kind of scenario.

    I am getting the following error when trying to pass modified date for oppty.
    Error getting drill information: SELECT Opportunity.Name saw_0, Opportunity."Opportunity ID" saw_1, Opportunity."Sales Type" saw_2, Opportunity.Priority saw_3, Opportunity."Last Modified" saw_4 FROM "Opportunity Lists" WHERE (Opportunity."Opportunity ID" = 'AAPA-6EEC9X') AND (Opportunity."Last Modified" = timestamp '0000-00-00 00:00:00')
    Error Details
    Error Codes: YQCO4T56:OPR4ONWY:U9IM8TAC:OI2DL65P
    Odbc driver returned an error (SQLExecDirectW).
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 46048] Datetime Month value 0 from 0000-00-01 is out of range. (HY000)
    SQL Issued: {call NQSGetLevelDrillability('SELECT Opportunity.Name saw_0, Opportunity."Opportunity ID" saw_1, Opportunity."Sales Type" saw_2, Opportunity.Priority saw_3, Opportunity."Last Modified" saw_4 FROM "Opportunity Lists" WHERE (Opportunity."Opportunity ID" = ''AAPA-6EEC9X'') AND (Opportunity."Last Modified" = timestamp ''0000-00-00 00:00:00'')')                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Reg: Passing Image url through CSS Class

    Hi,
    How can i pass the image through Css class ?
    Thanks in advance.

    Hi,
    I am not sure if that can be done in css file though.
    I suppose you are using the backing bean for setting the skin (just read your old thread). If yes, you can add two images to your page and set the visible property according to the current skin. Something like
    <af:image id="i1" source="../images/first_logo.gif" visible="#{seesionScope.currentSkin == 'First'}"/>
    <af:image id="i2" source="../images/second_logo.gif" visible="#{seesionScope.currentSkin == 'Second'}"/>
    If i select Second CSS file then the logo will be change according to the style class defined in First CSS file .AFAIK, the company logo would be static ;) .
    -Arun

  • How to pass multiple dates through open document syntax

    Hi Team,
    I am need to pass more than one date from the summary report to detail report. What is the open document syntax to achieve this requirement. Thanks in advance
    pra

    Hi Pra,
    I believe you would need to use the lsM[NAME] syntax.
    lsM[NAME] is used to specify multiple values for prompts, separated by a comma.
    For instance:
    http://<servername>:<port>/OpenDocument/opendoc/<platformSpecific>?iDocID=Aa6GrrM79cRAmaOSMGoadKI&sID
    Type=CUID&sRefresh=Y&lsMparamStringDR=[c],[d]&lsMparamNumberDR=[3],[4]&lsMparamDateDR=[Date(2003,6,3)],[Date(2003,6,4)]&lsMparamDateTimeDR=[DateTime(2003,6,1,3,1,1)],[DateTime(2003,6,1,4,1,1)]
    Crystal reports
    If the target is a Crystal report, each value must be enclosed in square brackets.
    Web Intelligence documents
    The character ? is a reserved prompt value for Web Intelligence documents in an openDocument URL. Setting the prompt value to lsM[NAME]=? in the URL forces the "Prompts" dialog box to appear for that particular prompt.
    I hope this is a very helpful answer to you.
    Kind regards,
    John

  • Passing of data through GUI

    Hi all ,
    I have a simple question here..... but being a newbie and extremely pressed for time , I hope some kind soul can help me with thiis ....
    I hava a main class. From the main class I involve a GUI to collect information from the user ....
    public void collectinformation ( )
    abc = new abcGUI();
    // rest of the codes
    if (abc.getStatus = true)
    else
    how do i make the application to wait for the GUI to get dispose before executing the rest of the codes ???
    (Instead of running the GUI and immediately proceed with the rest of the codes ???)
    Thank a lot in advance !!

    my situation is like this
    I have 2 classes: 1 main one, 2 subclass that helps to collect user data
    *************************** subclass *******************************************
    public class subclass implements ActionListener
    public AuthGUIG8()
    //Create and set up the window.
    mainFrame = new JFrame("Authentication");
    mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //converterFrame.setSize(new Dimension(120, 40));
    //Create and set up the panel.
    mainPanel = new JPanel(new GridLayout(3, 3));
    //Add the widgets.
    addControls();
    //Set the default button.
    mainFrame.getRootPane().setDefaultButton(okButton);
    //Add the panel to the window.
    mainFrame.getContentPane().add(mainPanel, BorderLayout.CENTER);
    //Display the window.
    mainFrame.pack();
         mainFrame.addWindowListener
    mainFrame.setVisible(true);
         iFailAttempt = 0;
         bNewbie = false;
    ************* main class *************************
    public class mainclass
    subclass abc = new subclass()
    // rest of the codes
    if abc.getStatus == true
    else
    unless I can implement window Listener for window closing event on the main class to listen to the GUI created in the subclass, otherwise the window listener will not work rite ??
    In this case I will still have the "rest of the codes" been run b4 the GUI in the subclass was disposed rite ??
    how can i get rid of this multithreading situation ???
    please advise. Thank you in advance ..

  • Pass form data through web service to session bean

    Hello,
    i want to create an insert in a database table using a web dynpros that call my method createEntry i a sessionbean. The sessionbean is ok, it worked with a jsp.
    My Problem:
    The inputfields of my form are blocked so that i cannot insert the values. This problem only occurs if i bind the inputfields to the attributes of my web service in the view context.
    What i already did:
    I defined a web service in my EJB Module Project.
    I imported this model into my web dynpro.
    I bound the elements of the web service into the custom controller.
    I bound the elements from the custom controller to my view context.
    I did not bind the result of the web service in any way because i do not need it.
    Did i miss something i had to do?
    Thanks for help or any advices, it is my first time using a web service and i already tried to get along with the CarRental and the Email example.
    André

    Hi,
    I think you problem is not a Web Service but the fact that Model Context Elements are not created automatically.
    >I bound the elements of the web service into the custom >controller.
    You made a binding but here you should <b>create</b> the elemnts itself wich means:
    1. Create the instance of the element for you cotext node.
    2. Call wdContext.node<You Context Name>.bind(<instance created in previous step>
    This step is the same as for RFC Model so if you fill that my explanation is not clear enought go to Adptive RFC Model tutorial (calling BAPI_FLIGHT_GET_LIST) and see the code in wdDoInit() method.
    Hope it helps.
    Victor

  • Use OpenFrameWorks/Quartz Composition image data?

    So I have been tinkering with the Skeleton sample project on a Mac and I have a couple of questions. First off, How can we pass image data from say Quartz Composition or a Openframeworks project(C++,Xcode) or any other to the render function of the plugin. For example from Openframeworks I can get a pixels as an array of unsigned chars. Can I supply it to the render function? If so, how? Also I have seen people using Quartz Compositions to make plugins for AE. Can some one help me figuring out how to pass the image data from the composition to the render function in a plugin? Please bare with me, as I am a newbie and I really hope some one could help me.
    Thank you!

    as for bit depths:
    there a 3 different iteration suites. one for each bit depth.
    i couldn't find them in the documentation but if you go to the definition of any of them in the code, you'll find the others.
    you must use the appropriate suite for the kind of buffer you're using or the function will fail.
    how do you tell which one to use?
    if you created the pixel world yourself, then you know it's kind.
    to find out which depth AE hands you, use PF_GetPixelFormat.
    take a look at the "smarty pants" sample project. it shows how to handle that.
    actually the shifter sample implements that as well, so forget what i just said. (yes you were right)
    as for your x y question, i'm not sure what you're asking.
    i managed to understand that question in 2 ways.
    so here are 2 answers.  :-)
    1. if you're asking how to tell the coordinates of the pixel you're currently being handed by the iteration suite,
    then the x and y coordinates are given to you by the iteration function.
    to be more precise, it gives you the following data:
    refcon - a pointer to whatever piece of memory you sent to the iteration function. (use it to transfer data into your iteration function)
    x - the x coordinate of the current pixel in the output world.
    y - that one's kind of obvious...
    in - the current pixel's content from the input world (if the in and out worlds are of the same size, then the x and y coordinates for both worlds are the same)
    out - the structure into which you put your result RGBA (you may fill that world with whatever you like before the iteration, thus getting two inputs to use for your calculation)
    2. if you're asking how to tell which pixels are being sampled using the sample suite (as used in the shifter sample),
    then these are shorts, bit shifted.
    these values are compatible with what you get reading data from a point param.
    these values are NOT comfortable to use for anything else.
    why? relics of what was most efficient CPU-wise 12 years ago.
    you can sample a pixel buffer in 3 ways:
    "nearest neighbor" for fast performance,
    "subpixel" for accurate results,
    and "area sample" for... when you need... an area. (duh)
    for more info, investigate the "PF_SampPB" structure.
    in any case,
    you don't have to get the input using the sample suite.
    you can always use the input pixel as it is, or get the pixel from the quartz thingie you want to use.
    i tend to think that the first answer was what you we're looking for , but what the heck.

  • How to pass table data to brf plus application through abap program

    Dear All,
    i have a question related to BRF Plus management through abap program.
    In brf plus application end, Field1,field2,field3 these 3 are importing parameters.
                                           Table1->structure1->field4,field5 this is the table,with in one structure is there and 2 fields.
    in my abap program, i am getting values of fields let us take field1,field2,field3,field4,field5.
    And my question is
    1) How to pass fields to BRF Plus application from abap program.
    2)How to pass Table data to BRF Plus application from abap program.
    3)How to pass Structure data to BRF Plus application from abap program.
    4)How to get the result data from BRF Plus application to my abap program.
    And finally , how to run FDT_TEMPLATE_FUNCTION_PROCESS.
    How do i get the code automatically when calling the function in brf plus application.
    Regards
    venkata.

    Hi Prabhu,
    Since it is a Custom Fm i cant see it in my system.
    Look if u want to bring data in internal table then there could be two ways::
    1) your FM should contain itab in CHANGING option , so that u can have internal table of same type and pass through FM,
    2) read values one by one and append to internal table.
    Thanks
    Rohit G

  • "secured by passing data through LWAPP tunnels."

    Hi,
    The WLC v4.1 Config Guide says,
    "all Layer 2 wired communications between
    controllers and lightweight access points are secured by passing data through LWAPP tunnels."
    Is it correct that this is only true for the LWAPP Control channel which is encrypted - the LWAPP Data channel is in clear text which WireShark has no problem parsing, right?
    Regards, MH

    Only LWAPP control message payloads are encrypted. As you've stated however LWAPP data payaloads are not encrypted as the wired network is assumed to be relatively secure (compared to wireless).
    Additional Reference Appendix B in this document:
    http://www.cisco.com/en/US/netsol/ns340/ns394/ns348/networking_solutions_white_paper0900aecd805e0862.shtml

  • How to retrieve data through table by passing date

    hi
    i hv made one table which stores email id & cureent date when entered,
    can anybody tell me how to retrieve data through table by passing today's date to last week date,so it can retrieve all email ids which are entersd in last week.
    thanks

    http://www.google.com/search?&q=sql+tutorial

  • Is it possible to Pass Binary Image Data to Logical DSP via ALDSP Control?

    I have run into an issue trying to pass binary image data (hexBinary in the WSDL) from WLI's ALDSP Control to a logical service in ALDSP 3.0. I was wondering if anyone has done this successfully, and if so, can you offer any advice?
    The following error is generated:
    Caused by: com.bea.dsp.das.exception.DASException: weblogic.xml.query.exceptions.XQueryTypeException: {err}XP0006: "element {commonj.sdo}datagraph { {commonj.sdo}DataGraphType }": bad value for type element {http://idexx.com/lims/domain/image}Image { {http://idexx.com/lims/domain/image}Image }*
    at com.bea.dsp.das.ejb.EJBClient.invokeOperation(EJBClient.java:160)
    The snippet of code that I am using in the WLI to communicate with the ALDSP control is:
    try {
    byte[] bytes2;
    bytes2 = reportText.getBytes("UTF-8");
    Image image =createNewImage();
    image.setImage(bytes2);
    image.setImageFormat("XML");
    image.setImageType("RESULTS REPORT");
    image.setOwningLabId( owningLabId);
    image.setExpirationType("EXPA");
    image.setAddedBy (BigInteger.ONE);
    image.setScanDate(XMLHelper.toXSDDateTimeFormat(new Date()));
    Image[] sdos = new Image[1];
    sdos[0]= image;
    logDebug(sdoHelper. dataObjectToXml(image));
    System.out.println(sdoHelper. dataObjectToXml(image));
    imageDSPControlFile.createImage(sdos);
    sdoHelper. dataObjectToXml(image);
    } catch (UnsupportedEncodingException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    throw new RuntimeException(e.getCause());
    Lastly, the WSDL schema is as follows:
    <?xml version="1.0" encoding="UTF-8"?>
    <schema xmlns="http://www.w3.org/2001/XMLSchema"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://idexx.com/lims/domain/image"
    xmlns:tns="http://idexx.com/lims/domain/image"
    elementFormDefault="qualified">
    <xs:element name="Image" type="tns:Image" />
    <xs:complexType name="Image">
    <xs:sequence>
    <xs:element name="imageId" type="xs:integer" minOccurs="0"/>
    <xs:element name="image" type="xs:hexBinary"/>
    <xs:element name="scanDate" type="xs:dateTime"/>
    <xs:element name="imageFormat" type="xs:string"/>
    <xs:element name="imageType" type="xs:string"/>
    <xs:element name="expirationType" type="xs:string"/>
    <xs:element name="owningLabId" type="xs:integer"/>
    <xs:element name="addedDate" type="xs:dateTime" minOccurs="0"/>
    <xs:element name="addedBy" type="xs:integer" minOccurs="0"/>
    </xs:sequence>
    </xs:complexType>
    </schema>

    WLI's ALDSP Control This is actually ALDSP's ALDSP Control - but you can call it from WLI. Check the Advanced Samples announcement in this forum for examples of using the ALDSP Control
    - mike

  • Korean characters, not handled through JNI

    Hello:
    I have a C library that is wrapped through JNI. The data is in Korean, and is returning fine in the C code, but then when I access the data through Java (JString), it is all messed up. Any ideas what is the problem?
    Thanks,
    [email protected]

    Adding on, here is the snippet code, where a command is passed in. The C code executes the command, and returns the result. The UTF and jstring string manipulations are shown below. What is wrong with the assumption if the data itself is of Korean language (double-byte enabled)? Any response would be greatly appreciated. Please respond to this message board, or email at [email protected]
    Thanks,
    Bilal
    JNIEXPORT jshort JNICALL
    Java_execCliCommand(
    JNIEnv *env, jobject obj, jstring cliCmd, jobject cliOutObj)
    jshort jresult;
    P_HANDLE cliOut = (P_HANDLE)NULL;
    char cliOutBuf = (char )NULL;
    jclass jcliOutClass;
    jfieldID joutbufID;
    jstring jcliOutStr;
    * Get the cli command & connectstring and execute the cli.
    const char cliCmdStr = (env)->GetStringUTFChars(env, cliCmd, 0);
    printf("CLI COMMAND : %s\n", (char *)cliCmdStr);
    jresult = cliRunServerCommand((char *)cliCmdStr, &cliOut);
    jcliOutClass = (*env)->GetObjectClass(env, cliOutObj);
    joutbufID = (*env)->GetFieldID(env, jcliOutClass, "outbuf", "Ljava/lang/String;");
    if ( cliOutBuf != NULL ) {
    printf("CLI RESULTS: %s\n", cliOutBuf);
    jcliOutStr = (*env)->NewString(env, (jchar *)cliOutBuf, (jsize)(p_strlen(cliOutBuf)+1));
    printf("UNICODE CLI RESULTS: %s\n", (char *)(*env)->GetStringChars(env, jcliOutStr,0));
    } else {
    jcliOutStr = (*env)->NewStringUTF(env, "Command executed successfully");
    (*env)->SetObjectField(env, cliOutObj, joutbufID, jcliOutStr);
    (*env)->ReleaseStringUTFChars(env, cliCmd, cliCmdStr);
    (*env)->ReleaseStringUTFChars(env, connectString, connectStr);
    return jresult;
    }

  • Is JMF use hardware accelerated through JNI possible?

    Dear all:
    I try to use JMF decode MPEG-2 data, through VeXP which wrote in C.
    So I think we can call C library through JNI pass encoded MPEG-2 data to VeXP, use hardware decode encoded MPEG-2 data to YUV-format raw data then return it to JAVA.
    but JNI seem can't pass media raw data by call by reference...
    It should cause a lot of memory copy.
    How about it's feasibility?
    Have anyone give me some suggestion?
    Regards,
    white

    There's a few ways to do it, but I'd use a style sheet. So:
    1. Add this to the "creationComplete" Stage event:   sym.$("<link rel='stylesheet' type='text/css' href='styles.css'>").appendTo("#Stage");
    2. Create a style sheet (text file) in your project folder named "styles.css", and define a class:
    .force-webkit-acceleration {
         -webkit-transform: translate3d(0,0,0);
    3. Give your animated element the class "force-webkit-acceleration" in the properties panel (the little c-in-a-box icon next to the title field).
    Be sure that the style sheet file ends up in your "publish/web" folder too.

  • Trying to Load a BufferedImage from a PNG through JNI

    Yes I realize that I can load it directly through Java and not go through JNI, but I need this to test correctly as my C code will aquire images without saving to Disk and I want Java code to manipulate the images without saving to disk. The image Im trying to load is a 800x600 PNG image.
    So I have the code
    import java.io.ByteArrayInputStream;
    import java.io.File;
    import java.io.IOException;
    import java.io.InputStream;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    import com.sun.media.jai.widget.DisplayJAI;
    class ImageLoader{
         static{
              System.loadLibrary("LoadImage");
         private static native byte[] loadImage();
         public static void main(String[] args){
    byte[] f = loadImage();
              InputStream s= new ByteArrayInputStream(f);
              BufferedImage bi;
              try {
                   bi = ImageIO.read(s);
                   displayBufferedImage(bi, "test");
              } catch (IOException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
          * Utility method for display a BufferedImage.<br>
          * @param  image input image
          * @param  title window title string
         public static void displayBufferedImage(BufferedImage image, String title)
              JFrame frame = new JFrame();
             frame.setTitle(title);
             //frame.getContentPane().add(new DisplayTwoSynchronizedImages(sourceImgBI, resultImgGray));
             frame.getContentPane().add(new JScrollPane(new DisplayJAI(image)));
             //frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
             //frame.pack();
             frame.setSize(300,300);
             frame.setLocationRelativeTo( null );
             frame.setVisible(true); // show the frame.
         }and I have the JNI c code as
    char* result;
    JNIEXPORT jbyteArray JNICALL Java_ImageLoader_loadImage
      (JNIEnv * env, jclass jclassj){
                   int fd = open("test.png",  O_RDWR, S_IRUSR|S_IWUSR );
                   int size = (800*600*4);
                   result = (char*)malloc(size);
                   read(fd, result, size);
                   jbyteArray return_result;
                   return_result = env->NewByteArray(800*600);
                   env->SetByteArrayRegion(return_result, 0, 800*600, (jbyte*)result);
                   //free(result);
                   return return_result;
         }but when I try to run the code I get the following error
    javax.imageio.IIOException: Error reading PNG image data
         at com.sun.imageio.plugins.png.PNGImageReader.readImage(PNGImageReader.java:1287)
         at com.sun.imageio.plugins.png.PNGImageReader.read(PNGImageReader.java:1552)
         at javax.imageio.ImageIO.read(ImageIO.java:1438)
         at javax.imageio.ImageIO.read(ImageIO.java:1342)
         at ImageLoader.main(ImageLoader.java:31)
    Caused by: java.io.EOFException: Unexpected end of ZLIB input stream
         at java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:240)
         at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
         at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
         at java.io.BufferedInputStream.read1(BufferedInputStream.java:275)
         at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
         at java.io.DataInputStream.readFully(DataInputStream.java:195)
         at com.sun.imageio.plugins.png.PNGImageReader.decodePass(PNGImageReader.java:1084)
         at com.sun.imageio.plugins.png.PNGImageReader.decodeImage(PNGImageReader.java:1188)
         at com.sun.imageio.plugins.png.PNGImageReader.readImage(PNGImageReader.java:1280)
         ... 4 moreI think that Im on the right track because Java is recognizing that this is a PNG image, but Im not sure whats wrong. I don't know much about the formats, so I know nothing about PNG's, maybe someone else can help me here.
    Note: I ran the code
                   BufferedImage bi2 = ImageIO.read(new File("test.png"));
                   displayBufferedImage(bi2, "test2");and the image loads fine, so there is no issue with the image itself.

                   int fd = open("test.png", O_RDWR, S_IRUSR|S_IWUSR );Why are you opening the image file read/write? Why not read-only?
                   int size = (800*600*4);Here you're assuming the image is 800*600. Are you sure that's the case? Also you should write sizeof int here instead of 4.
                   result = (char*)malloc(size);Here you aren't checking for the possibility that result is null.
                   read(fd, result, size);Here you are ignoring the result returned by read(), so you are ignoring the possibilty that it was 0 or less than 'size'. Either are possible.
                   jbyteArray return_result;
                   return_result = env->NewByteArray(800*600);Here again you aren't testing for return_result == null.
                   env->SetByteArrayRegion(return_result, 0, 800*600, (jbyte*)result);Here you should be checking for Java exceptions. Also you shouldn't be repeating the 800*600 here, make it a constant or a variable somewhere.
                   //free(result);You need that free, otherwise you have a memory leak. If the image really is a constant 800*600 in size I would allocate 'result' on the stack so you don't need to housekeep it.
    Also you are never closing the input file!
    Caused by: java.io.EOFException: Unexpected end of ZLIB input streamSo clearly you didn't read all the image. That could be due to guessing wrong about 800*600 or getting a short read when reading the file.
    I think that Im on the right track because Java is recognizing that this is a PNG imageI agree. It starts like a PNG image, so you read something, but it doesn't end like one, so you didn't read it all.> and the image loads fine, so there is no issue with the image itself.
    Good test. Note that your Java code makes no assumption about the size of the image.

Maybe you are looking for

  • Adobe Bridge CS6 Raw files not previewing.

    I recently upgraded my iMac from a 2007 to a mid 2011 Mac ...the first running fine with CS5...the newer iMac with CS6 and 32GB ram.  I can't seem to get Bridge in CS6 on the new machine to preview D800 Raw Nef files.  Is there something that I need

  • IMac goes to sleep unexpectedly, Finder issues with flash drives - related?

    My iMac falls asleep for no known reason, often in the middle of active use. (Similar problem recently described in thread with messageID=11829917.) Sleep onset is frequent but seems to vary based on both currently-running software and attached devic

  • Need SQL to update Column based on latest value

    EFF_DTE     EXCH_FROM_CTRY_CD     EXCH_TO_CTRY_CD     SECTY_LST_PRCE     SECTY_MTH_AVG_PRCE      New Col In View 1/1/2013     USD     MXN     12.988     12.988     12.88672 1/2/2013     USD     MXN     12.988     12.988     12.88672 1/3/2013     USD 

  • When the system goes into sleep mode it keeps making a beeping noise. The system is shut down by holding the button in

    When the system goes into sleep mode it keeps making a beeping noise. The system is shut down by holding the button in and will then boot up again without any errors. I Have replace RAMS, Motherboard and Power Supply. I have check the Bio's  and Powe

  • Looking for still image content

    I'm currently in the process of making a spec or pre-vis for a music video. It's highly conceptual, so getting the right visuals to match the lyric content is very important. I'm off to a decent start finding things through google images, but if anyo