Forming an image from a ByteBuffer

I would be grateful if anybody could help me with a problem i am having with my program, i am trying to read pixels to form an image, i have the whole thing working now, however it is grayscale, and i cant work out why. Any help would be appreciated.
     GL11.glReadBuffer(GL11.GL_FRONT);
            ByteBuffer pixels = ByteBuffer.allocateDirect(400*400*3);
            GL11.glReadPixels(0, 0, 400, 400, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, pixels);
            ColorModel glColorModel = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
                                            new int[] {8,8,8,0},
                                            false,
                                            false,
                                            ComponentColorModel.OPAQUE,
                                            DataBuffer.TYPE_BYTE);
            int[] band = new int[3];
            // make array from byteBuffer to make a DataBufferByte from array...
            byte [] byteA=new byte[400*400*3];
            pixels.get(byteA);
            DataBuffer db = new DataBufferByte(byteA, 400*400*3, 0);
            WritableRaster raster = Raster.createInterleavedRaster(db, 400, 400, 400*3, 3, band, null);
            // make my image
            BufferedImage image = new BufferedImage(glColorModel, raster, false, null);//new java.util.Hashtable());thanks

Ok, investigation further:
            for (int i = 0; i < 1600 ; i ++){
                System.out.println(byteA);
}produces non grayscale numbers, such as 76 51 25 76 51 25 76 51 25 , ie the background. This means the problem is in the raster part, maybe the glColorModel? the thing is i just coppied the glColorModel straight from my texture loading thing, and they are in colour....                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • Interactive Form with images from KM ??

    hello: I need to read an image from km to incorporate it in Interactive Form, but for some reason when being generated the Form does not show it. The subject to dynamically obtain the images from km.
    Thank you very much.

    Hello,
    Please review this link to import a KM image:
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/kmc/getting%2ban%2bimage%2bfrom%2bkm%2bdocument%2bto%2bbe%2bused%2bin%2bweb%2bdynpro
    Now you must put the image to an attribute of context of type string. For it you do the following thing:
    //Reading the image file......
         BufferedInputStream bufIn = new BufferedInputStream(resourceimg.getContent().getInputStream());
         byte[] imagebyte = new byte[bufIn.available()];
         bufIn.read(imagebyte);
    //Convertir a String
         String imgString=new BASE64Encoder().encode(imagebyte);
         wdContext.currentContextElement().setImgString(imgString);
    Finally, in the Form you must add a Image Field, with the following properties:
    -Tab field
    URL: empty
    Embebed Image Data
    - Tab Binding
    Default Binding: $record.ImgString
    That is.
    Regards

  • Rich text box used in Infopath Form not displaying option to get images from Computer

    Hello,
    We have used "Rich text box" in Infopath Form which is not displaying option to get images from Computer.
    Options available are : From Address, From SharePoint
    But if we Rich text box in list, then it works fine with "From Computer" option.
    can you please help me out to get this option.
    Thanks in advance.
    REgards,
    Jayashri

    Hi,
    From your description, there is no “From Computer” option to get images with rich text box in InfoPath form.
    Per my knowledge, by design there are “From Address” and “From SharePoint” options without “From Computer” option in rich text box in InfoPath form. As a workaround, you can develop a custom InfoPath Rich Text box to do it.
    About developing a custom InfoPath control, I suggest you create a new thread on the forum “Visual Studio Tools for Office”, more experts will assist you with InfoPath development.
    Visual Studio Tools for Office:
    https://social.msdn.microsoft.com/Forums/office/en-US/home?forum=vsto&filter=alltypes&sort=lastpostdesc
    Thanks,
    Dean Wang

  • Save an image from interactive form to R/3 system table

    Hi to all,
    my scenario is this: Web AS 7.0 (probably patched to the last available patch), NWDS 7.0 and, at the moment, a 4.6c R/3 backend system (within some months we will upgrade to ECC 6.0). I have an online interactive form with some input fields and a user, logged in, fills these fields and pressing the "Submit to SAP" button will save the datas to a custom table on 4.6c backend. All this is simple and is working, but my problem is that one of these fields is an image. The purpose is that the user click on the image field and load an image from local PC and then, pressing submit to SAP button, will save the image on the custom table.
    How can I make this? Which kind of context I have to bind to the image field? I have to add a java script/form calc code to image field? And to backend side, how can I do?
    Thank you very much in advance,
    Enrico

    Hi,
    In your forms you got the image or a link to the image ? If it's the image the field is define as an XSTRING is supposed. If yes you can add it easily in a database table.
    If it's a link, your SAP system ( 4.6 C ) need to the the repository where the image is and then you can add it in the database.If you SAP system doesn't see the repository it's impossible to do so.
    Hope this help you.
    Best regards

  • Urgent ! Code for Displaying Image from Oracle BLOB image on VB Form

    Hi Plz any one have any work to showing a Picuture on Visual Basic Form, i Save the Picure in table and its column type is BLOB where i save picture, now i want to show it on VB form. if anybody knows plz tell me. and if image not found then how can i handle in nvl(field,' ') function.

    Refer VB sample on Passing LOB parameters to a stored procedure. It shows how to display and insert the image from VB form to an Oracle Database in a BLOB column.
    http://otn.oracle.com/sample_code/tech/windows/ole_db/oledb8/content.html
    Chandar

  • Want to scan an image from oracle forms -- Is it possible??

    Hi all,
    I want to scan an image from oracle forms through a scanner. I have not found any help on this topic. Pls help with example or code or with demmo form.
    BR
    Tarik.
    Edited by: Tarik_kuet on Sep 9, 2008 1:39 PM
    Edited by: Tarik_kuet on Sep 9, 2008 1:39 PM

    A colleague of me did it like this:
    * the scanner is connected to a network document server.
    * the document server sends(ftp) the image to the oracle XDB
    * a form shows the scanned documents(using a view on the ftp directory in XDB using path_view)
    * in this form the user can move the scanned document(s) to a (blob field) in a table.
    Hope this helps a bit...
    Edited by: poelger on Sep 9, 2008 10:08 AM

  • How to export database image from form 9i to excel??

    I hv some image sotred as blob in database and want to export them from form to excel
    here is my code:
    DECLARE
    MyApplication OLE2.OBJ_TYPE;
    workbooks OLE2.OBJ_TYPE;
    workbook OLE2.OBJ_TYPE;
    worksheets OLE2.OBJ_TYPE;
    worksheet OLE2.OBJ_TYPE;
    cell OLE2.OBJ_TYPE;
    args OLE2.LIST_TYPE;
    args1 OLE2.LIST_TYPE;
    args2 OLE2.LIST_TYPE;
    pictures OLE2.OBJ_TYPE;
    picture OLE2.OBJ_TYPE;
    BEGIN
    --INITIAL CODE ESTABLISHING THE Excel Object and Workbook/Worksheet
    MyApplication := OLE2.CREATE_OBJ('Excel.Application');
    OLE2.SET_PROPERTY(MyApplication , 'Visible',1);
    workbooks := OLE2.GET_OBJ_PROPERTY(MyApplication ,'Workbooks');
    workbook := OLE2.INVOKE_OBJ(workbooks,'Add');
    ---- START Code to create a work sheet and name it as WorkInstruction ---
    worksheets:=OLE2.GET_OBJ_PROPERTY(workbook, 'Worksheets');
    worksheet:=OLE2.INVOKE_OBJ(worksheets,'Add');
    OLE2.SET_PROPERTY(worksheet , 'Name','WorkInstruction');
    OLE2.SET_PROPERTY(MyApplication , 'ActiveSheet','WorkInstruction');
    ---- END Code to create a work sheet and name it as WorkInstruction ---
    worksheets := OLE2.GET_OBJ_PROPERTY(MyApplication ,'ActiveSheet');
    OLE2.SET_PROPERTY(worksheets , 'Value','WorkInstruction');
    args := OLE2.CREATE_ARGLIST;
    --- For Writing Image ---
    pictures:=OLE2.INVOKE_OBJ(worksheet,'Pictures');
    args2:=OLE2.CREATE_ARGLIST;
    OLE2.ADD_ARG(args2, 'images.img');<---- it works only on local path/ url???
    picture:=ole2.get_obj_property(pictures,'Insert', args2);
    OLE2.DESTROY_ARGLIST(args2);
    args1 := OLE2.CREATE_ARGLIST;
    OLE2.ADD_ARG(args1, 'C:\Documents and Settings\YinHan.Chan\Desktop\EXAMPLE.xls');
    OLE2.DESTROY_ARGLIST(args1);
    ole2.release_obj(picture);
    ole2.release_obj(pictures);
    ole2.release_obj(workbook);
    ole2.release_obj(workbooks);
    ole2.release_obj(worksheets);
    ole2.release_obj(worksheets);
    OLE2.RELEASE_OBJ(MyApplication);
    END;
    Please help
    thanks
    Message was edited by:
    user570542

    I am not seeing where you actually get the image from the db to Excel ...... all what you are doing is passing a file name, but did you already download the file to client machine? if so, consider giving full path instead of file name only !

  • Display image from external resource into interactive form

    Hi experts!
    How can I display an image from a external url, for example "http://www.adobe.com/imageshome/pdfgift_home.gif" ??
    I tried to do that:
    1. Insert a "Image field"
    2. Bind None
    3. Embed image data: unselected
    4. URL: $record.url
        In "url" it's a context's variable. It's type is string. I save in url: http://www.adobe.com/imageshome/pdfgift_home.gif
    4. Show: initialize
        Script: this.value.image.href = xfa.resolveNode(this.value.image.href).value;
        Language: JavaScript
        Run at: Client
    I can't save image into mimes' folder. It's a bussiness rule in my company.
    Thanks
    Gustavo Rodriguez

    have you tried directly linking it to the image this way? instead of passing through the context to make sure you can access the image?
    I just inserted an image on my form.
    Bind none
    Embed unchecked
    URL http://www.adobe.com/imageshome/pdfgift_home.gif
    Edited by: robert phelan on Jun 25, 2009 8:07 PM

  • Retrieving image from database in form 6i

    hello all
    i'm working on form 6i...
    i have uploded images into the database of customers in my application using READ_IMAGE_FILE.. IT IS FINE...
    But when i am trying retrieves records into the form.... i'm getting all the data except image... Image field is showing empty..
    How can i get image from database to form
    can u plz help me.....
    thanks

    What data type you used for storing image in database. If it is long raw, then you can place an image item within your data block on form and associate it with the column name. This should populate the image by itself.
    Below para is from Forms Help.
    Image items can be populated in the following ways:
    +1. a fetch from a LONG RAW database column+
    An image item in a data block is populated automatically when the end user or the application executes a query in the block.  When a fetched image is modified or replaced, Form Builder marks that record as Changed, and the next commit operation saves the new image to the corresponding LONG RAW column in the database.
    Note:  You cannot write a SELECT statement to select a LONG RAW value INTO an image item.
    +2. executing the READ_IMAGE_FILE built-in to read an image from the file system+
    +(To dynamically write an image from an image item out to a file, use the built-in procedure WRITE_IMAGE_FILE.)+

  • How to Display a image from WebCam in the Forms 10.1.2.0.2!

    Hi Friends!
    I'm using a Forms 10.1.2.0.2 and i need to display of someway a image from webcam in some item inside the Forms!
    This is possible?
    I saw an explanation in http://www.orafaq.com/forum/t/89431/67467/ but it works only for a Forms 6.0!
    Somebody can Help me?

    As Jan mentioned, there is no way to display webcam video in Forms unless you create a Java Bean which can be incorporated into your form. As Pauli mentioned, if your webcam software is viewable via a browser, you can use WEB.SHOW_DOCUMENT to display a browser window with the content, however you will not be able to put this content in the form using the method.
    A good starting place would be Google. Look for a java bean or applet which can operate a web cam.
    http://www.google.com/search?q=java+applet+web+cam

  • Need several forms to show the same image from an image library

    Hi
    I have several InfoPath forms with a logo at the top of the form. I would like to have the logo linked to an image file so if I have to change the logo, I can just overwrite the file that's sitting in a SharePoint image library without having to edit and
    re-publish 30 forms.
    I can get the file placed in the InfoPath form, but when I publish the form, the image looks correct but the publish process embeds the image. If I view the properties of the image on the form in SharePoint, the URL isn't the URL to the image in the image
    library. It's a long URL that looks hashed.
    So I went back to InfoPath and tried Insert > Picture > pasted the URL to the image in the image library > then clicked the down-arrow on the Insert button and chose Link to File. Now when I publish it, I get an error that says:
    Linked images are not supported by InfoPath Forms Services. To fix this problem, make the image a part of the form template. (Then it has a link to the image from the image library.)
    Is it possible to link to an image file so if the image file is updated the forms will see the new image?
    Thanks in advance,
    Sonya

    Thanks for the reply. So if I understand the info on the links above, to simply display an image that's not embedded in my InfoPath form, I have to create a Rich Text Box in the form, add a Receive data connection to a Picture Library on SharePoint, add
    a Loading Event to the InfoPath form template and edit/paste C# code (because I only want to display one image from the image library and not a repeating table like the example in the article above), then edit and add more blocks of C# code to an "addImageToTable"
    function, save/build/publish the form, then perform an "administrator-approved form template deployment" on the server? lol, all of that seems excessive just to display a non-embedded image. I'll need to decide if I want to fool with that since the logos don't
    change very often.

  • Retreving Image from Blob in forms 6

    I am using forms 6 and oracle 9i.i have an image item and on when_button_press trigger i insert an image into the image_item by calling the read_image_file function and then save that image into the database.it gives me a message that 1 transactoion applied and saved. now i want to to retrived that image from database into form.how should i do it.also how will i know whether my image has been saved or not.when i tried to execute query i got message query caused no records to be retreived.
    my table name is test_images and i have one column image(blob)

    your test_image table better to have another primary key item like file_id number with table trigger to sequence generating its value for IF INSERTING event, or it will have no handle to get the image back.

  • Extracting image from retuned form

    Hi have a form which asks the end user to place 3 images into it.
    Is there a way in which i can then download those images from the form at my end?

    Thanks Patrick.
    We are thinking about using a third party native Java library to do this (http://www.qoppa.com/pdffields/jpfindex.html). I was hoping we could use acrobat reader, since everyone has it!
    Here are a few more things.
    1. We are an Software Vendor that sells our solutions - our software solutions need to extract the xml from pdf. We have a java based program that parses this xml and does stuff with it.
    2. Obviously, we would need to be able to redistribute whatever solution we use to extract the xml from pdf.
    3. Can Acrobat Professional batch mode be executed from Java?
    4.. If so, Instead of distributing a full blown Acrobat Professional or requiring customers to buy it,  is there a library that Adobe provides that we could repackage and ewdistribute? If so, can you send me some pointers on where I could find what those libraries would be and how much would they cost for each distribution we do.
    5. If no, are you familiar with qoppa or do you have recommendations on any other third party libary for Java?
    Thanks a bunch!

  • Unable to download image from DB in forms 10g using webutility

    Hi All,
    I want to download blob image from db to client I am using below code in a button when i press button i get this error: ORA-04067
    Any one please help.
    declare
         vboolean boolean;
         vfilename varchar2(120) := 'J:\img'||:employees.employee_id||to_char(sysdate,'DDMMRRRR_HH24MISS')||'.jpg';
    begin
    vboolean :=
    webutil_file_transfer.DB_To_Client_With_Progress
    ( vfilename,
    'employees',
    'picture',
    'employee_id = '||:employees.employee_id,
    'Downloading from Database',
    'Wait to Complete');
    client_host('cmd /c start '||vfilename);
    end;

    Hello Francois,
    Thanks for response!
    I compiled the webutil_db package in database and it is in the forms user schema, i got the same error message as i get in the forms
    actual error message is both in db compilation and in the forms execution
    ora-04067 not executed, package body "<user>.webutil_db" does not exist.

  • Forms 11gR2 - paste from clipboard into image item

    Hi, how can I paste image from clipboard straight into an Image item on Form?
    If it can't be done via standard Forms functionality, is there any workaround - I mean can Java Bean do it, or maybe drag and drop via Beans Area?
    I know it's quite odd functionality, but any hint is much appreciated.
    Thanks in advance. Jack

    Hello,
    <p>I think that it is not possible. The only ways to populate an Image Item is to use the Read_Image_File() or to query from the database.
    You can use a Java Bean that allows to drag and drop an image file.</p>
    Francois

Maybe you are looking for