Hi All..
I using VC++ 6.0..with windows XP..
I have bmp image which I would like convert it save as jpeg format..
can anyone teach me the steps..??
Thank you..
Shizu..
Easiest solution is GDI+:
http://msdn.microsoft.com/en-us/library/ms534462%28v=VS.85%29.aspx
Load your bmp file into an 'Image' object then save it using the appropriate encoder:
VOID Example_SaveFile()
{
// Create an Image object based on a PNG file.
Image image(L"Mosaic.bmp");
// Save the image.
CLSID jpgClsid;
GetEncoderClsid(L"image/jpeg", &jpgClsid);
image.Save(L"Mosaic2.jpg", &jpgClsid, NULL);
}
Hi luce..
I try your code already..
once compile I get error message like below show..
******************************************************************
error C2065: 'Image' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 'image'
error C2065: 'image' : undeclared identifier
error C2065: 'GetEncoderClsid' : undeclared identifier
error C2228: left of '.Save' must have class/struct/union type
******************************************************************
Please help..
am I need to include any header..??
Hi luce..
I try your code already..
once compile I get error message like below show..******************************************************************
error C2065: 'Image' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 'image'
error C2065: 'image' : undeclared identifier
error C2065: 'GetEncoderClsid' : undeclared identifier
error C2228: left of '.Save' must have class/struct/union type
******************************************************************
Please help..am I need to include any header..??
He wasn't writing your code for you, he was giving an example of how to implement the functionality. No one will do your code for you, as stated here.
As stated, you would need to open the image file and output with the proper encoding. Here is an article of MDSN on how to do it as well. A lot of options are available to you.
Hi Red Goose..
I understand the rules..
I know that Luce only give me sample..
my question is I don't understand why I will have
error C2065: 'GetEncoderClsid' : undeclared identifier
am I missing something that need to include..??
Thank you..
shizu..
Shizu,
#include <Gdiplus.h>
using namespace Gdiplus;
#pragma comment (lib, "Gdiplus.lib")
And you'd need to initalize GDI+ before you can use it...
For further info check the documentation on MSDN (sent the link in my previous post)
Hi Luce..
Once I include <Gdiplus.h> without add in any code yet, after compile have error message that fail to locate
************************************************************************************
fatal error C1083: Cannot open include file: 'Gdiplus.h': No such file or directory
************************************************************************************
Am I need to install any SDK then I able to use this GDI+..??
Please advise..
Thank you..
shizu..
I agreed with Luce. It's the simplest way to convert a image to jpeg format.
If you need more advanced format converting, find some open sources jpeg convert, it would be very helpful.
Take the BMP image, copy it into paint. Then save it as JPEG
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.