gdiplus: Add and use an HBITMAP field in GpBitmap objects.

This commit is contained in:
Vincent Povirk 2009-08-28 14:49:35 -05:00 committed by Alexandre Julliard
parent b99abe2e91
commit e48524ceb6
3 changed files with 10 additions and 6 deletions

View File

@ -670,7 +670,7 @@ GpStatus WINGDIPAPI GdipCreateTextureIA(GpImage *image,
n_y + n_height > ((GpBitmap*)image)->height) n_y + n_height > ((GpBitmap*)image)->height)
return InvalidParameter; return InvalidParameter;
IPicture_get_Handle(image->picture, (OLE_HANDLE*)&hbm); hbm = ((GpBitmap*)image)->hbitmap;
if(!hbm) return GenericError; if(!hbm) return GenericError;
IPicture_get_CurDC(image->picture, &hdc); IPicture_get_CurDC(image->picture, &hdc);
bm_is_selected = (hdc != 0); bm_is_selected = (hdc != 0);

View File

@ -222,6 +222,7 @@ struct GpBitmap{
ImageLockMode lockmode; ImageLockMode lockmode;
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;
}; };
struct GpCachedBitmap{ struct GpCachedBitmap{

View File

@ -167,7 +167,7 @@ GpStatus WINGDIPAPI GdipBitmapLockBits(GpBitmap* bitmap, GDIPCONST GpRect* rect,
if(bitmap->lockmode) if(bitmap->lockmode)
return WrongState; return WrongState;
IPicture_get_Handle(bitmap->image.picture, (OLE_HANDLE*)&hbm); hbm = bitmap->hbitmap;
IPicture_get_CurDC(bitmap->image.picture, &hdc); IPicture_get_CurDC(bitmap->image.picture, &hdc);
bm_is_selected = (hdc != 0); bm_is_selected = (hdc != 0);
@ -263,7 +263,7 @@ GpStatus WINGDIPAPI GdipBitmapUnlockBits(GpBitmap* bitmap,
return Ok; return Ok;
} }
IPicture_get_Handle(bitmap->image.picture, (OLE_HANDLE*)&hbm); hbm = bitmap->hbitmap;
IPicture_get_CurDC(bitmap->image.picture, &hdc); IPicture_get_CurDC(bitmap->image.picture, &hdc);
bm_is_selected = (hdc != 0); bm_is_selected = (hdc != 0);
@ -587,6 +587,7 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromHICON(HICON hicon, GpBitmap** bitmap)
(*bitmap)->image.flags = ImageFlagsNone; (*bitmap)->image.flags = ImageFlagsNone;
(*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;
DeleteObject(iinfo.hbmColor); DeleteObject(iinfo.hbmColor);
DeleteObject(iinfo.hbmMask); DeleteObject(iinfo.hbmMask);
@ -687,6 +688,7 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride,
(*bitmap)->width = width; (*bitmap)->width = width;
(*bitmap)->height = height; (*bitmap)->height = height;
(*bitmap)->format = format; (*bitmap)->format = format;
IPicture_get_Handle((*bitmap)->image.picture, (OLE_HANDLE*)&(*bitmap)->hbitmap);
return Ok; return Ok;
} }
@ -1261,6 +1263,8 @@ static GpStatus decode_image_olepicture_bitmap(IStream* stream, REFCLSID clsid,
IPicture_get_Handle(pic, (OLE_HANDLE*)&hbm); IPicture_get_Handle(pic, (OLE_HANDLE*)&hbm);
IPicture_get_CurDC(pic, &hdc); IPicture_get_CurDC(pic, &hdc);
(*((GpBitmap**) image))->hbitmap = hbm;
bmch = (BITMAPCOREHEADER*) (&pbmi->bmiHeader); bmch = (BITMAPCOREHEADER*) (&pbmi->bmiHeader);
bmch->bcSize = sizeof(BITMAPCOREHEADER); bmch->bcSize = sizeof(BITMAPCOREHEADER);
@ -1576,9 +1580,8 @@ GpStatus WINGDIPAPI GdipSaveImageToStream(GpImage *image, IStream* stream,
if (encode_image == NULL) if (encode_image == NULL)
return UnknownImageFormat; return UnknownImageFormat;
/* extract underlying hbitmap representation from the IPicture */ hbmp = ((GpBitmap*)image)->hbitmap;
hr = IPicture_get_Handle(image->picture, (OLE_HANDLE*)&hbmp); if (!hbmp)
if (FAILED(hr) || !hbmp)
return GenericError; return GenericError;
hr = IPicture_get_CurDC(image->picture, &hdc); hr = IPicture_get_CurDC(image->picture, &hdc);
if (FAILED(hr)) if (FAILED(hr))