a windows API function to convert JPG into BMP [modified]
-
there are dozens. did you try searching this site? or Google?
-
there are dozens. did you try searching this site? or Google?
-
there are dozens. did you try searching this site? or Google?
-
If you don't need to write the JPEG decompression yourself, here's the simplest way I know:
#include <atlimage.h>
...
// (error handling omitted)
CImage image;
image.Load(_T("c:\\some.jpg"));
image.Save(_T("c:\\some.bmp"), ImageFormatBMP);Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
If you don't need to write the JPEG decompression yourself, here's the simplest way I know:
#include <atlimage.h>
...
// (error handling omitted)
CImage image;
image.Load(_T("c:\\some.jpg"));
image.Save(_T("c:\\some.bmp"), ImageFormatBMP);Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
do u know where can i get atlimage.h ??? CImage is a new class included with VC7 i think, but i use BC++ :( -- modified at 17:26 Thursday 25th October, 2007
V_shr wrote:
CImage is a new class included with VC7 i think, but i dont use VisualStudio.NET
:doh: Ok, try this ...
ULONG dwToken;
Gdiplus::GdiplusStartupInput input;
Gdiplus::GdiplusStartupOutput output;
Gdiplus::Status status = Gdiplus::GdiplusStartup(&dwToken, &input, &output);
if(status == Gdiplus::Ok)
{
Gdiplus::Bitmap *pBitmap = new Gdiplus::Bitmap(L"c:\\some.jpg", FALSE);
CLSID bmpClsid;
GetEncoderClsid(L"image/bmp", &bmpClsid);
pBitmap->Save(L"c:\\some.bmp", &bmpClsid);
delete pBitmap;Gdiplus::GdiplusShutdown(dwToken);
}I took the GetEncoderClsId() function right from the GDI+ docs in the Platform SDK. It looks like this:
int GetEncoderClsid(const WCHAR* format, CLSID* pClsid)
{
UINT num = 0; // number of image encoders
UINT size = 0; // size of the image encoder array in bytesImageCodecInfo* pImageCodecInfo = NULL;
GetImageEncodersSize(&num, &size);
if(size == 0)
return -1; // FailurepImageCodecInfo = (ImageCodecInfo*)(malloc(size));
if(pImageCodecInfo == NULL)
return -1; // FailureGetImageEncoders(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
}Mark
-
V_shr wrote:
CImage is a new class included with VC7 i think, but i dont use VisualStudio.NET
:doh: Ok, try this ...
ULONG dwToken;
Gdiplus::GdiplusStartupInput input;
Gdiplus::GdiplusStartupOutput output;
Gdiplus::Status status = Gdiplus::GdiplusStartup(&dwToken, &input, &output);
if(status == Gdiplus::Ok)
{
Gdiplus::Bitmap *pBitmap = new Gdiplus::Bitmap(L"c:\\some.jpg", FALSE);
CLSID bmpClsid;
GetEncoderClsid(L"image/bmp", &bmpClsid);
pBitmap->Save(L"c:\\some.bmp", &bmpClsid);
delete pBitmap;Gdiplus::GdiplusShutdown(dwToken);
}I took the GetEncoderClsId() function right from the GDI+ docs in the Platform SDK. It looks like this:
int GetEncoderClsid(const WCHAR* format, CLSID* pClsid)
{
UINT num = 0; // number of image encoders
UINT size = 0; // size of the image encoder array in bytesImageCodecInfo* pImageCodecInfo = NULL;
GetImageEncodersSize(&num, &size);
if(size == 0)
return -1; // FailurepImageCodecInfo = (ImageCodecInfo*)(malloc(size));
if(pImageCodecInfo == NULL)
return -1; // FailureGetImageEncoders(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
}Mark