mirror of
https://github.com/reactos/reactos.git
synced 2025-02-21 16:04:57 +00:00
[GDIPLUS_WINETEST]
sync gdiplus_winetest to wine 1.1.39 svn path=/trunk/; revision=45830
This commit is contained in:
parent
d8bd52c185
commit
efe0d1d255
2 changed files with 555 additions and 9 deletions
|
@ -30,6 +30,18 @@
|
|||
#define expect(expected, got) ok((UINT)(got) == (UINT)(expected), "Expected %.8x, got %.8x\n", (UINT)(expected), (UINT)(got))
|
||||
#define expectf(expected, got) ok(fabs(expected - got) < 0.0001, "Expected %.2f, got %.2f\n", expected, got)
|
||||
|
||||
static BOOL color_match(ARGB c1, ARGB c2, BYTE max_diff)
|
||||
{
|
||||
if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE;
|
||||
c1 >>= 8; c2 >>= 8;
|
||||
if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE;
|
||||
c1 >>= 8; c2 >>= 8;
|
||||
if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE;
|
||||
c1 >>= 8; c2 >>= 8;
|
||||
if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void expect_guid(REFGUID expected, REFGUID got, int line, BOOL todo)
|
||||
{
|
||||
WCHAR bufferW[39];
|
||||
|
@ -64,7 +76,7 @@ static void test_bufferrawformat(void* buff, int size, REFGUID expected, int lin
|
|||
LPBYTE data;
|
||||
HRESULT hres;
|
||||
GpStatus stat;
|
||||
GpBitmap *bmp;
|
||||
GpImage *img;
|
||||
|
||||
hglob = GlobalAlloc (0, size);
|
||||
data = GlobalLock (hglob);
|
||||
|
@ -75,16 +87,16 @@ static void test_bufferrawformat(void* buff, int size, REFGUID expected, int lin
|
|||
ok_(__FILE__, line)(hres == S_OK, "Failed to create a stream\n");
|
||||
if(hres != S_OK) return;
|
||||
|
||||
stat = GdipCreateBitmapFromStream(stream, &bmp);
|
||||
stat = GdipLoadImageFromStream(stream, &img);
|
||||
ok_(__FILE__, line)(stat == Ok, "Failed to create a Bitmap\n");
|
||||
if(stat != Ok){
|
||||
IStream_Release(stream);
|
||||
return;
|
||||
}
|
||||
|
||||
expect_rawformat(expected, (GpImage*)bmp, line, todo);
|
||||
expect_rawformat(expected, img, line, todo);
|
||||
|
||||
GdipDisposeImage((GpImage*)bmp);
|
||||
GdipDisposeImage(img);
|
||||
IStream_Release(stream);
|
||||
}
|
||||
|
||||
|
@ -206,7 +218,13 @@ static void test_GdipImageGetFrameDimensionsCount(void)
|
|||
|
||||
stat = GdipImageGetFrameDimensionsList((GpImage*)bm, &dimension, 1);
|
||||
expect(Ok, stat);
|
||||
expect_guid(&FrameDimensionPage, &dimension, __LINE__, TRUE);
|
||||
expect_guid(&FrameDimensionPage, &dimension, __LINE__, FALSE);
|
||||
|
||||
stat = GdipImageGetFrameDimensionsList((GpImage*)bm, &dimension, 2);
|
||||
expect(InvalidParameter, stat);
|
||||
|
||||
stat = GdipImageGetFrameDimensionsList((GpImage*)bm, &dimension, 0);
|
||||
expect(InvalidParameter, stat);
|
||||
|
||||
count = 12345;
|
||||
stat = GdipImageGetFrameCount((GpImage*)bm, &dimension, &count);
|
||||
|
@ -512,6 +530,7 @@ static void test_GdipCreateBitmapFromHBITMAP(void)
|
|||
GdipDisposeImage((GpImage*)gpbm);
|
||||
DeleteObject(hbm);
|
||||
|
||||
memset(buff, 0, sizeof(buff));
|
||||
hbm = CreateBitmap(WIDTH2, HEIGHT2, 1, 1, &buff);
|
||||
stat = GdipCreateBitmapFromHBITMAP(hbm, NULL, &gpbm);
|
||||
expect(Ok, stat);
|
||||
|
@ -774,12 +793,176 @@ static const unsigned char jpgimage[285] = {
|
|||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xda,0x00,0x0c,0x03,0x01,
|
||||
0x00,0x02,0x11,0x03,0x11,0x00,0x3f,0x00,0xb2,0xc0,0x07,0xff,0xd9
|
||||
};
|
||||
/* 320x320 twip wmf */
|
||||
static const unsigned char wmfimage[180] = {
|
||||
0xd7,0xcd,0xc6,0x9a,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x01,0x40,0x01,0xa0,0x05,
|
||||
0x00,0x00,0x00,0x00,0xb1,0x52,0x01,0x00,0x09,0x00,0x00,0x03,0x4f,0x00,0x00,0x00,
|
||||
0x0f,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x0b,0x02,0x00,0x00,
|
||||
0x00,0x00,0x05,0x00,0x00,0x00,0x0c,0x02,0x40,0x01,0x40,0x01,0x04,0x00,0x00,0x00,
|
||||
0x02,0x01,0x01,0x00,0x04,0x00,0x00,0x00,0x04,0x01,0x0d,0x00,0x08,0x00,0x00,0x00,
|
||||
0xfa,0x02,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
|
||||
0x2d,0x01,0x00,0x00,0x07,0x00,0x00,0x00,0xfc,0x02,0x01,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x04,0x00,0x00,0x00,0x2d,0x01,0x01,0x00,0x07,0x00,0x00,0x00,0xfc,0x02,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x2d,0x01,0x02,0x00,
|
||||
0x07,0x00,0x00,0x00,0x1b,0x04,0x40,0x01,0x40,0x01,0x00,0x00,0x00,0x00,0x04,0x00,
|
||||
0x00,0x00,0xf0,0x01,0x00,0x00,0x04,0x00,0x00,0x00,0xf0,0x01,0x01,0x00,0x03,0x00,
|
||||
0x00,0x00,0x00,0x00
|
||||
};
|
||||
static void test_getrawformat(void)
|
||||
{
|
||||
test_bufferrawformat((void*)pngimage, sizeof(pngimage), &ImageFormatPNG, __LINE__, FALSE);
|
||||
test_bufferrawformat((void*)gifimage, sizeof(gifimage), &ImageFormatGIF, __LINE__, FALSE);
|
||||
test_bufferrawformat((void*)bmpimage, sizeof(bmpimage), &ImageFormatBMP, __LINE__, FALSE);
|
||||
test_bufferrawformat((void*)jpgimage, sizeof(jpgimage), &ImageFormatJPEG, __LINE__, FALSE);
|
||||
test_bufferrawformat((void*)wmfimage, sizeof(wmfimage), &ImageFormatWMF, __LINE__, FALSE);
|
||||
}
|
||||
|
||||
static void test_loadwmf(void)
|
||||
{
|
||||
LPSTREAM stream;
|
||||
HGLOBAL hglob;
|
||||
LPBYTE data;
|
||||
HRESULT hres;
|
||||
GpStatus stat;
|
||||
GpImage *img;
|
||||
GpRectF bounds;
|
||||
GpUnit unit;
|
||||
REAL res = 12345.0;
|
||||
|
||||
hglob = GlobalAlloc (0, sizeof(wmfimage));
|
||||
data = GlobalLock (hglob);
|
||||
memcpy(data, wmfimage, sizeof(wmfimage));
|
||||
GlobalUnlock(hglob); data = NULL;
|
||||
|
||||
hres = CreateStreamOnHGlobal(hglob, TRUE, &stream);
|
||||
ok(hres == S_OK, "Failed to create a stream\n");
|
||||
if(hres != S_OK) return;
|
||||
|
||||
stat = GdipLoadImageFromStream(stream, &img);
|
||||
ok(stat == Ok, "Failed to create a Bitmap\n");
|
||||
if(stat != Ok){
|
||||
IStream_Release(stream);
|
||||
return;
|
||||
}
|
||||
|
||||
IStream_Release(stream);
|
||||
|
||||
stat = GdipGetImageBounds(img, &bounds, &unit);
|
||||
expect(Ok, stat);
|
||||
todo_wine expect(UnitPixel, unit);
|
||||
expectf(0.0, bounds.X);
|
||||
expectf(0.0, bounds.Y);
|
||||
todo_wine expectf(320.0, bounds.Width);
|
||||
todo_wine expectf(320.0, bounds.Height);
|
||||
|
||||
stat = GdipGetImageHorizontalResolution(img, &res);
|
||||
expect(Ok, stat);
|
||||
todo_wine expectf(1440.0, res);
|
||||
|
||||
stat = GdipGetImageVerticalResolution(img, &res);
|
||||
expect(Ok, stat);
|
||||
todo_wine expectf(1440.0, res);
|
||||
|
||||
GdipDisposeImage(img);
|
||||
}
|
||||
|
||||
static void test_createfromwmf(void)
|
||||
{
|
||||
HMETAFILE hwmf;
|
||||
GpImage *img;
|
||||
GpStatus stat;
|
||||
GpRectF bounds;
|
||||
GpUnit unit;
|
||||
REAL res = 12345.0;
|
||||
|
||||
hwmf = SetMetaFileBitsEx(sizeof(wmfimage)-sizeof(WmfPlaceableFileHeader),
|
||||
wmfimage+sizeof(WmfPlaceableFileHeader));
|
||||
ok(hwmf != 0, "SetMetaFileBitsEx failed\n");
|
||||
|
||||
stat = GdipCreateMetafileFromWmf(hwmf, TRUE,
|
||||
(WmfPlaceableFileHeader*)wmfimage, (GpMetafile**)&img);
|
||||
expect(Ok, stat);
|
||||
|
||||
stat = GdipGetImageBounds(img, &bounds, &unit);
|
||||
expect(Ok, stat);
|
||||
todo_wine expect(UnitPixel, unit);
|
||||
expectf(0.0, bounds.X);
|
||||
expectf(0.0, bounds.Y);
|
||||
todo_wine expectf(320.0, bounds.Width);
|
||||
todo_wine expectf(320.0, bounds.Height);
|
||||
|
||||
stat = GdipGetImageHorizontalResolution(img, &res);
|
||||
expect(Ok, stat);
|
||||
expectf(1440.0, res);
|
||||
|
||||
stat = GdipGetImageVerticalResolution(img, &res);
|
||||
expect(Ok, stat);
|
||||
expectf(1440.0, res);
|
||||
|
||||
GdipDisposeImage(img);
|
||||
}
|
||||
|
||||
static void test_resolution(void)
|
||||
{
|
||||
GpStatus stat;
|
||||
GpBitmap *bitmap;
|
||||
REAL res=-1.0;
|
||||
HDC screendc;
|
||||
int screenxres, screenyres;
|
||||
|
||||
/* create Bitmap */
|
||||
stat = GdipCreateBitmapFromScan0(1, 1, 32, PixelFormat24bppRGB, NULL, &bitmap);
|
||||
expect(Ok, stat);
|
||||
|
||||
/* test invalid values */
|
||||
stat = GdipGetImageHorizontalResolution(NULL, &res);
|
||||
expect(InvalidParameter, stat);
|
||||
|
||||
stat = GdipGetImageHorizontalResolution((GpImage*)bitmap, NULL);
|
||||
expect(InvalidParameter, stat);
|
||||
|
||||
stat = GdipGetImageVerticalResolution(NULL, &res);
|
||||
expect(InvalidParameter, stat);
|
||||
|
||||
stat = GdipGetImageVerticalResolution((GpImage*)bitmap, NULL);
|
||||
expect(InvalidParameter, stat);
|
||||
|
||||
stat = GdipBitmapSetResolution(NULL, 96.0, 96.0);
|
||||
expect(InvalidParameter, stat);
|
||||
|
||||
stat = GdipBitmapSetResolution(bitmap, 0.0, 0.0);
|
||||
expect(InvalidParameter, stat);
|
||||
|
||||
/* defaults to screen resolution */
|
||||
screendc = GetDC(0);
|
||||
|
||||
screenxres = GetDeviceCaps(screendc, LOGPIXELSX);
|
||||
screenyres = GetDeviceCaps(screendc, LOGPIXELSY);
|
||||
|
||||
ReleaseDC(0, screendc);
|
||||
|
||||
stat = GdipGetImageHorizontalResolution((GpImage*)bitmap, &res);
|
||||
expect(Ok, stat);
|
||||
expectf((REAL)screenxres, res);
|
||||
|
||||
stat = GdipGetImageVerticalResolution((GpImage*)bitmap, &res);
|
||||
expect(Ok, stat);
|
||||
expectf((REAL)screenyres, res);
|
||||
|
||||
/* test changing the resolution */
|
||||
stat = GdipBitmapSetResolution(bitmap, screenxres*2.0, screenyres*3.0);
|
||||
expect(Ok, stat);
|
||||
|
||||
stat = GdipGetImageHorizontalResolution((GpImage*)bitmap, &res);
|
||||
expect(Ok, stat);
|
||||
expectf(screenxres*2.0, res);
|
||||
|
||||
stat = GdipGetImageVerticalResolution((GpImage*)bitmap, &res);
|
||||
expect(Ok, stat);
|
||||
expectf(screenyres*3.0, res);
|
||||
|
||||
stat = GdipDisposeImage((GpImage*)bitmap);
|
||||
expect(Ok, stat);
|
||||
}
|
||||
|
||||
static void test_createhbitmap(void)
|
||||
|
@ -963,6 +1146,7 @@ static void test_palette(void)
|
|||
INT size;
|
||||
BYTE buffer[1040];
|
||||
ColorPalette *palette=(ColorPalette*)buffer;
|
||||
ARGB color=0;
|
||||
|
||||
/* test initial palette from non-indexed bitmap */
|
||||
stat = GdipCreateBitmapFromScan0(2, 2, 8, PixelFormat32bppRGB, NULL, &bitmap);
|
||||
|
@ -1008,6 +1192,22 @@ static void test_palette(void)
|
|||
expect(0xff000000, palette->Entries[0]);
|
||||
expect(0xffffffff, palette->Entries[1]);
|
||||
|
||||
/* test getting/setting pixels */
|
||||
stat = GdipBitmapGetPixel(bitmap, 0, 0, &color);
|
||||
expect(Ok, stat);
|
||||
expect(0xff000000, color);
|
||||
|
||||
stat = GdipBitmapSetPixel(bitmap, 0, 1, 0xffffffff);
|
||||
todo_wine ok((stat == Ok) ||
|
||||
broken(stat == InvalidParameter) /* pre-win7 */, "stat=%.8x\n", stat);
|
||||
|
||||
if (stat == Ok)
|
||||
{
|
||||
stat = GdipBitmapGetPixel(bitmap, 0, 1, &color);
|
||||
expect(Ok, stat);
|
||||
expect(0xffffffff, color);
|
||||
}
|
||||
|
||||
GdipDisposeImage((GpImage*)bitmap);
|
||||
|
||||
/* test initial palette on 4-bit bitmap */
|
||||
|
@ -1025,6 +1225,22 @@ static void test_palette(void)
|
|||
|
||||
check_halftone_palette(palette);
|
||||
|
||||
/* test getting/setting pixels */
|
||||
stat = GdipBitmapGetPixel(bitmap, 0, 0, &color);
|
||||
expect(Ok, stat);
|
||||
expect(0xff000000, color);
|
||||
|
||||
stat = GdipBitmapSetPixel(bitmap, 0, 1, 0xffff00ff);
|
||||
todo_wine ok((stat == Ok) ||
|
||||
broken(stat == InvalidParameter) /* pre-win7 */, "stat=%.8x\n", stat);
|
||||
|
||||
if (stat == Ok)
|
||||
{
|
||||
stat = GdipBitmapGetPixel(bitmap, 0, 1, &color);
|
||||
expect(Ok, stat);
|
||||
expect(0xffff00ff, color);
|
||||
}
|
||||
|
||||
GdipDisposeImage((GpImage*)bitmap);
|
||||
|
||||
/* test initial palette on 8-bit bitmap */
|
||||
|
@ -1042,6 +1258,22 @@ static void test_palette(void)
|
|||
|
||||
check_halftone_palette(palette);
|
||||
|
||||
/* test getting/setting pixels */
|
||||
stat = GdipBitmapGetPixel(bitmap, 0, 0, &color);
|
||||
expect(Ok, stat);
|
||||
expect(0xff000000, color);
|
||||
|
||||
stat = GdipBitmapSetPixel(bitmap, 0, 1, 0xffcccccc);
|
||||
todo_wine ok((stat == Ok) ||
|
||||
broken(stat == InvalidParameter) /* pre-win7 */, "stat=%.8x\n", stat);
|
||||
|
||||
if (stat == Ok)
|
||||
{
|
||||
stat = GdipBitmapGetPixel(bitmap, 0, 1, &color);
|
||||
expect(Ok, stat);
|
||||
expect(0xffcccccc, color);
|
||||
}
|
||||
|
||||
/* test setting/getting a different palette */
|
||||
palette->Entries[1] = 0xffcccccc;
|
||||
|
||||
|
@ -1092,6 +1324,307 @@ static void test_palette(void)
|
|||
GdipDisposeImage((GpImage*)bitmap);
|
||||
}
|
||||
|
||||
static void test_colormatrix(void)
|
||||
{
|
||||
GpStatus stat;
|
||||
ColorMatrix colormatrix, graymatrix;
|
||||
GpImageAttributes *imageattr;
|
||||
const ColorMatrix identity = {{
|
||||
{1.0,0.0,0.0,0.0,0.0},
|
||||
{0.0,1.0,0.0,0.0,0.0},
|
||||
{0.0,0.0,1.0,0.0,0.0},
|
||||
{0.0,0.0,0.0,1.0,0.0},
|
||||
{0.0,0.0,0.0,0.0,1.0}}};
|
||||
const ColorMatrix double_red = {{
|
||||
{2.0,0.0,0.0,0.0,0.0},
|
||||
{0.0,1.0,0.0,0.0,0.0},
|
||||
{0.0,0.0,1.0,0.0,0.0},
|
||||
{0.0,0.0,0.0,1.0,0.0},
|
||||
{0.0,0.0,0.0,0.0,1.0}}};
|
||||
GpBitmap *bitmap1, *bitmap2;
|
||||
GpGraphics *graphics;
|
||||
ARGB color;
|
||||
|
||||
colormatrix = identity;
|
||||
graymatrix = identity;
|
||||
|
||||
stat = GdipSetImageAttributesColorMatrix(NULL, ColorAdjustTypeDefault,
|
||||
TRUE, &colormatrix, &graymatrix, ColorMatrixFlagsDefault);
|
||||
expect(InvalidParameter, stat);
|
||||
|
||||
stat = GdipCreateImageAttributes(&imageattr);
|
||||
expect(Ok, stat);
|
||||
|
||||
stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeDefault,
|
||||
TRUE, &colormatrix, NULL, ColorMatrixFlagsDefault);
|
||||
expect(Ok, stat);
|
||||
|
||||
stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeDefault,
|
||||
TRUE, NULL, NULL, ColorMatrixFlagsDefault);
|
||||
expect(InvalidParameter, stat);
|
||||
|
||||
stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeDefault,
|
||||
TRUE, &colormatrix, &graymatrix, ColorMatrixFlagsDefault);
|
||||
expect(Ok, stat);
|
||||
|
||||
stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeDefault,
|
||||
TRUE, &colormatrix, NULL, ColorMatrixFlagsSkipGrays);
|
||||
expect(Ok, stat);
|
||||
|
||||
stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeDefault,
|
||||
TRUE, &colormatrix, NULL, ColorMatrixFlagsAltGray);
|
||||
expect(InvalidParameter, stat);
|
||||
|
||||
stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeDefault,
|
||||
TRUE, &colormatrix, &graymatrix, ColorMatrixFlagsAltGray);
|
||||
expect(Ok, stat);
|
||||
|
||||
stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeDefault,
|
||||
TRUE, &colormatrix, &graymatrix, 3);
|
||||
expect(InvalidParameter, stat);
|
||||
|
||||
stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeCount,
|
||||
TRUE, &colormatrix, &graymatrix, ColorMatrixFlagsDefault);
|
||||
expect(InvalidParameter, stat);
|
||||
|
||||
stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeAny,
|
||||
TRUE, &colormatrix, &graymatrix, ColorMatrixFlagsDefault);
|
||||
expect(InvalidParameter, stat);
|
||||
|
||||
stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeDefault,
|
||||
FALSE, NULL, NULL, ColorMatrixFlagsDefault);
|
||||
expect(Ok, stat);
|
||||
|
||||
/* Drawing a bitmap transforms the colors */
|
||||
colormatrix = double_red;
|
||||
stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeDefault,
|
||||
TRUE, &colormatrix, NULL, ColorMatrixFlagsDefault);
|
||||
expect(Ok, stat);
|
||||
|
||||
stat = GdipCreateBitmapFromScan0(1, 1, 0, PixelFormat32bppRGB, NULL, &bitmap1);
|
||||
expect(Ok, stat);
|
||||
|
||||
stat = GdipCreateBitmapFromScan0(1, 1, 0, PixelFormat32bppRGB, NULL, &bitmap2);
|
||||
expect(Ok, stat);
|
||||
|
||||
stat = GdipBitmapSetPixel(bitmap1, 0, 0, 0xff40ffff);
|
||||
expect(Ok, stat);
|
||||
|
||||
stat = GdipGetImageGraphicsContext((GpImage*)bitmap2, &graphics);
|
||||
expect(Ok, stat);
|
||||
|
||||
stat = GdipDrawImageRectRectI(graphics, (GpImage*)bitmap1, 0,0,1,1, 0,0,1,1,
|
||||
UnitPixel, imageattr, NULL, NULL);
|
||||
expect(Ok, stat);
|
||||
|
||||
stat = GdipBitmapGetPixel(bitmap2, 0, 0, &color);
|
||||
expect(Ok, stat);
|
||||
todo_wine expect(0xff80ffff, color);
|
||||
|
||||
GdipDeleteGraphics(graphics);
|
||||
GdipDisposeImage((GpImage*)bitmap1);
|
||||
GdipDisposeImage((GpImage*)bitmap2);
|
||||
GdipDisposeImageAttributes(imageattr);
|
||||
}
|
||||
|
||||
static void test_gamma(void)
|
||||
{
|
||||
GpStatus stat;
|
||||
GpImageAttributes *imageattr;
|
||||
GpBitmap *bitmap1, *bitmap2;
|
||||
GpGraphics *graphics;
|
||||
ARGB color;
|
||||
|
||||
stat = GdipSetImageAttributesGamma(NULL, ColorAdjustTypeDefault, TRUE, 1.0);
|
||||
expect(InvalidParameter, stat);
|
||||
|
||||
stat = GdipCreateImageAttributes(&imageattr);
|
||||
expect(Ok, stat);
|
||||
|
||||
stat = GdipSetImageAttributesGamma(imageattr, ColorAdjustTypeDefault, TRUE, 1.0);
|
||||
expect(Ok, stat);
|
||||
|
||||
stat = GdipSetImageAttributesGamma(imageattr, ColorAdjustTypeAny, TRUE, 1.0);
|
||||
expect(InvalidParameter, stat);
|
||||
|
||||
stat = GdipSetImageAttributesGamma(imageattr, ColorAdjustTypeDefault, TRUE, -1.0);
|
||||
expect(InvalidParameter, stat);
|
||||
|
||||
stat = GdipSetImageAttributesGamma(imageattr, ColorAdjustTypeDefault, TRUE, 0.0);
|
||||
expect(InvalidParameter, stat);
|
||||
|
||||
stat = GdipSetImageAttributesGamma(imageattr, ColorAdjustTypeDefault, TRUE, 0.5);
|
||||
expect(Ok, stat);
|
||||
|
||||
stat = GdipSetImageAttributesGamma(imageattr, ColorAdjustTypeDefault, FALSE, 0.0);
|
||||
expect(Ok, stat);
|
||||
|
||||
/* Drawing a bitmap transforms the colors */
|
||||
stat = GdipSetImageAttributesGamma(imageattr, ColorAdjustTypeDefault, TRUE, 3.0);
|
||||
expect(Ok, stat);
|
||||
|
||||
stat = GdipCreateBitmapFromScan0(1, 1, 0, PixelFormat32bppRGB, NULL, &bitmap1);
|
||||
expect(Ok, stat);
|
||||
|
||||
stat = GdipCreateBitmapFromScan0(1, 1, 0, PixelFormat32bppRGB, NULL, &bitmap2);
|
||||
expect(Ok, stat);
|
||||
|
||||
stat = GdipBitmapSetPixel(bitmap1, 0, 0, 0xff80ffff);
|
||||
expect(Ok, stat);
|
||||
|
||||
stat = GdipGetImageGraphicsContext((GpImage*)bitmap2, &graphics);
|
||||
expect(Ok, stat);
|
||||
|
||||
stat = GdipDrawImageRectRectI(graphics, (GpImage*)bitmap1, 0,0,1,1, 0,0,1,1,
|
||||
UnitPixel, imageattr, NULL, NULL);
|
||||
expect(Ok, stat);
|
||||
|
||||
stat = GdipBitmapGetPixel(bitmap2, 0, 0, &color);
|
||||
expect(Ok, stat);
|
||||
todo_wine ok(color_match(0xff20ffff, color, 1), "Expected ff20ffff, got %.8x\n", color);
|
||||
|
||||
GdipDeleteGraphics(graphics);
|
||||
GdipDisposeImage((GpImage*)bitmap1);
|
||||
GdipDisposeImage((GpImage*)bitmap2);
|
||||
GdipDisposeImageAttributes(imageattr);
|
||||
}
|
||||
|
||||
/* 1x1 pixel gif, 2 frames; first frame is white, second is black */
|
||||
static const unsigned char gifanimation[72] = {
|
||||
0x47,0x49,0x46,0x38,0x39,0x61,0x01,0x00,0x01,0x00,0xa1,0x00,0x00,0x00,0x00,0x00,
|
||||
0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x21,0xf9,0x04,0x00,0x0a,0x00,0xff,
|
||||
0x00,0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x02,0x02,0x4c,0x01,0x00,
|
||||
0x21,0xf9,0x04,0x01,0x0a,0x00,0x01,0x00,0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x01,
|
||||
0x00,0x00,0x02,0x02,0x44,0x01,0x00,0x3b
|
||||
};
|
||||
|
||||
static void test_multiframegif(void)
|
||||
{
|
||||
LPSTREAM stream;
|
||||
HGLOBAL hglob;
|
||||
LPBYTE data;
|
||||
HRESULT hres;
|
||||
GpStatus stat;
|
||||
GpBitmap *bmp;
|
||||
ARGB color;
|
||||
UINT count;
|
||||
GUID dimension;
|
||||
|
||||
/* Test frame functions with an animated GIF */
|
||||
hglob = GlobalAlloc (0, sizeof(gifanimation));
|
||||
data = GlobalLock (hglob);
|
||||
memcpy(data, gifanimation, sizeof(gifanimation));
|
||||
GlobalUnlock(hglob);
|
||||
|
||||
hres = CreateStreamOnHGlobal(hglob, TRUE, &stream);
|
||||
ok(hres == S_OK, "Failed to create a stream\n");
|
||||
if(hres != S_OK) return;
|
||||
|
||||
stat = GdipCreateBitmapFromStream(stream, &bmp);
|
||||
ok(stat == Ok, "Failed to create a Bitmap\n");
|
||||
if(stat != Ok){
|
||||
IStream_Release(stream);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Bitmap starts at frame 0 */
|
||||
color = 0xdeadbeef;
|
||||
stat = GdipBitmapGetPixel(bmp, 0, 0, &color);
|
||||
expect(Ok, stat);
|
||||
expect(0xffffffff, color);
|
||||
|
||||
/* Check that we get correct metadata */
|
||||
stat = GdipImageGetFrameDimensionsCount((GpImage*)bmp,&count);
|
||||
expect(Ok, stat);
|
||||
expect(1, count);
|
||||
|
||||
stat = GdipImageGetFrameDimensionsList((GpImage*)bmp, &dimension, 1);
|
||||
expect(Ok, stat);
|
||||
expect_guid(&FrameDimensionTime, &dimension, __LINE__, FALSE);
|
||||
|
||||
count = 12345;
|
||||
stat = GdipImageGetFrameCount((GpImage*)bmp, &dimension, &count);
|
||||
todo_wine expect(Ok, stat);
|
||||
todo_wine expect(2, count);
|
||||
|
||||
/* SelectActiveFrame overwrites our current data */
|
||||
stat = GdipImageSelectActiveFrame((GpImage*)bmp, &dimension, 1);
|
||||
expect(Ok, stat);
|
||||
|
||||
color = 0xdeadbeef;
|
||||
GdipBitmapGetPixel(bmp, 0, 0, &color);
|
||||
expect(Ok, stat);
|
||||
todo_wine expect(0xff000000, color);
|
||||
|
||||
stat = GdipImageSelectActiveFrame((GpImage*)bmp, &dimension, 0);
|
||||
expect(Ok, stat);
|
||||
|
||||
color = 0xdeadbeef;
|
||||
GdipBitmapGetPixel(bmp, 0, 0, &color);
|
||||
expect(Ok, stat);
|
||||
expect(0xffffffff, color);
|
||||
|
||||
/* Write over the image data */
|
||||
stat = GdipBitmapSetPixel(bmp, 0, 0, 0xff000000);
|
||||
expect(Ok, stat);
|
||||
|
||||
/* Switching to the same frame does not overwrite our changes */
|
||||
stat = GdipImageSelectActiveFrame((GpImage*)bmp, &dimension, 0);
|
||||
expect(Ok, stat);
|
||||
|
||||
stat = GdipBitmapGetPixel(bmp, 0, 0, &color);
|
||||
expect(Ok, stat);
|
||||
expect(0xff000000, color);
|
||||
|
||||
/* But switching to another frame and back does */
|
||||
stat = GdipImageSelectActiveFrame((GpImage*)bmp, &dimension, 1);
|
||||
expect(Ok, stat);
|
||||
|
||||
stat = GdipImageSelectActiveFrame((GpImage*)bmp, &dimension, 0);
|
||||
expect(Ok, stat);
|
||||
|
||||
stat = GdipBitmapGetPixel(bmp, 0, 0, &color);
|
||||
expect(Ok, stat);
|
||||
todo_wine expect(0xffffffff, color);
|
||||
|
||||
GdipDisposeImage((GpImage*)bmp);
|
||||
IStream_Release(stream);
|
||||
|
||||
/* Test with a non-animated gif */
|
||||
hglob = GlobalAlloc (0, sizeof(gifimage));
|
||||
data = GlobalLock (hglob);
|
||||
memcpy(data, gifimage, sizeof(gifimage));
|
||||
GlobalUnlock(hglob);
|
||||
|
||||
hres = CreateStreamOnHGlobal(hglob, TRUE, &stream);
|
||||
ok(hres == S_OK, "Failed to create a stream\n");
|
||||
if(hres != S_OK) return;
|
||||
|
||||
stat = GdipCreateBitmapFromStream(stream, &bmp);
|
||||
ok(stat == Ok, "Failed to create a Bitmap\n");
|
||||
if(stat != Ok){
|
||||
IStream_Release(stream);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Check metadata */
|
||||
stat = GdipImageGetFrameDimensionsCount((GpImage*)bmp,&count);
|
||||
expect(Ok, stat);
|
||||
expect(1, count);
|
||||
|
||||
stat = GdipImageGetFrameDimensionsList((GpImage*)bmp, &dimension, 1);
|
||||
expect(Ok, stat);
|
||||
expect_guid(&FrameDimensionTime, &dimension, __LINE__, FALSE);
|
||||
|
||||
count = 12345;
|
||||
stat = GdipImageGetFrameCount((GpImage*)bmp, &dimension, &count);
|
||||
todo_wine expect(Ok, stat);
|
||||
todo_wine expect(1, count);
|
||||
|
||||
GdipDisposeImage((GpImage*)bmp);
|
||||
IStream_Release(stream);
|
||||
}
|
||||
|
||||
START_TEST(image)
|
||||
{
|
||||
struct GdiplusStartupInput gdiplusStartupInput;
|
||||
|
@ -1117,9 +1650,15 @@ START_TEST(image)
|
|||
test_testcontrol();
|
||||
test_fromhicon();
|
||||
test_getrawformat();
|
||||
test_loadwmf();
|
||||
test_createfromwmf();
|
||||
test_resolution();
|
||||
test_createhbitmap();
|
||||
test_getsetpixel();
|
||||
test_palette();
|
||||
test_colormatrix();
|
||||
test_gamma();
|
||||
test_multiframegif();
|
||||
|
||||
GdiplusShutdown(gdiplusToken);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ static void test_constructor(void)
|
|||
{
|
||||
GpStringFormat *format;
|
||||
GpStatus stat;
|
||||
INT n;
|
||||
INT n, count;
|
||||
StringAlignment align, valign;
|
||||
StringTrimming trimming;
|
||||
StringDigitSubstitute digitsub;
|
||||
|
@ -43,6 +43,7 @@ static void test_constructor(void)
|
|||
GdipGetStringFormatHotkeyPrefix(format, &n);
|
||||
GdipGetStringFormatTrimming(format, &trimming);
|
||||
GdipGetStringFormatDigitSubstitution(format, &digitlang, &digitsub);
|
||||
GdipGetStringFormatMeasurableCharacterRangeCount(format, &count);
|
||||
|
||||
expect(HotkeyPrefixNone, n);
|
||||
expect(StringAlignmentNear, align);
|
||||
|
@ -50,6 +51,7 @@ static void test_constructor(void)
|
|||
expect(StringTrimmingCharacter, trimming);
|
||||
expect(StringDigitSubstituteUser, digitsub);
|
||||
expect(LANG_NEUTRAL, digitlang);
|
||||
expect(0, count);
|
||||
|
||||
stat = GdipDeleteStringFormat(format);
|
||||
expect(Ok, stat);
|
||||
|
@ -64,14 +66,19 @@ static void test_characterrange(void)
|
|||
|
||||
stat = GdipCreateStringFormat(0, LANG_NEUTRAL, &format);
|
||||
expect(Ok, stat);
|
||||
todo_wine
|
||||
{
|
||||
stat = GdipSetStringFormatMeasurableCharacterRanges(NULL, 3, ranges);
|
||||
expect(InvalidParameter, stat);
|
||||
stat = GdipSetStringFormatMeasurableCharacterRanges(format, 0, ranges);
|
||||
expect(Ok, stat);
|
||||
stat = GdipSetStringFormatMeasurableCharacterRanges(format, 3, NULL);
|
||||
expect(InvalidParameter, stat);
|
||||
|
||||
stat = GdipSetStringFormatMeasurableCharacterRanges(format, 3, ranges);
|
||||
expect(Ok, stat);
|
||||
stat = GdipGetStringFormatMeasurableCharacterRangeCount(format, &count);
|
||||
expect(Ok, stat);
|
||||
if (stat == Ok) expect(3, count);
|
||||
}
|
||||
|
||||
stat= GdipDeleteStringFormat(format);
|
||||
expect(Ok, stat);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue