Results 1 to 4 of 4

Thread: Show binary image

  1. #1
    Sencha User
    Join Date
    Dec 2010
    Location
    Toronto
    Posts
    62

    Default Show binary image

    I try to show a binary image from database,

    var picBox = {
    id: 'imgname',
    name: 'imgname',
    fieldLabel: '',
    xtype: 'box', // or xtype: 'component',
    width: 150, //
    height: 150, //
    autoEl: {
    tag: 'img', //
    src: image //'../../images/Logo.png' //exists.png' /// <reference path="../../images/Logo.png" />
    }
    }
    }
    //////////////////////////////////////////////////////////
    function hexToBase64(str) {
    return btoa(String.fromCharCode.apply(null, str.replace(/\r|\n/g, "").replace(/([\da-fA-F]{2}) ?/g, "0x$1 ").replace(/ +$/, "").split(" ")));
    }
    ////////////////////////////////////////////////
    Ext.getCmp('imgname').src = 'data:image/jpeg;base64,' + hexToBase64(form.responseText);

    form.responseText is from backend code(c#)
    byte[] image = (byte[])imageData;
    Response.ContentType = "image/jpeg";
    Response.BinaryWrite(image);
    Response.End();

    I cant get image show. Is anything wrong?

    Many thanks,
    Thomson

  2. #2

    Default

    Data encoded by base64 cannot be read.
    You can pass url of image to front page.

  3. #3
    Sencha User
    Join Date
    Dec 2010
    Location
    Toronto
    Posts
    62

    Default

    I stored image in the database, so I don't have url for access. I believed the image can show to front from database.

    thanks for your respond.
    Thomson

  4. #4

    Default

    Hi guy, maybe you are right . I just found it here
    http://stackoverflow.com/questions/1...lob-in-webpage

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •