Commit 4386caa1 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

gdiplus: Reduce the number of casts by using the proper type for variables.

parent 176c8eb3
...@@ -478,8 +478,7 @@ GpStatus WINGDIPAPI GdipCreateTextureIA(GpImage *image, ...@@ -478,8 +478,7 @@ GpStatus WINGDIPAPI GdipCreateTextureIA(GpImage *image,
REAL height, GpTexture **texture) REAL height, GpTexture **texture)
{ {
HDC hdc; HDC hdc;
OLE_HANDLE hbm; HBITMAP hbm, old = NULL;
HBITMAP old = NULL;
BITMAPINFO *pbmi; BITMAPINFO *pbmi;
BITMAPINFOHEADER *bmih; BITMAPINFOHEADER *bmih;
INT n_x, n_y, n_width, n_height, abs_height, stride, image_stride, i, bytespp; INT n_x, n_y, n_width, n_height, abs_height, stride, image_stride, i, bytespp;
...@@ -507,7 +506,7 @@ GpStatus WINGDIPAPI GdipCreateTextureIA(GpImage *image, ...@@ -507,7 +506,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, &hbm); IPicture_get_Handle(image->picture, (OLE_HANDLE*)&hbm);
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);
...@@ -520,11 +519,11 @@ GpStatus WINGDIPAPI GdipCreateTextureIA(GpImage *image, ...@@ -520,11 +519,11 @@ GpStatus WINGDIPAPI GdipCreateTextureIA(GpImage *image,
if(!bm_is_selected){ if(!bm_is_selected){
hdc = CreateCompatibleDC(0); hdc = CreateCompatibleDC(0);
old = SelectObject(hdc, (HBITMAP)hbm); old = SelectObject(hdc, hbm);
} }
/* fill out bmi */ /* fill out bmi */
GetDIBits(hdc, (HBITMAP)hbm, 0, 0, NULL, pbmi, DIB_RGB_COLORS); GetDIBits(hdc, hbm, 0, 0, NULL, pbmi, DIB_RGB_COLORS);
bytespp = pbmi->bmiHeader.biBitCount / 8; bytespp = pbmi->bmiHeader.biBitCount / 8;
abs_height = abs(pbmi->bmiHeader.biHeight); abs_height = abs(pbmi->bmiHeader.biHeight);
...@@ -538,7 +537,7 @@ GpStatus WINGDIPAPI GdipCreateTextureIA(GpImage *image, ...@@ -538,7 +537,7 @@ GpStatus WINGDIPAPI GdipCreateTextureIA(GpImage *image,
dibits = GdipAlloc(pbmi->bmiHeader.biSizeImage); dibits = GdipAlloc(pbmi->bmiHeader.biSizeImage);
if(dibits) /* this is not a good place to error out */ if(dibits) /* this is not a good place to error out */
GetDIBits(hdc, (HBITMAP)hbm, 0, abs_height, dibits, pbmi, DIB_RGB_COLORS); GetDIBits(hdc, hbm, 0, abs_height, dibits, pbmi, DIB_RGB_COLORS);
if(!bm_is_selected){ if(!bm_is_selected){
SelectObject(hdc, old); SelectObject(hdc, old);
......
...@@ -96,9 +96,8 @@ GpStatus WINGDIPAPI GdipBitmapLockBits(GpBitmap* bitmap, GDIPCONST GpRect* rect, ...@@ -96,9 +96,8 @@ GpStatus WINGDIPAPI GdipBitmapLockBits(GpBitmap* bitmap, GDIPCONST GpRect* rect,
{ {
BOOL bm_is_selected; BOOL bm_is_selected;
INT stride, bitspp = PIXELFORMATBPP(format); INT stride, bitspp = PIXELFORMATBPP(format);
OLE_HANDLE hbm;
HDC hdc; HDC hdc;
HBITMAP old = NULL; HBITMAP hbm, old = NULL;
BITMAPINFO *pbmi; BITMAPINFO *pbmi;
BYTE *buff = NULL; BYTE *buff = NULL;
UINT abs_height; UINT abs_height;
...@@ -128,7 +127,7 @@ GpStatus WINGDIPAPI GdipBitmapLockBits(GpBitmap* bitmap, GDIPCONST GpRect* rect, ...@@ -128,7 +127,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, &hbm); IPicture_get_Handle(bitmap->image.picture, (OLE_HANDLE*)&hbm);
IPicture_get_CurDC(bitmap->image.picture, &hdc); IPicture_get_CurDC(bitmap->image.picture, &hdc);
bm_is_selected = (hdc != 0); bm_is_selected = (hdc != 0);
...@@ -140,11 +139,11 @@ GpStatus WINGDIPAPI GdipBitmapLockBits(GpBitmap* bitmap, GDIPCONST GpRect* rect, ...@@ -140,11 +139,11 @@ GpStatus WINGDIPAPI GdipBitmapLockBits(GpBitmap* bitmap, GDIPCONST GpRect* rect,
if(!bm_is_selected){ if(!bm_is_selected){
hdc = CreateCompatibleDC(0); hdc = CreateCompatibleDC(0);
old = SelectObject(hdc, (HBITMAP)hbm); old = SelectObject(hdc, hbm);
} }
/* fill out bmi */ /* fill out bmi */
GetDIBits(hdc, (HBITMAP)hbm, 0, 0, NULL, pbmi, DIB_RGB_COLORS); GetDIBits(hdc, hbm, 0, 0, NULL, pbmi, DIB_RGB_COLORS);
abs_height = abs(pbmi->bmiHeader.biHeight); abs_height = abs(pbmi->bmiHeader.biHeight);
stride = pbmi->bmiHeader.biWidth * bitspp / 8; stride = pbmi->bmiHeader.biWidth * bitspp / 8;
...@@ -155,7 +154,7 @@ GpStatus WINGDIPAPI GdipBitmapLockBits(GpBitmap* bitmap, GDIPCONST GpRect* rect, ...@@ -155,7 +154,7 @@ GpStatus WINGDIPAPI GdipBitmapLockBits(GpBitmap* bitmap, GDIPCONST GpRect* rect,
pbmi->bmiHeader.biBitCount = bitspp; pbmi->bmiHeader.biBitCount = bitspp;
if(buff) if(buff)
GetDIBits(hdc, (HBITMAP)hbm, 0, abs_height, buff, pbmi, DIB_RGB_COLORS); GetDIBits(hdc, hbm, 0, abs_height, buff, pbmi, DIB_RGB_COLORS);
if(!bm_is_selected){ if(!bm_is_selected){
SelectObject(hdc, old); SelectObject(hdc, old);
...@@ -194,9 +193,8 @@ GpStatus WINGDIPAPI GdipBitmapLockBits(GpBitmap* bitmap, GDIPCONST GpRect* rect, ...@@ -194,9 +193,8 @@ GpStatus WINGDIPAPI GdipBitmapLockBits(GpBitmap* bitmap, GDIPCONST GpRect* rect,
GpStatus WINGDIPAPI GdipBitmapUnlockBits(GpBitmap* bitmap, GpStatus WINGDIPAPI GdipBitmapUnlockBits(GpBitmap* bitmap,
BitmapData* lockeddata) BitmapData* lockeddata)
{ {
OLE_HANDLE hbm;
HDC hdc; HDC hdc;
HBITMAP old = NULL; HBITMAP hbm, old = NULL;
BOOL bm_is_selected; BOOL bm_is_selected;
BITMAPINFO *pbmi; BITMAPINFO *pbmi;
...@@ -218,7 +216,7 @@ GpStatus WINGDIPAPI GdipBitmapUnlockBits(GpBitmap* bitmap, ...@@ -218,7 +216,7 @@ GpStatus WINGDIPAPI GdipBitmapUnlockBits(GpBitmap* bitmap,
return Ok; return Ok;
} }
IPicture_get_Handle(bitmap->image.picture, &hbm); IPicture_get_Handle(bitmap->image.picture, (OLE_HANDLE*)&hbm);
IPicture_get_CurDC(bitmap->image.picture, &hdc); IPicture_get_CurDC(bitmap->image.picture, &hdc);
bm_is_selected = (hdc != 0); bm_is_selected = (hdc != 0);
...@@ -228,12 +226,12 @@ GpStatus WINGDIPAPI GdipBitmapUnlockBits(GpBitmap* bitmap, ...@@ -228,12 +226,12 @@ GpStatus WINGDIPAPI GdipBitmapUnlockBits(GpBitmap* bitmap,
if(!bm_is_selected){ if(!bm_is_selected){
hdc = CreateCompatibleDC(0); hdc = CreateCompatibleDC(0);
old = SelectObject(hdc, (HBITMAP)hbm); old = SelectObject(hdc, hbm);
} }
GetDIBits(hdc, (HBITMAP)hbm, 0, 0, NULL, pbmi, DIB_RGB_COLORS); GetDIBits(hdc, hbm, 0, 0, NULL, pbmi, DIB_RGB_COLORS);
pbmi->bmiHeader.biBitCount = PIXELFORMATBPP(lockeddata->PixelFormat); pbmi->bmiHeader.biBitCount = PIXELFORMATBPP(lockeddata->PixelFormat);
SetDIBits(hdc, (HBITMAP)hbm, 0, abs(pbmi->bmiHeader.biHeight), SetDIBits(hdc, hbm, 0, abs(pbmi->bmiHeader.biHeight),
bitmap->bitmapbits, pbmi, DIB_RGB_COLORS); bitmap->bitmapbits, pbmi, DIB_RGB_COLORS);
if(!bm_is_selected){ if(!bm_is_selected){
...@@ -1035,7 +1033,7 @@ GpStatus WINGDIPAPI GdipLoadImageFromStream(IStream* stream, GpImage **image) ...@@ -1035,7 +1033,7 @@ GpStatus WINGDIPAPI GdipLoadImageFromStream(IStream* stream, GpImage **image)
if(type == PICTYPE_BITMAP){ if(type == PICTYPE_BITMAP){
BITMAPINFO *pbmi; BITMAPINFO *pbmi;
BITMAPCOREHEADER* bmch; BITMAPCOREHEADER* bmch;
OLE_HANDLE hbm; HBITMAP hbm;
HDC hdc; HDC hdc;
pbmi = GdipAlloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)); pbmi = GdipAlloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
...@@ -1052,7 +1050,7 @@ GpStatus WINGDIPAPI GdipLoadImageFromStream(IStream* stream, GpImage **image) ...@@ -1052,7 +1050,7 @@ GpStatus WINGDIPAPI GdipLoadImageFromStream(IStream* stream, GpImage **image)
(*((GpBitmap**) image))->height = ipicture_pixel_height(pic); (*((GpBitmap**) image))->height = ipicture_pixel_height(pic);
/* get the pixel format */ /* get the pixel format */
IPicture_get_Handle(pic, &hbm); IPicture_get_Handle(pic, (OLE_HANDLE*)&hbm);
IPicture_get_CurDC(pic, &hdc); IPicture_get_CurDC(pic, &hdc);
bmch = (BITMAPCOREHEADER*) (&pbmi->bmiHeader); bmch = (BITMAPCOREHEADER*) (&pbmi->bmiHeader);
...@@ -1061,13 +1059,13 @@ GpStatus WINGDIPAPI GdipLoadImageFromStream(IStream* stream, GpImage **image) ...@@ -1061,13 +1059,13 @@ GpStatus WINGDIPAPI GdipLoadImageFromStream(IStream* stream, GpImage **image)
if(!hdc){ if(!hdc){
HBITMAP old; HBITMAP old;
hdc = CreateCompatibleDC(0); hdc = CreateCompatibleDC(0);
old = SelectObject(hdc, (HBITMAP)hbm); old = SelectObject(hdc, hbm);
GetDIBits(hdc, (HBITMAP)hbm, 0, 0, NULL, pbmi, DIB_RGB_COLORS); GetDIBits(hdc, hbm, 0, 0, NULL, pbmi, DIB_RGB_COLORS);
SelectObject(hdc, old); SelectObject(hdc, old);
DeleteDC(hdc); DeleteDC(hdc);
} }
else else
GetDIBits(hdc, (HBITMAP)hbm, 0, 0, NULL, pbmi, DIB_RGB_COLORS); GetDIBits(hdc, hbm, 0, 0, NULL, pbmi, DIB_RGB_COLORS);
(*((GpBitmap**) image))->format = (bmch->bcBitCount << 8) | PixelFormatGDI; (*((GpBitmap**) image))->format = (bmch->bcBitCount << 8) | PixelFormatGDI;
GdipFree(pbmi); GdipFree(pbmi);
......
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