Main Site Documentation

Is there a way to convert a bmp image to a jpg image?


#1

hi, my project is using gadgeteer camera module to capture picture, and upload the picture to the internet, but the internet server just support recieve jpg, png and gif image, the camera module is only output bmp image, so my problem is how to convert the bmp image to jpg format?
thanks very much!


#2

There is decoding but no encoding. You can add encoding using RLP. The jpeg code is standard and open if you google it.

This requires a bit more advance knowledge in C programming.


#3

Jpeg is a very fiddly, but interesting format.

Once I have a working camera, will probably knock up some code for handling them.

C# is not the greatest language for creating them. Have a look at:
http://www.codeproject.com/Articles/83225/A-Simple-JPEG-Encoder-in-C#

Can we write code in any other languages to send over to the board?


#4

thanks for your replies, it looks like i have to using underlayer method to solve this problem, may be i need consult some jpg encoding arithmetic in c.


#5

Do you have a server where you can run an image converter? BMP->PNG conversion is very easy to write using the .NET Framework. It would be just a few lines of code. For extra points, you could write it as a Web service that automatically sends the result to your destination of choice.

If you want to write a converter yourself, PNG is a much, much simpler format than JPG.


#6

For standard C# .Net
Image myImage = Image.FromFile(“myBMPImage.bmp”);
myImage.Save(“myJPEGImage.jpg”, ImageFormat.Jpeg);

Or take it from a stream, and throw it straight back out if you just want it passed through memory.

New to NetMF, but have seen these.

From: http://msdn.microsoft.com/en-us/library/cc533012.aspx
BMP and JPG image support, and text manipulation.
and reference to it in:
http://msdn.microsoft.com/en-us/library/cc561295.aspx

There may just be a decoder that can be included. When i have a working camera, will have a play and see if anything is hidden in there we can use.


#7

Spotted this,

Looks like the system will convert Jpeg to Bitmap

Bitmap picImage = new Bitmap(pictureData, Bitmap.BitmapImageType.Jpeg);


#8

Yes it will decode BMP, JPEG and GIF. But not encode.


#9

hi, Kerry, thanks for your advise, i will try to convert the image to png format, do you have some example code programing in c to reference? besides, may be the easiest way is to change the camera, using a new which output jpg image.


#10

Here’s a tutorial and example code on converting BMP to PNG in C#: http://programcsharp.com/blog/archive/2006/12/20/bitmap-to-png-converter.aspx. I don’t have a C example handy, but can poke around if you like.


#11

thanks a lot!


#12

it seems like you need an image converter to convert the image into formats you desire. it is simplier and fast. http://www.rasteredge.com/how-to/vb-net-imaging/image-converting/


#13

Maybe you can use http://netmf.codeplex.com/workitem/332

Seems there is some bit-fiddling that might work for you, maybe even a probability for it to be included later in the 4.3 SDK???