HDC Ausschnitt als jpg speichern
-
Hallo,
ich möchte gerne ein HDC unter GDI als jpg mit GDI+ speichern. Der Code aktuell:
HDC hdc2; HBITMAP aBmp; Gdiplus::Bitmap* gdippbitmap; HPALETTE pal=0; hdc2=CreateCompatibleDC(device->device); aBmp=CreateCompatibleBitmap(device->device,rect->right,rect->bottom); SelectObject(hdc2,aBmp); BitBlt(hdc2,rect->left,rect->top,rect->right-rect->left,rect->bottom-rect->top,device->device,rect->left,rect->top,SRCCOPY); gdippbitmap=Gdiplus::Bitmap::FromHBITMAP(aBmp,0); DeleteObject(aBmp); DeleteDC(hdc2); delete gdippbitmap;Jetzt habe ich zwar ein GDI+ Bitmap aber kein Image. Denn man kann nur ein Image speichern: http://msdn.microsoft.com/en-us/library/ms535407(VS.85).aspx
Irgendjemand ne Idee?
-
Hallo,
MSDN-Doku schrieb:
The Bitmap class inherits from the Image class
D.h., man sollte die Save-Methoden der Image-Klasse aufrufen können, auch mit einem Gdiplus::Bitmap-Objekt.
Allerdings steht dort auch:
MSDN-Doku schrieb:
Do not pass to the FromHBITMAP method a GDI bitmap or a GDI palette that is currently (or was previously) selected into a device context.
Einfach ausprobieren, was passiert, wenn die Bitmap korrekt aus dem DC entfernt wurde.
MfG,
Probe-Nutzer
-
hallo!
benutz doch einfach die CImage class
wenn du nach BitBlt und SelectObject eine HMBITMAP hast kannst du einfach
CImage::Attach(hBitmap);
CImage::Save(ScreenName,ImageFormatJPEG);benutzen