PDA

View Full Version : How to show binary image to extjs?



thomsonzh
18 Jun 2013, 1:32 PM
Hi,
I have an picBox,
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" />


},
// listeners: { dblclick: { fn: function () { alert("double click"); } } }
listeners: {
render: function (component) {
component.getEl().on('click', function (e) {
winPopup = createWindowPopup();
winPopup.show();
winPopup.setTitle('Change Picture', 'imgUpload');
});
}
}


}

I also get image from database,
image = 'data:image/jpeg;base64,' + hexToBase64(form.responseText);
form.responseText is an binary image.
How can I show image to picBox?

Many thanks,

Colin Alworth
18 Jun 2013, 2:57 PM
You've posted in the GXT forum - I'd be happy to move this, but which version of Ext JS are you using?

thomsonzh
19 Jun 2013, 3:32 AM
You've posted in the GXT forum - I'd be happy to move this, but which version of Ext JS are you using? Thanks Colin,I use extjs3.x.

thomsonzh
27 Jun 2013, 10:58 AM
Ext.getCmp('imgname').getEl().dom.src = "exists.png";

It is working. But I try to get image from database, like,

Ext.getCmp('imgname').getEl().dom.src = 'data:image/jpeg;base64,' + hexToBase64(form.responseText); it's not working.

form.responseText below,

?PNG





IHDR??<?J
sRGB???gAMA?? ?a pHYs???o?d??IDATx^??g?U??
?s?9?s?9?s$*??DT[email protected]$?dD$???&?9?1?s??Yk??????{?9j??V}??7????%??[??Vr+???Jn%??[??Vr+???Jn%??[??Vr+???Jn%??[??Vr+???Jn%??[???'? ??`??cxq?QB?1L???$?????KKOb??'1??S? ?1? ??!?v??x?????O?????????*???4??<
???Xc???E???X?H???1w?e??_