gdi32: Reject invalid DIB depths in CreateDIBSection.

This commit is contained in:
Alexandre Julliard 2010-07-20 14:28:51 +02:00
parent 21ced8ddc8
commit 811cdfaf27
3 changed files with 36 additions and 28 deletions

View File

@ -1261,11 +1261,10 @@ HBITMAP WINAPI CreateDIBSection(HDC hdc, CONST BITMAPINFO *bmi, UINT usage,
case 8: case 8:
case 24: case 24:
if (compression == BI_RGB) break; if (compression == BI_RGB) break;
/* fall through */
default:
WARN( "invalid %u bpp compression %u\n", bpp, compression ); WARN( "invalid %u bpp compression %u\n", bpp, compression );
return 0; return 0;
default:
FIXME( "should fail %u bpp compression %u\n", bpp, compression );
break;
} }
if (!(dib = HeapAlloc( GetProcessHeap(), 0, sizeof(*dib) ))) return 0; if (!(dib = HeapAlloc( GetProcessHeap(), 0, sizeof(*dib) ))) return 0;

View File

@ -554,7 +554,7 @@ static void test_dibsections(void)
if (i == 1 || i == 4 || i == 8 || i == 16 || i == 24 || i == 32) if (i == 1 || i == 4 || i == 8 || i == 16 || i == 24 || i == 32)
ok(hdib != NULL, "CreateDIBSection bpp %u\n", i); ok(hdib != NULL, "CreateDIBSection bpp %u\n", i);
else else
todo_wine ok(hdib == NULL, "CreateDIBSection bpp %u succeeded\n", i); ok(hdib == NULL, "CreateDIBSection bpp %u succeeded\n", i);
if (hdib) DeleteObject( hdib ); if (hdib) DeleteObject( hdib );
} }

View File

@ -2346,34 +2346,43 @@ static void test_GdipGetNearestColor(void)
GdipDisposeImage((GpImage*)bitmap); GdipDisposeImage((GpImage*)bitmap);
status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat48bppRGB, NULL, &bitmap); status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat48bppRGB, NULL, &bitmap);
expect(Ok, status); todo_wine expect(Ok, status);
status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics); if (status == Ok)
expect(Ok, status); {
status = GdipGetNearestColor(graphics, &color); status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
expect(Ok, status); expect(Ok, status);
expect(0xdeadbeef, color); status = GdipGetNearestColor(graphics, &color);
GdipDeleteGraphics(graphics); expect(Ok, status);
GdipDisposeImage((GpImage*)bitmap); expect(0xdeadbeef, color);
GdipDeleteGraphics(graphics);
GdipDisposeImage((GpImage*)bitmap);
}
status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppARGB, NULL, &bitmap); status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppARGB, NULL, &bitmap);
expect(Ok, status); todo_wine expect(Ok, status);
status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics); if (status == Ok)
expect(Ok, status); {
status = GdipGetNearestColor(graphics, &color); status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
expect(Ok, status); expect(Ok, status);
expect(0xdeadbeef, color); status = GdipGetNearestColor(graphics, &color);
GdipDeleteGraphics(graphics); expect(Ok, status);
GdipDisposeImage((GpImage*)bitmap); expect(0xdeadbeef, color);
GdipDeleteGraphics(graphics);
GdipDisposeImage((GpImage*)bitmap);
}
status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppPARGB, NULL, &bitmap); status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppPARGB, NULL, &bitmap);
expect(Ok, status); todo_wine expect(Ok, status);
status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics); if (status == Ok)
expect(Ok, status); {
status = GdipGetNearestColor(graphics, &color); status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
expect(Ok, status); expect(Ok, status);
expect(0xdeadbeef, color); status = GdipGetNearestColor(graphics, &color);
GdipDeleteGraphics(graphics); expect(Ok, status);
GdipDisposeImage((GpImage*)bitmap); expect(0xdeadbeef, color);
GdipDeleteGraphics(graphics);
GdipDisposeImage((GpImage*)bitmap);
}
status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB565, NULL, &bitmap); status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB565, NULL, &bitmap);
expect(Ok, status); expect(Ok, status);