How to Convert a BMP Image to a JPEG ...
-
Can you be a little less lazier than that?
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche .·´¯`·->Rajesh<-·´¯`·. [Microsoft MVP - Visual C++]
thx for reply
-
Can you be a little less lazier than that?
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche .·´¯`·->Rajesh<-·´¯`·. [Microsoft MVP - Visual C++]
Rajesh R Subramanian wrote:
Can you be a little less lazier than that?
Yes, he can add another
How to Convert a BMP Image to a JPEG ...
line to the message text. ;P :-D
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
How to Convert a BMP Image to a JPEG ...
#include <atlimage.h>
...
CImage bmpimg;
bmpimg.Load(_T("c:\\some.bmp"));
bmpimg.Save(_T("c:\\some.jpg"), ImageFormatJPEG);Mark Salsbery Microsoft MVP - Visual C++ :java:
-
How to Convert a BMP Image to a JPEG ...
You can use of CImage class with Save function of it.
-
You can use of CImage class with Save function of it.
-
Hi to all, I need to convert an array of bitmap to a compress format (avi, mpeg4 and so on). Do you have any idea how to do it in C++??? Regards, Daniele
Do you want to make a video files?
-
#include <atlimage.h>
...
CImage bmpimg;
bmpimg.Load(_T("c:\\some.bmp"));
bmpimg.Save(_T("c:\\some.jpg"), ImageFormatJPEG);Mark Salsbery Microsoft MVP - Visual C++ :java:
-
#include <atlimage.h>
...
CImage img;
img.Load(_T("c:\\some.jpg"));
img.Save(_T("c:\\some.bmp"), ImageFormatBMP);Mark Salsbery Microsoft MVP - Visual C++ :java:
-
#include <atlimage.h>
...
CImage img;
img.Load(_T("c:\\some.jpg"));
img.Save(_T("c:\\some.bmp"), ImageFormatBMP);Mark Salsbery Microsoft MVP - Visual C++ :java:
-
CImage is a class shared by ATL and MFC these days. It uses GDI+ for image loading and saving. Here's the GDI+ version:
#include <gdiplus.h>
// This function stolen from the GDI+ docs
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; // 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
}
...
// Convert a JPEG to a BMP with GDI+
ULONG dwToken; Gdiplus::GdiplusStartupInput input; Gdiplus::GdiplusStartupOutput output; Gdiplus::Status status = Gdiplus::GdiplusStartup(&dwToken, &input, &output); if(status == Gdiplus::Ok) { Gdiplus::Bitmap \*pSrcBitmap = new Gdiplus::Bitmap(L"c:\\\\test.jpg", FALSE); CLSID bmpClsid; GetEncoderClsid(L"image/bmp", &bmpClsid); pSrcBitmap->Save(L"c:\\\\test.bmp", &bmpClsid); delete pSrcBitmap; Gdiplus::GdiplusShutdown(dwToken); }
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
CImage is a class shared by ATL and MFC these days. It uses GDI+ for image loading and saving. Here's the GDI+ version:
#include <gdiplus.h>
// This function stolen from the GDI+ docs
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; // 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
}
...
// Convert a JPEG to a BMP with GDI+
ULONG dwToken; Gdiplus::GdiplusStartupInput input; Gdiplus::GdiplusStartupOutput output; Gdiplus::Status status = Gdiplus::GdiplusStartup(&dwToken, &input, &output); if(status == Gdiplus::Ok) { Gdiplus::Bitmap \*pSrcBitmap = new Gdiplus::Bitmap(L"c:\\\\test.jpg", FALSE); CLSID bmpClsid; GetEncoderClsid(L"image/bmp", &bmpClsid); pSrcBitmap->Save(L"c:\\\\test.bmp", &bmpClsid); delete pSrcBitmap; Gdiplus::GdiplusShutdown(dwToken); }
Mark Salsbery Microsoft MVP - Visual C++ :java: