Howto dispay image from binary type

Hi, I have sucesfully displayed picture from context of type "Resource" to an Image child with binded to it context of type String. I use to it belov listed piece of code and it works fine:
FileResource = value attribute if type com.sap....Resource
Image = value attribut of type String binded to Image child
if (element.getFileResource() != null) {
element.setImage(element.getFileResource().getUrl(WDFileDownloadBehaviour.OPEN_INPLACE.ordinal()));
Now I have encountered closely related problem (there is a smile with coding an upload as well but I was able to upload "something" != null.). I have a picture in Binary type (uploaded from mysql db). How do I display it in an Image child with String type context (you can bind other types of context to Image child than String)? Below code how I upload the image:
ResultSet rs = stUpdate2.executeQuery("SELECT * FROM photo");
     while(rs.next())
          byte[] b=rs.getBytes(1);
IWDResource res=WDResourceFactory.createCachedResource(b,"Image4",WDWebResourceType.JPG_IMAGE);                    IPrivateMyProjectView.IImageTableElement imageEle=wdContext.createImageTableElement();
     imageEle.setImage3(b); //this is probably wrong, I tried bot "setImage3(res)" but I get error
//The method setImage3(byte[]) in the type IPrivateKartaPolakaView.IImageTableElement is not applicable for //the arguments (IWDResource)
//or
//imageEle.setImage3( res.getUrl(WDFileDownloadBehaviour.OPEN_INPLACE.ordinal()));
//               wdContext.nodeImageTable() .addElement(imageEle );
//how it should be but that provides me "The method setImage3(byte[]) in the type //IPrivateMyProjectView.IImageTableElement is not applicable for the arguments (String)" error
wdContext.nodeImageTable().addElement(imageEle );
ImageTable = Value Node
Image3 = value attribute of type binary
Please advice. Regards, Balmer.

Hi,
First of all, make a string context attribute, and bind ur image UI element's source name to it.
Then write the following code:
IWDResource l_resource = WDResourceFactory.createCachedResource(<variable of type byte[] whihch has the binary type>,"MyImage",WDWebResourceType.JPG_IMAGE);
String l_image = l_resource.getUrl(WDFileDownloadBehaviour.OPEN_INPLACE.ordinal());
now set this l_image to the source context attribute.
check it out and let me know if it works.....
Regards,
Gita

Similar Messages

  • Displaying image from binary data using java

    hi there,
    i have created a swing applet displays me a url, what the url returns me is the image in binary format, and i want to show the complete image using that binary data
    so how do i do it.
    some thing like this :
    URL url = new URL("http://192.168.1.1:8086/file-storage/download/Zerg.jpg?version_id=35688");
    JEditorPane jep = new JEditorPane();
    jep.setPage(url);
    output is in binary on my applet window.

    Hey,
    This displays an image from a url, you could check if your url is and image or not using URL.getFileName() and see if it ends in gif jpeg etc. and then display it this way.
    hope it helps
    Nick Hanlon
    import java.awt.*;
    import java.awt.Image.*;
    import java.awt.Toolkit.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.net.*;
    import java.io.*;
    import javax.swing.text.html.*;
    public class SimpleApp extends JFrame {
    public static void main(String args[]) {
    SimpleApp aFrame = new SimpleApp();
    public SimpleApp() {
    super("Frame");
    /*JEditorPane jep = new JEditorPane();
    jep.*/
    try {
    HTMLEditorKit htmlKit = new HTMLEditorKit();
    JEditorPane ep = new JEditorPane();
    try {
    ep.setEditorKit(htmlKit);
    BufferedReader in = new BufferedReader(
    new StringReader(
    "<HTML><IMG SRC=\"http://developer.java.sun.com/images/chiclet.row.gif\"></HTML>"));
    htmlKit.read(in, ep.getDocument(),0);
    getContentPane().setLayout(new BorderLayout());
    setResizable(false);
    getContentPane().add(ep, "North");
    pack();
    show();
    } catch (javax.swing.text.BadLocationException e) {}
    } catch (IOException e) {}
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) { System.exit(0); }
    }

  • Displaying image from binary file

    I am converting a image file(jpg) into a binary file and sending it. In the receiving side i got back the binary file and want to display the image in the applet or store the image in a file. while trying to do this i am not able to read the image from the buffer. Below here i have given my code.
    File f= new File("image.jpg");
           FileInputStream fis = new FileInputStream(f);
           byte [] buffer = new byte[(int)f.length()];
           fis.read(buffer,0,buffer.length);
           fis.close();
          File f1 = new File("input.txt");
          int length = buffer.length;
          PrintWriter pw;
           pw = new PrintWriter(new BufferedWriter(new FileWriter(f1)));
          for(int i=0;i<length;i++)
              pw.println(Integer.toBinaryString(buffer));
    pw.flush();
    pw.close();
    converting back to image i get error
    File f1 = new File("inp.txt");
    FileInputStream fis = new FileInputStream(f1);
    buffer = new byte[(int)f1.length()];
    fis.read(buffer,0,buffer.length);
    Toolkit tk = Toolkit.getDefaultToolkit();
    img = tk.createImage(buffer);
    Reply me as early as possible.thanks.

    You have two glaring problems here.
    Firstly, you are writing via writers, which are intended for text and are probably corrupting your data. You want to be using a FileOutputStream.
    Secondly, when reading in you are not checking the number of bytes read and may well not be fully populating your array. You want to change your reading code to something like this,
        buffer = new byte[(int)f1.length()];
        int read = 0;
        while (f1.available() > 0)
            read += fis.read(buffer, read, buffer.length - read);
        }

  • Displaying image from binary code

    I am converting a image file(jpg) into a binary file and sending it. In the receiving side i get the binary file and want to display the image in the applet or store the image in a file. while trying to do this i am not able to read the image from the buffer. Below here i have given my code.
          File f= new File("image.jpg");
           FileInputStream fis = new FileInputStream(f);
           byte [] buffer = new byte[(int)f.length()];
           fis.read(buffer,0,buffer.length);
           fis.close();
          File f1 = new File("input.txt");
          int length = buffer.length;
          PrintWriter pw;
           pw = new PrintWriter(new BufferedWriter(new FileWriter(f1)));
          for(int i=0;i<length;i++)
              pw.println(Integer.toBinaryString(buffer));
    pw.flush();
    pw.close();
    converting back to image i get error
    File f1 = new File("inp.txt");
    FileInputStream fis = new FileInputStream(f1);
    buffer = new byte[(int)f1.length()];
    fis.read(buffer,0,buffer.length);
    Toolkit tk = Toolkit.getDefaultToolkit();
    img = tk.createImage(buffer);
    Reply me as early as possible.thanks.

    You have two glaring problems here.
    Firstly, you are writing via writers, which are intended for text and are probably corrupting your data. You want to be using a FileOutputStream.
    Secondly, when reading in you are not checking the number of bytes read and may well not be fully populating your array. You want to change your reading code to something like this,
        buffer = new byte[(int)f1.length()];
        int read = 0;
        while (f1.available() > 0)
            read += fis.read(buffer, read, buffer.length - read);
        }

  • How to render image from binary property of node?

    Hello!
    How to put the image to the page from binary property of node in cms? How tags can i use?

    Hi,
    I have an additional question, regarding the images of a page. As stated above, rendering them works fine. But now I would also like to have them resized within certain boundaries. Is there a way to define the min/max width/height in the design of the page component for these images?
    I tried adding a node (name='image', jcr:primaryType=nt:unstructured) to /etc/designs/<myproject>/jcr:content/<mypagecomponent>. I then added minHeight, minWidth, maxHeight, ... properties to that node, but it seems they are not being picked up by the img.png.java servlet from the libs/foundation/page component.
    I created this design node based on a similar node which was added in the design of <mypagecomponent> for an 'image' in a 'par' when I changed the design of it.
    So I'm wondering if it is at all possible to define a design for the image of a page and if it, how I should do it.
    Kind regards,
    Luc

  • Display image from binary code in web service(Sharepoint portal)

    Hi All,
    We have converted a BAPI into web service.We are able to access it and fetch the data in sharepoint portal. The content which gets published in the sharepoint needs one image also to get displayed.The problem is we have the binary format but we are not able to decode that and display that as image in sharepoint portal.
    We are using VS2003 to make the portal component and then deploy it in sharepoint portal.We are stuck how to decode the binary format and display the image.
    Any Help will be appreicated.
    Regards
    Sachin

    Hi All,
    We have converted a BAPI into web service.We are able to access it and fetch the data in sharepoint portal. The content which gets published in the sharepoint needs one image also to get displayed.The problem is we have the binary format but we are not able to decode that and display that as image in sharepoint portal.
    We are using VS2003 to make the portal component and then deploy it in sharepoint portal.We are stuck how to decode the binary format and display the image.
    Any Help will be appreicated.
    Regards
    Sachin

  • Indd will not update placed images that have type design changes from Ai

    I am creating a book in Indesign ca4 and have placed hundreds of images from Illustrator cs4. These images have unconverted type in them. When i update the font (in FontExplorer X) the files  updates fine in Ai. However, when I go to the Indd file nothing changes. If i click on one of the images and relink then the updated font pops in. Now normally when I change anything else in an Ai file it automatically changes in the Indd file or at least shows that the file needs to be "updated".
    The problem is that I don't want to spend hours clicking each graphic, going to relink find the file, etc. Also, the font change is mearly the same font with a different revision number and it is difficult to even see if the font has actually updated, I would be blind by the time I finished the process of updating each graphic and verifying that it actulally updated.
    I do not want to convert the type to outlines, as this would cause even more time issues.
    I don't understand how the this can happen without a red flag happening somewhere along the process, as the previous font that shows up in Indd no longer exists and the file is not embeded, or converted?

    Peter, thanks for working on this for me I appreciate your heIp. I think what is happening is that when the font is updated it is not acknowledged by the Ai file until it is opened and resaved. Additionally, Ai does not change anything in a file that is resaved unless a change is made. So, what I had to do is open each Ai file and move or nudge some insignificant object or some other change to force an update, then resave the file. Also, if a change is made then undo is selected the file will not update it must be an actual change. Then it will update.

  • How to display image from wamp if the data type i use is blob?

    please help me with the problem of displaying image from wamp if data type is blob. Thanks

    Don't store the images in the database. Store the image file names in the database and put the images in a folder.

  • When capturing images from a Nikon D600, they show in Bridge, but when clicked to load into CS6,an error message says that it is the wrong type of document, even jpeg files. This is a NEW frustration.

    When capturing images from a Nikon D600, they show in Bridge, but when clicked to load into CS6,an error message says that it is the wrong type of document, evne jpeg files. This is a NEW frustration.

    Nikon raw files would open up in Adobe Camera Raw and so should jpegs.
    If you select one in Bridge and give the command "Ctrl r" (Windows), what happens?
    Also what is the version of ACR in the title bar?
    Gene
    Note: unmark your question as "answered". the green balloon next to the subject shows it as "solved".

  • Howto remove gif, jpeg (images) from e-mails?

    Hi Gurus.
    Please help, I want to remove gifs and other images from emails and deliver the rest of content to the user mailbox.
    Many thanks
    BR

    Hi,
    Look at the conversion channel in the Messaging Server Administration Guide. This allows you to replace the MIME contents of messages e.g. replace/remove a gif or other images that you specify.
    Regards,
    Shane.

  • Read an avi file using "Read from binary file" vi

    My question is how to read an avi file using "Read from binary file" vi .
    My objective is to create a series of small avi files by using IMAQ AVI write frame with mpeg-4 codec of 2 second long (so 40 frames in each file with 20 fps ) and then send them one by one so as to create a stream of video. The image are grabbed from USB camera. If I read those frames using IMAQ AVI read frame then compression advantage would be lost so I want to read the whole file itself.
    I read the avi file using "Read from binary file" with unsigned 8 bit data format and then sent to remote end and save it and then display it, however it didnt work. I later found that if I read an image file using "Read from binary file" with unsigned 8 bit data format and save it in local computer itself , the format would be changed and it would be unrecognizable. Am I doing wrong by reading the file in unsined 8 bit integer format or should I have used any other data types.
    I am using Labview 8.5 and Labview vision development module and vision acquisition module 8.5
    Your help would be highly appreciated.
    Thank you.
    Solved!
    Go to Solution.
    Attachments:
    read avi file in other data format.JPG ‏26 KB

    Hello,
    Check out the (full) help message for "write to binary file"
    The "prepend array or string size" input defaults to true, so in your example the data written to the file will have array size information added at the beginning and your output file will be (four bytes) longer than your input file. Wire a False constant to "prepend array or string size" to prevent this happening.
    Rod.
    Message Edited by Rod on 10-14-2008 02:43 PM

  • How to create Image from 8-bit grayscal pixel matrix

    Hi,
    I am trying to display image from fingerprintscanner.
    To communicate with the scanner I use JNI
    I've wrote java code which get the image from C++ as a byte[].
    To display image I use as sample code from forum tring to display the image.
    http://forum.java.sun.com/thread.jspa?forumID=20&threadID=628129
    import java.awt.*;
    import java.awt.color.*;
    import java.awt.image.*;
    import java.io.*;
    import java.util.*;
    import javax.imageio.*;
    import javax.swing.*;
    public class Example {
    public static void main(String[] args) throws IOException {
    final int H = 400;
    final int W = 600;
    byte[] pixels = createPixels(W*H);
    BufferedImage image = toImage(pixels, W, H);
    display(image);
    ImageIO.write(image, "jpeg", new File("static.jpeg"));
    public static void _main(String[] args) throws IOException {
    BufferedImage m = new BufferedImage(1, 1, BufferedImage.TYPE_BYTE_GRAY);
    WritableRaster r = m.getRaster();
    System.out.println(r.getClass());
    static byte[] createPixels(int size){
    byte[] pixels = new byte[size];
    Random r = new Random();
    r.nextBytes(pixels);
    return pixels;
    static BufferedImage toImage(byte[] pixels, int w, int h) {
    DataBuffer db = new DataBufferByte(pixels, w*h);
    WritableRaster raster = Raster.createInterleavedRaster(db,
    w, h, w, 1, new int[]{0}, null);
    ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
    ColorModel cm = new ComponentColorModel(cs, false, false,
    Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
    return new BufferedImage(cm, raster, false, null);
    static void display(BufferedImage image) {
    final JFrame f = new JFrame("");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(new JLabel(new ImageIcon(image)));
    f.pack();
    SwingUtilities.invokeLater(new Runnable(){
    public void run() {
    f.setLocationRelativeTo(null);
    f.setVisible(true);
    And I see only white pixels on black background.
    Here is description of C++ method:
    GetImage
    Syntax: unsigned char* GetImage(int handle)
    Description: This function grabs the image of a fingerprint from the UFIS scanner.
    Parameters: Handle of the scanner
    Return values: Pointer to 1D-array, which contains the 8-bit grayscale pixel matrix line by line.
    here is sample C++ code which works fine to show image in C++
    void Show(unsigned char * bitmap, int W, int H, CClientDC & ClientDC)
    int i, j;
    short color;
    for(i = 0; i < H; i++) {
         for(j = 0; j < W; j++) {
         color = (unsigned char)bitmap[j+i*W];
         ClientDC.SetPixel(j,i,RGB(color,color,color));
    Will appreciate your help .

    Hi Joel,
    The database nls parameters are:
    select * from nls_database_parameters;
    NLS_LANGUAGE AMERICAN
    NLS_TERRITORY AMERICA
    NLS_CURRENCY $
    NLS_ISO_CURRENCY AMERICA
    NLS_NUMERIC_CHARACTERS .,
    NLS_CHARACTERSET CL8MSWIN1251
    NLS_CALENDAR GREGORIAN
    NLS_DATE_FORMAT DD-MON-RR
    NLS_DATE_LANGUAGE AMERICAN
    NLS_SORT BINARY
    NLS_TIME_FORMAT HH.MI.SSXFF AM
    NLS_TIMESTAMP_FORMAT DD-MON-RR HH.MI.SSXFF AM
    NLS_TIME_TZ_FORMAT HH.MI.SSXFF AM TZR
    NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI.SSXFF AM TZR
    NLS_DUAL_CURRENCY $
    NLS_COMP BINARY
    NLS_LENGTH_SEMANTICS BYTE
    NLS_NCHAR_CONV_EXCP FALSE
    NLS_NCHAR_CHARACTERSET AL16UTF16
    NLS_RDBMS_VERSION 9.2.0.4.0
    Part of the email header:
    Content-Type: multipart/alternative; boundary="---=1T02D27M75MU981T02D27M75MU98"
    -----=1T02D27M75MU981T02D27M75MU98
    -----=1T02D27M75MU981T02D27M75MU98
    Content-Type: text/plain; charset=us-ascii
    -----=1T02D27M75MU981T02D27M75MU98
    Content-Type: text/html;
    -----=1T02D27M75MU981T02D27M75MU98--
    I think that something is wrong in the WWV_FLOW_MAIL package. In order to send 8-bit characters must be used UTL_SMTP.WRITE_ROW_DATA instead of the UTL_SMTP.WRITE_DATA.
    Regards,
    Roumen

  • Insert Image in SharePoint List & Display Image from SharePoint List using C# Pragmatically

    hi 
    i have a share point custom list with the following columns and its types.
    Title--------------->Single line of test 
    FirstName--------------->Single line of test
    LastName--------------->Single line of test
    Description--------------->multiple line of test
    Link--------------->Hyperlink or Picture
    Image--------------->Hyperlink or Picture
    I've to create a visual web part with the following input fields and which can insert following items in the above list columns
     Title                  asp textbox
    First Name         asp textbox
    Last Name        asp textbox
    Description        asp textbox
    Link                  asp textbox
    Image              file upload control
    Submit             asp button
    when i click browse button for image control in above web part it browses image .jpg,jpeg or .png file from my computer into image input field above and when i click submit button it must be submitted in the Image column in the above list.
    i want to know how can i do that in c# pragmatically. 
    i've another visual web part which should read the image from the list in Image column and display it in image control on the web part.
    like this
    <img id="imgdisplay" runat="server" src="" />
    how can i read image from image column through c# pragmatically.

    Hello,
    You can't directly add picture into "Hyperlink or Picture" column because this column takes URL value and image is binary etc. You can first upload that picture into picture library (create new picture or document library) then add that image link
    into that column.
    To add/edit "Hyperlink or Picture" column, SP provided special class called "SPFieldUrl". Wheer you need to pass URL and description as parameter.
    Refer this link for you ref:
    http://stackoverflow.com/questions/23829576/how-to-decide-sharepoint-url-field-is-set-as-hyperlink-or-picture
    Hope it could help
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • Which is better? Extracting images from directories or from database?

    Good day,
    I would like to start a discussion on extracting image (binary data) from a relational database. Although some might say that extracting image from directories is a better approach, I m still sceptic on that implementation.
    My argument towards this is based on the reasonings below:
    1. Easier maintainence. - System Administrator can do backup from one place which is the database.
    2. High level of security - can anyone tell me how easy it is to hack into a database server?
    3. image is not dependent on file structure - no more worries about broken links because some one might mistakenly change the directory structure. If there needs to be a change, it will be handle efficiently by the database server.
    The intention of my question is to find out :
    1. Why is taking image from a directory folder which resides on the web server is better than using the same approach from the database?
    2. How is this approach (taking image from directory) scalable if there is thousands of images and text that needs to be served?
    If anybody would be kind enough to reply, I would be most grateful.
    Thank You.
    Regards
    hatta

    Databases are typically more oriented towards text and number content than binary content, I believe. If you carry images in the database you will need to run them through your code and through your java server before they are displayed. If they are held in a directory they will be called from hrefs in the produced page, which means that they are served by your static server. This is quicker because no processing of the image is required. It also means the Database has to handle massively less data. Depending on the database this should be far quicker to query.
    It is worth noting that it is also quite difficult to actually change mime-types on a page to display a picture in the midst of HTML- the number of enquiries on these pages about this topic should be enough to illustrate this.
    If you give over controls of all the image file handling to your java system (which I do when I write sites like the one you describe) then the actual program knows where to put the images and automatically adds them to the database. The system administrator never needs to touch them. If they want a backup they save the database and the website directory. The second of those should be a standard administrative task anyway, so there is not a huge difference there. The danger of someone accidentally changing the directory structure is no greater than the danger of someone accidentally dropping a database table- it can be minimised by making sure your administrators are competent. Directory structures can be changed back, dropped tables are gone.
    The security claim is slightly negated because you still have to run a webserver. Every program you run on your server is vulnerable to attack but if you are serving web pages you will have a server program that is faster than a database for image handling. You are far more at risk from running FTP or Telnet on your server or (worst of all) trying to maintain IIS.
    The images in directory structure is more scalable because very large databases are more likely to become unstable and carrying a 50k image in every image field rather than 2 bytes of text will make the database roughly 25000 times larger. I have already mentioned the difference in serving methods which stands in favour of recycling images. A static site will be faster than a dynamic site of equivalent size, so where you can, take advantage of that.

  • Display Images from Database

    Hi all,
    I require to display images stored in database along with textual description of it on a JSP.
    The image file should not be stored intermediately on file system (i.e w/o using img HTML tag)
    It is a typical shopping cart appln. where images are fetched from database and the associated description is displayed along side.
    Please note that it is the case of Mixed content types(text and binary data).
    Thanks and Regards

    Like "Breakfast" said, you can do this with a servlet that retrieves your images from a database....
    if you create a servlet to do this, you would have a generic servlet which retrieves a picture from a database based upon a key which could be a picture name or number.
    Lets say the file is out there in the database as a BLOB or Binary Image... you could have this kind of code in the doPost(HttpRequest req, HttpResponse res) or doService(HttpRequest req, HttpResponse res) method.
    The table holding the image has at least two columns one called IMAGE which holds the binary image and the other called FILENAME. If the connection to the DB is already open, you do something like this.
    String fileToGet = (String)req.getParameter("FILENAME");
    rs = conn.createStatement().executeQuery("select from IMAGE_TABLE where FILENAME='" + fileToGet + "'");
    if(rs.next())
    InputStream in = rs.getBinaryStream("IMAGE");
    res.setContentType("image/jpg"); // or whatever type of file it is.
    ServletOutputStream sout = res.getOutputStream();
    int c;
    while((c = in.read()) != -1)
    sout.write(c);
    in.close();
    sout.close();
    This should write your image to the response output of the servlet.
    Now, where you want your image, you put.
    <img src="/servlet/ImageServlet?FILENAME="thefileIwant">
    This should do what you want... Use your favorite pipe copy method to get the input stream to the output stream. If you are worried about overhead and scaling like "breakfast" said (it CAN be a problem in high access sites), then you can add an image caching scheme and get really complex.... But this is a rough idea on what to do.
    Hope this helps.
    Stephen McConnell

Maybe you are looking for

  • I can't delete my photos in the new iOS7 photo app.

    Hi, I can't delete my photos in the new iOS7 photo app. I tried shutting the app down and opening it again, but it doesn't help. What should I do? Thanks

  • SharePoint 2010 & SQL Server Report Builder 3.0 - HTTP 404 Error

    Hi all, Apologies if this post is not in the correct forum.  I have recently upgraded my SQL installation on my SharePoint server from Express 2008 R2 to Standard 2008 R2 so I could set up Reporting Services Integration in CA.  Followed instructions

  • Inactive pixels, but its not what you think.......

    Just purchased a 5800 Xpress direct from nokia a week ago and have now discovered 3 clusters of inactive pixels comprising of 6, 8, and 10 groups. They are all on the number 1, when in text mode. Now most people, including myself would automatically

  • Why can't available to open my file in Adobe

    I'm ops but when I'm send to email I not available to see my document

  • Lion Server no LAG / BOND Support?

    I HOPE I am missing something. I put the dual GE on the Mac Pro into a LAG / BOND Group, to my switch. OSX Network pannel sees the bonded interfaces, and though static IP, is getting DNS information from Router. The Server Application, knows the IP a