Commit d87adf2a authored by Vincent Povirk's avatar Vincent Povirk Committed by Alexandre Julliard

gdiplus: Don't use IPicture to manage the HDC associated with a GpBitmap.

parent e48524ce
...@@ -672,7 +672,7 @@ GpStatus WINGDIPAPI GdipCreateTextureIA(GpImage *image, ...@@ -672,7 +672,7 @@ GpStatus WINGDIPAPI GdipCreateTextureIA(GpImage *image,
hbm = ((GpBitmap*)image)->hbitmap; hbm = ((GpBitmap*)image)->hbitmap;
if(!hbm) return GenericError; if(!hbm) return GenericError;
IPicture_get_CurDC(image->picture, &hdc); hdc = ((GpBitmap*)image)->hdc;
bm_is_selected = (hdc != 0); bm_is_selected = (hdc != 0);
pbmi = GdipAlloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)); pbmi = GdipAlloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
......
...@@ -223,6 +223,7 @@ struct GpBitmap{ ...@@ -223,6 +223,7 @@ struct GpBitmap{
INT numlocks; INT numlocks;
BYTE *bitmapbits; /* pointer to the buffer we passed in BitmapLockBits */ BYTE *bitmapbits; /* pointer to the buffer we passed in BitmapLockBits */
HBITMAP hbitmap; HBITMAP hbitmap;
HDC hdc;
}; };
struct GpCachedBitmap{ struct GpCachedBitmap{
......
...@@ -168,7 +168,7 @@ GpStatus WINGDIPAPI GdipBitmapLockBits(GpBitmap* bitmap, GDIPCONST GpRect* rect, ...@@ -168,7 +168,7 @@ GpStatus WINGDIPAPI GdipBitmapLockBits(GpBitmap* bitmap, GDIPCONST GpRect* rect,
return WrongState; return WrongState;
hbm = bitmap->hbitmap; hbm = bitmap->hbitmap;
IPicture_get_CurDC(bitmap->image.picture, &hdc); hdc = bitmap->hdc;
bm_is_selected = (hdc != 0); bm_is_selected = (hdc != 0);
pbmi = GdipAlloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)); pbmi = GdipAlloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
...@@ -264,7 +264,7 @@ GpStatus WINGDIPAPI GdipBitmapUnlockBits(GpBitmap* bitmap, ...@@ -264,7 +264,7 @@ GpStatus WINGDIPAPI GdipBitmapUnlockBits(GpBitmap* bitmap,
} }
hbm = bitmap->hbitmap; hbm = bitmap->hbitmap;
IPicture_get_CurDC(bitmap->image.picture, &hdc); hdc = bitmap->hdc;
bm_is_selected = (hdc != 0); bm_is_selected = (hdc != 0);
pbmi = GdipAlloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)); pbmi = GdipAlloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
...@@ -588,6 +588,7 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromHICON(HICON hicon, GpBitmap** bitmap) ...@@ -588,6 +588,7 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromHICON(HICON hicon, GpBitmap** bitmap)
(*bitmap)->width = ipicture_pixel_width((*bitmap)->image.picture); (*bitmap)->width = ipicture_pixel_width((*bitmap)->image.picture);
(*bitmap)->height = ipicture_pixel_height((*bitmap)->image.picture); (*bitmap)->height = ipicture_pixel_height((*bitmap)->image.picture);
(*bitmap)->hbitmap = NULL; (*bitmap)->hbitmap = NULL;
(*bitmap)->hdc = NULL;
DeleteObject(iinfo.hbmColor); DeleteObject(iinfo.hbmColor);
DeleteObject(iinfo.hbmMask); DeleteObject(iinfo.hbmMask);
...@@ -689,6 +690,7 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride, ...@@ -689,6 +690,7 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride,
(*bitmap)->height = height; (*bitmap)->height = height;
(*bitmap)->format = format; (*bitmap)->format = format;
IPicture_get_Handle((*bitmap)->image.picture, (OLE_HANDLE*)&(*bitmap)->hbitmap); IPicture_get_Handle((*bitmap)->image.picture, (OLE_HANDLE*)&(*bitmap)->hbitmap);
IPicture_get_CurDC((*bitmap)->image.picture, &(*bitmap)->hdc);
return Ok; return Ok;
} }
...@@ -786,18 +788,17 @@ GpStatus WINGDIPAPI GdipEmfToWmfBits(HENHMETAFILE hemf, UINT cbData16, ...@@ -786,18 +788,17 @@ GpStatus WINGDIPAPI GdipEmfToWmfBits(HENHMETAFILE hemf, UINT cbData16,
GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image) GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
{ {
HDC hdc;
TRACE("%p\n", image); TRACE("%p\n", image);
if(!image) if(!image)
return InvalidParameter; return InvalidParameter;
IPicture_get_CurDC(image->picture, &hdc);
DeleteDC(hdc);
IPicture_Release(image->picture); IPicture_Release(image->picture);
if (image->type == ImageTypeBitmap) if (image->type == ImageTypeBitmap)
{
GdipFree(((GpBitmap*)image)->bitmapbits); GdipFree(((GpBitmap*)image)->bitmapbits);
DeleteDC(((GpBitmap*)image)->hdc);
}
GdipFree(image); GdipFree(image);
return Ok; return Ok;
...@@ -889,11 +890,12 @@ GpStatus WINGDIPAPI GdipGetImageGraphicsContext(GpImage *image, ...@@ -889,11 +890,12 @@ GpStatus WINGDIPAPI GdipGetImageGraphicsContext(GpImage *image,
return NotImplemented; return NotImplemented;
} }
IPicture_get_CurDC(image->picture, &hdc); hdc = ((GpBitmap*)image)->hdc;
if(!hdc){ if(!hdc){
hdc = CreateCompatibleDC(0); hdc = CreateCompatibleDC(0);
IPicture_SelectPicture(image->picture, hdc, NULL, NULL); SelectObject(hdc, ((GpBitmap*)image)->hbitmap);
((GpBitmap*)image)->hdc = hdc;
} }
return GdipCreateFromHDC(hdc, graphics); return GdipCreateFromHDC(hdc, graphics);
...@@ -1264,6 +1266,7 @@ static GpStatus decode_image_olepicture_bitmap(IStream* stream, REFCLSID clsid, ...@@ -1264,6 +1266,7 @@ static GpStatus decode_image_olepicture_bitmap(IStream* stream, REFCLSID clsid,
IPicture_get_CurDC(pic, &hdc); IPicture_get_CurDC(pic, &hdc);
(*((GpBitmap**) image))->hbitmap = hbm; (*((GpBitmap**) image))->hbitmap = hbm;
(*((GpBitmap**) image))->hdc = hdc;
bmch = (BITMAPCOREHEADER*) (&pbmi->bmiHeader); bmch = (BITMAPCOREHEADER*) (&pbmi->bmiHeader);
bmch->bcSize = sizeof(BITMAPCOREHEADER); bmch->bcSize = sizeof(BITMAPCOREHEADER);
...@@ -1583,9 +1586,7 @@ GpStatus WINGDIPAPI GdipSaveImageToStream(GpImage *image, IStream* stream, ...@@ -1583,9 +1586,7 @@ GpStatus WINGDIPAPI GdipSaveImageToStream(GpImage *image, IStream* stream,
hbmp = ((GpBitmap*)image)->hbitmap; hbmp = ((GpBitmap*)image)->hbitmap;
if (!hbmp) if (!hbmp)
return GenericError; return GenericError;
hr = IPicture_get_CurDC(image->picture, &hdc); hdc = ((GpBitmap*)image)->hdc;
if (FAILED(hr))
return GenericError;
bm_is_selected = (hdc != 0); bm_is_selected = (hdc != 0);
if (!bm_is_selected) { if (!bm_is_selected) {
hdc = CreateCompatibleDC(0); hdc = CreateCompatibleDC(0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment