The use of gdiplus in vc6.0 and the http://mingarlic.blog.163.com/blog/static/31148911200710261318324/ of a small example of converting BMP to JPG
# Include <gdiplus. h>
Using namespace gdiplus;
Gdiplusstartupinput m_gdiplusstartupinput;
Ulong_ptr m_gdiplustoken;
Int getencoderclsid (const wchar * format, CLSID * pclsid );
Void BMP 2jpg (cstring strbmp file, cstring strjpgfile );
Gdiplusstartup (& m_gdiplustoken, & m_gdiplusstartupinput, null );
BMP 2jpg ("...","...");
Gdiplusshutdown (m_gdipluw.en );
Int getencoderclsid (const wchar * format, CLSID * pclsid)
{
Uint num = 0; // Number of image encoders
Uint size = 0; // size of the image encoder array in bytes
Imagecodecinfo * pimagecodecinfo = NULL;
Getimageencoderssize (& num, & size );
If (size = 0)
Return-1; // failure
Pimagecodecinfo = (imagecodecinfo *) (malloc (size ));
If (pimagecodecinfo = NULL)
Return-1; // failure
Getimageencoders (Num, size, pimagecodecinfo );
For (uint J = 0; j <num; ++ J)
{
If (wcscmp (pimagecodecinfo [J]. mimetype, format) = 0)
{
* Pclsid = pimagecodecinfo [J]. CLSID;
Free (pimagecodecinfo );
Return J; // success
}
}
Free (pimagecodecinfo );
Return-1; // failure
}
Void BMP 2jpg (cstring strbmp file, cstring strjpgfile)
{
CLSID encoderclsid;
Wchar strguid [39];
If (getencoderclsid (L "image/JPEG", & encoderclsid)> = 0)
Stringfromguid2 (encoderclsid, strguid, 39 );
Image image (strbmp file. allocsysstring ());
Image. Save (strjpgfile. allocsysstring (), & encoderclsid, null );
}
/*
// In GDI +, You need to define a ulong_ptr.
# Ifndef ulong_ptr
# Define ulong_ptr unsigned long *
# Endif
*/