Link to home
Start Free TrialLog in
Avatar of gzjimfan
gzjimfan

asked on

Inline bitmap, Data URL and RLE compressed data in JavaScript

Hi experts,

I have a RLE compressed bitmap encoded in base64, and I would like to use inline bitmap (data URL) to display this picture in FireFox. It looks like fire fox can't display my bitmap, does anyone know why?

My code that displays the bitmap is:

function display(base64str)
{
   var pic = document.createElement('img');
   pic.src = 'data:image/bmp;base64,' + base64str;
  var div = document.getElementById("mydiv");
  div.appendChild(pic);
}

I tried with none RLE compressed bitmap and it works fine.  So I am wondering if RLE is even supported in data URL kind of usage.
Avatar of NickVd
NickVd

Is there reason why you're using a bmp file instead of a gif or a jpeg?

Try data:image/gif;base64 or data:image/jpeg;base64 instead of data:image/bmp;base64

Also, make sure than your encoded string is not corrupt.
Avatar of gzjimfan

ASKER

The target I am working on is running on an embedded platform which does not support bitmap to jpeg/gif compression (or I would have to port code to do that), that's why I am using RLE to do it because it's much simpler. I think the base64 encoded data is OK because using the same code to encode the none-RLE compressed data can get a proper picture display.

If there's no other way to display encoded RLE bitmap I will need to look into solutions to compress jpeg images on the embedded platform.

Thanks for your response.
Ah..

Well since you're on an embedded system, I don't know how much help I can be other than suggesting you talk with the manufacturer.

Good luck! :)
:) I am the manufacturer (designer that develops the embedded device).

If you know a free piece of source code that compresses JPEG from bitmap in C/C++, please let me know..
image magick (though I'm not 100% on the language)
ASKER CERTIFIED SOLUTION
Avatar of NickVd
NickVd

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial