Source code to convert bmp to jpeg

Discussion to talk about software related topics only.
Post Reply
jdal
Posts: 21
Joined: Sat Jan 07, 2012 7:10 am

Source code to convert bmp to jpeg

Post 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 ?
mhoyt
Posts: 9
Joined: Fri Feb 19, 2010 12:17 pm
Location: Blue Bell, Pennsylvania, USA
Contact:

Re: Source code to convert bmp to jpeg

Post 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
mhoyt
Posts: 9
Joined: Fri Feb 19, 2010 12:17 pm
Location: Blue Bell, Pennsylvania, USA
Contact:

Re: Source code to convert bmp to jpeg

Post 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
jdal
Posts: 21
Joined: Sat Jan 07, 2012 7:10 am

Re: Source code to convert bmp to jpeg

Post 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.
james442
Posts: 1
Joined: Fri Feb 05, 2016 10:31 pm

Re: Source code to convert bmp to jpeg

Post 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.
User avatar
dciliske
Posts: 623
Joined: Mon Feb 06, 2012 9:37 am
Location: San Diego, CA
Contact:

Re: Source code to convert bmp to jpeg

Post 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
Attachments
bmp2jpeg.tar.gz
(947.73 KiB) Downloaded 483 times
Dan Ciliske
Project Engineer
Netburner, Inc
Ushavilash
Posts: 3
Joined: Mon Feb 26, 2024 11:00 pm

Re: Source code to convert bmp to jpeg

Post 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.
Post Reply