gdiplus: CreateDIBSection doesn't need a DC for the DIB_RGB_COLORS case.

This commit is contained in:
Alexandre Julliard 2012-05-02 12:02:17 +02:00
parent d2e8d44811
commit 039c85346c
3 changed files with 4 additions and 30 deletions

View File

@ -265,7 +265,6 @@ COLORREF ARGB2COLORREF(ARGB color)
HBITMAP ARGB2BMP(ARGB color)
{
HDC hdc;
BITMAPINFO bi;
HBITMAP result;
RGBQUAD *bits;
@ -273,8 +272,6 @@ HBITMAP ARGB2BMP(ARGB color)
if ((color & 0xff000000) == 0xff000000) return 0;
hdc = CreateCompatibleDC(NULL);
bi.bmiHeader.biSize = sizeof(bi.bmiHeader);
bi.bmiHeader.biWidth = 1;
bi.bmiHeader.biHeight = 1;
@ -287,15 +284,13 @@ HBITMAP ARGB2BMP(ARGB color)
bi.bmiHeader.biClrUsed = 0;
bi.bmiHeader.biClrImportant = 0;
result = CreateDIBSection(hdc, &bi, DIB_RGB_COLORS, (void*)&bits, NULL, 0);
result = CreateDIBSection(0, &bi, DIB_RGB_COLORS, (void*)&bits, NULL, 0);
bits[0].rgbReserved = alpha = (color>>24)&0xff;
bits[0].rgbRed = ((color>>16)&0xff)*alpha/255;
bits[0].rgbGreen = ((color>>8)&0xff)*alpha/255;
bits[0].rgbBlue = (color&0xff)*alpha/255;
DeleteDC(hdc);
return result;
}

View File

@ -131,15 +131,10 @@ static COLORREF get_gdi_brush_color(const GpBrush *brush)
static HBITMAP create_hatch_bitmap(const GpHatch *hatch)
{
HBITMAP hbmp;
HDC hdc;
BITMAPINFOHEADER bmih;
DWORD *bits;
int x, y;
hdc = CreateCompatibleDC(0);
if (!hdc) return 0;
bmih.biSize = sizeof(bmih);
bmih.biWidth = 8;
bmih.biHeight = 8;
@ -148,7 +143,7 @@ static HBITMAP create_hatch_bitmap(const GpHatch *hatch)
bmih.biCompression = BI_RGB;
bmih.biSizeImage = 0;
hbmp = CreateDIBSection(hdc, (BITMAPINFO *)&bmih, DIB_RGB_COLORS, (void **)&bits, NULL, 0);
hbmp = CreateDIBSection(0, (BITMAPINFO *)&bmih, DIB_RGB_COLORS, (void **)&bits, NULL, 0);
if (hbmp)
{
const char *hatch_data;
@ -175,7 +170,6 @@ static HBITMAP create_hatch_bitmap(const GpHatch *hatch)
}
}
DeleteDC(hdc);
return hbmp;
}

View File

@ -1372,7 +1372,6 @@ GpStatus WINGDIPAPI GdipCreateHBITMAPFromBitmap(GpBitmap* bitmap,
GpStatus stat;
HBITMAP result;
UINT width, height;
HDC hdc;
BITMAPINFOHEADER bih;
LPBYTE bits;
BitmapData lockeddata;
@ -1395,11 +1394,7 @@ GpStatus WINGDIPAPI GdipCreateHBITMAPFromBitmap(GpBitmap* bitmap,
bih.biClrUsed = 0;
bih.biClrImportant = 0;
hdc = CreateCompatibleDC(NULL);
if (!hdc) return GenericError;
result = CreateDIBSection(hdc, (BITMAPINFO*)&bih, DIB_RGB_COLORS, (void**)&bits,
NULL, 0);
result = CreateDIBSection(0, (BITMAPINFO*)&bih, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
if (result)
{
@ -1415,8 +1410,6 @@ GpStatus WINGDIPAPI GdipCreateHBITMAPFromBitmap(GpBitmap* bitmap,
else
stat = GenericError;
DeleteDC(hdc);
if (stat != Ok && result)
{
DeleteObject(result);
@ -1694,7 +1687,6 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride,
BITMAPINFO* pbmi;
HBITMAP hbitmap=NULL;
INT row_size, dib_stride;
HDC hdc;
BYTE *bits=NULL, *own_bits=NULL;
REAL xres, yres;
GpStatus stat;
@ -1739,15 +1731,8 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride,
pbmi->bmiHeader.biClrUsed = 0;
pbmi->bmiHeader.biClrImportant = 0;
hdc = CreateCompatibleDC(NULL);
if (!hdc) {
GdipFree(pbmi);
return GenericError;
}
hbitmap = CreateDIBSection(0, pbmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
hbitmap = CreateDIBSection(hdc, pbmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
DeleteDC(hdc);
GdipFree(pbmi);
if (!hbitmap) return GenericError;