3

I have a small C based camera app on Linux with a built-in microhttpd webserver that provides captured jpegs to webclients.

That works well, as the camera does jpg encoding, but as a further option, I need to alter image pixels at server side. So over another camera interface I get the 3 channel rbg image buffer and the question is, which image format do I need in order to display that pixeldata as an image in HTML using e.g.

<img src="/pixeldata"/>

? I prefer not to use an overbloated image lib to create a png or similar, so my 1st idea was to use

Content-Type: image/rgb

, which is the SGI rgb image format, but as I found out, it adds a 512! byte header just to essentially tell image width, height, number of channels... So my challenge is:

  • how to wrap the raw pixel data into a simple image header
  • preferably in plain C, without adding a large image lib to my camera project
  • to make it displayable in HTML on firefox, crome, ie ..

Thanks

x y
  • 911
  • 9
  • 27

1 Answers1

3

I would recommend using the BMP format. As far as I can tell it adds a header of something like 50 bytes.

The BMP format is simple too, it just exists of plain pixel data in the format you want. If you're concerned about the header size of the file, you're not going to get much less than BMP.

bzeaman
  • 1,128
  • 11
  • 28
  • That's it. I found [this code snippet](http://stackoverflow.com/questions/11004868/creating-a-bmp-file-bitmap-in-c) which solves my problem. Thank you for pointing me in the right direction. – x y Jun 22 '16 at 08:10