javascript - How to display binary data as image - extjs 4 -



javascript - How to display binary data as image - extjs 4 -

here binary valid .jpeg image. http://pastebin.ca/raw/2314500

i have tried utilize python save binary info image.

how can convert info viewable .jpeg image extjs 4?

i tried this, doesn't work.

data:image/jpeg;base64,+ binary info

need convert in base64.

js have btoa() function it.

for example:

var img = document.createelement('img'); img.src = 'data:image/jpeg;base64,' + btoa('your-binary-data'); document.body.appendchild(img);

but think binary info in pastebin invalid - jpeg info must ended on 'ffd9'.

update:

need write simple hex base64 converter:

function hextobase64(str) { homecoming btoa(string.fromcharcode.apply(null, str.replace(/\r|\n/g, "").replace(/([\da-fa-f]{2}) ?/g, "0x$1 ").replace(/ +$/, "").split(" "))); }

and utilize it:

img.src = 'data:image/jpeg;base64,' + hextobase64('your-binary-data');

see working illustration hex info on jsfiddle

javascript ajax extjs extjs4

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -