Page 1 of 1

Source code to convert bmp to jpeg

Posted: Wed Apr 10, 2013 6:08 pm
by jdal
I have a requirement to convert a .bmp image to a .jpg.
I have a sensor that only outputs a .bmp image, and i have to send that to another destination which only accepts .jpg.
I spent some time looking for source code to do this rahter than re-inventing the wheel, but so far am unable to find anything useful that can be used in our compiler. Most of the stuff out there is for C# and VB.

In your journeys, have any of you come across anything to do this ?

Re: Source code to convert bmp to jpeg

Posted: Thu Apr 11, 2013 6:22 am
by mhoyt
There is a lot of stuff out there for JPEG and BMP formats in C and C++. After all, the reference libraries for these formats were originally created in C. There is a significant amount of C and C++ code out there for practically any widely-accepted file format. If you haven't found much, then you haven't been looking in the right place.

Having said that, there are at least two options I can think of right away:

1. libjpeg (http://libjpeg.sourceforge.net), an open-source C library with a liberal license (i.e. free for any use). I have only used this library with the Windows platform, but I expect it would port nicely to the Netburner platform.

2. jpeg-compressor (https://code.google.com/p/jpeg-compressor/). In lieu of a relatively large and full-featured library like libjpeg, this library puts all the code to generate jpeg files into a single C++ source file. It was written for the Windows platform, but the code should port easily to Netburner.

With either of these libraries, you'd still need to get the BMP data into shape for input into the JPEG library. BMP format is very simple, you could find a library to pull out the image data or roll one yourself.

Hope this helps!

--Mike

Re: Source code to convert bmp to jpeg

Posted: Thu Apr 11, 2013 6:29 am
by mhoyt
I should add that the aforementioned jpeg-compressor project includes in the source distribution an example program that can read in a BMP and output a JPEG.

--Mike

Re: Source code to convert bmp to jpeg

Posted: Thu Apr 11, 2013 6:33 am
by jdal
Thank mike i will look into it.
With either of these libraries, you'd still need to get the BMP data into shape for input into the JPEG library. BMP format is very simple, you could find a library to pull out the image data or roll one yourself.
I have done this, this was the easy part. I think first i am going to look at trying to get the other end to do the conversion for me. It looks like converting the bmp to jpeg on the NB end will be to time consuming to compute the values pixel for pixel.

Re: Source code to convert bmp to jpeg

Posted: Sat Feb 06, 2016 1:50 am
by james442
I have a requirement to convert a .bmp image to a .jpg.
I have a sensor that only outputs a .bmp image, and i have to send that to another destination which only accepts .jpg.
I spent some time looking for source code to do this rahter than re-inventing the wheel, but so far am unable to find anything useful that can be used in our compiler. Most of the stuff out there is for C# and VB.

Re: Source code to convert bmp to jpeg

Posted: Tue Feb 09, 2016 1:50 am
by dciliske
Turns out, the jpeg-compressor lib works straight out of the box. I spent faaaar more time trying to get raw data to feed into it than trying to get it to actually work. Here's my rough Tiff parser and an app that will serve up Lena, converting it on the way out the door.

-Dan

Re: Source code to convert bmp to jpeg

Posted: Fri Apr 05, 2024 4:19 am
by Ushavilash
Hey hi, you can use the libjpeg library to convert BMP images to JPEG format. It's a widely used library with support for various programming languages, including C and C++ and detail information check wikipedia on the other hand for jpeg compressing you can use any online application such as Jpeg Compressor.