jsbmp - JavaScript Bitmap Generator

Create Windows bitmap (.BMP) files with JavaScript.

Please note that this is not a high-level image composition library: included functions do little more than pack raw pixel data.

It supports 24-bit uncompressed (BI_RGB):

// 5x1 pixel progression from black to light grey
var greys = bmp_rgb(5, 1, ['000000','333333', '666666', '999999', 'cccccc']);

And 8-bit run-length encoded (BI_RLE8):

// 2000x2 pixel line, blue on top and red below
var bluelineredline = bmp_rle8(2000, 2, [['0000FF', 2000], ['FF0000', 2000]]);

Cool Examples


Tested with Firefox 3.0.11, Internet Explorer 8 and Safari version something.

Please note that, although version 8 finally adds data URI support to Internet Explorer, it is limited to URIs 32,000-odd characters long. (Consider that one pixel in an uncompressed bitmap takes up 4+ bytes, for a maximum base64-encoded size of ~80x80.)


Bitmap generation:

Supporting files: