Fallen JLI MVP
Alter: 40 Anmeldedatum: 08.03.2003 Beiträge: 2860 Wohnort: Münster Medaillen: 1 (mehr...)
|
Verfasst am: 04.01.2005, 07:03 Titel: |
|
|
hat sich erledigt ich hab die kunst des GDI+ erlernt damit geht das ganze recht gut.
Code: | int GetEncoderClsid(const WCHAR* format, CLSID* pClsid)
{
using namespace Gdiplus;
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
}
BOOL WriteBitmap( CString szFile, HBITMAP bmp)
{
using namespace Gdiplus;
LPWSTR lpszW = new WCHAR[255];
LPTSTR lpStr = szFile.GetBuffer( szFile.GetLength() );
int nLen = MultiByteToWideChar(CP_ACP, 0,lpStr, -1, NULL, NULL);
MultiByteToWideChar(CP_ACP, 0, lpStr, -1, lpszW, nLen);
HDC HelpDC=CreateCompatibleDC(NULL);;
SelectObject(HelpDC,bmp);
HPALETTE hPalette = (HPALETTE)GetCurrentObject( HelpDC, OBJ_PAL) ;
CLSID encoderClsid;
GetEncoderClsid(L"image/bmp", &encoderClsid);
Bitmap *myBitMap = new Bitmap(bmp, hPalette ) ;
myBitMap->Save(lpszW,&encoderClsid);
delete[] lpszW;
DeleteDC(HelpDC);
return TRUE;
} |
_________________ "I have a Core2Quad at 3.2GHz, 4GB of RAM at 1066 and an Nvidia 8800 GTS 512 on Vista64 and this game runs like ass whereas everything else I own runs like melted butter over a smokin' hot 18 year old catholic schoolgirl's arse." |
|