Register to reply

C# .bmp to .jpg

by madmike159
Tags: None
Share this thread:
madmike159
#1
Feb2-12, 11:20 AM
PF Gold
madmike159's Avatar
P: 370
I am getting a 640x480 bitmap image of an Xbox Kinect, and I have also made a separate programs which can send and receive images over TCP.

Since bimaps are uncompressed I would like to convert the image to a JPEG to save bandwith. The only examples I have seen of this were for saving images.

The code I have seen was something like this.

Image bitmapImage = openfile(path);    //Gets image from a file path
Image jpegImage;
jpegImage.save(path, jpg);     //Saves a jpeg to the path
I want to be able to get an image from the Kinect (I have code for this bit), then that the Image object and save it to another Image but as a JPEG.

Anyone got any ideas on how to do this?
Phys.Org News Partner Science news on Phys.org
FIXD tells car drivers via smartphone what is wrong
Team pioneers strategy for creating new materials
Team defines new biodiversity metric
madmike159
#2
Feb9-12, 04:06 AM
PF Gold
madmike159's Avatar
P: 370
Bump

Anyone got any ideas, I'm struggling to find a way to do this.
Mark44
#3
Feb9-12, 12:55 PM
Mentor
P: 21,292
What language are you coding in? That would be helpful information.

AlephZero
#4
Feb9-12, 01:10 PM
Engineering
Sci Advisor
HW Helper
Thanks
P: 7,166
C# .bmp to .jpg

Quote Quote by Mark44 View Post
What language are you coding in?
From the thread title, I presume C#.
Borek
#5
Feb9-12, 01:47 PM
Admin
Borek's Avatar
P: 23,585
GDI+ comes to mind: http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx

At least I used it to save plots of titration curves in PNG format (from C++) from my . From what I remember it saves in JPG as well.
Mark44
#6
Feb9-12, 01:56 PM
Mentor
P: 21,292
Quote Quote by AlephZero View Post
From the thread title, I presume C#.
I thought he had said C#, but couldn't find it in the body of his post. Guess I didn't look hard enough to notice it in the title.

Mad Mike, check the System.Drawing namespace, and particularly the Image class. The Save method has an overload that lets you specify the format of the saved image.
madmike159
#7
Feb10-12, 06:21 AM
PF Gold
madmike159's Avatar
P: 370
Yea, I'm using c#. Should have made that clear.

At the moment I am reading in a bmp image from the kinect camera, saving it as a jpg and then opening that file and sending the jpg. I would rather just be able to convert it with out having to save it to disk first.
Mark44
#8
Feb10-12, 08:16 PM
Mentor
P: 21,292
You don't have to save it to disk - you can save the bitmap image to a stream, and then do whatever with it. See http://msdn.microsoft.com/en-us/library/ms142147.aspx.


Register to reply