Search code examples
javascripthtmlfirebreath

converting a binary raw image data in javascript


I'm using a firebreath plugin and I am sending a raw binary image data from the plugin to JavaScript, but was not able to use this data as JavaScript did not recognize this. I later converted the raw image data to base64 format and used in JavaScript in which case I was able to draw the image but performance was hit as base64 conversion took nearly 100ms for each conversion.
Is there a way where in I can draw image directly from the raw image? I Basically have to improve performance.


Solution

  • rather than drawing it on a canvas, you could try putting a data URI in an image tag and sending it as a jpeg. Basically compress the image as much as you reasonably (for your application) can before you send it to javascript in order to minimize the amount you need to convert w/ base64. The only other way I could see it maybe working would be to use a websocket to talk to the plugin, which has its own problems.