gdiplus/tests: Add gif frames composition tests.
This commit is contained in:
parent
821932dab9
commit
a3822f973e
|
@ -2423,6 +2423,51 @@ static const unsigned char gifanimation[72] = {
|
|||
0x00,0x00,0x02,0x02,0x44,0x01,0x00,0x3b
|
||||
};
|
||||
|
||||
/* Generated with ImageMagick:
|
||||
* convert -transparent black -delay 100 -size 8x2 xc:black \
|
||||
* -dispose none -page +0+0 -size 2x2 xc:red \
|
||||
* -dispose background -page +2+0 -size 2x2 xc:blue \
|
||||
* -dispose previous -page +4+0 -size 2x2 xc:green \
|
||||
* -dispose undefined -page +6+0 -size 2x2 xc:gray \
|
||||
* test.gif
|
||||
*/
|
||||
static const unsigned char gifanimation2[] = {
|
||||
0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x08, 0x00,
|
||||
0x02, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x21, 0xf9, 0x04, 0x01, 0x64,
|
||||
0x00, 0x00, 0x00, 0x21, 0xff, 0x0b, 0x4e, 0x45,
|
||||
0x54, 0x53, 0x43, 0x41, 0x50, 0x45, 0x32, 0x2e,
|
||||
0x30, 0x03, 0x01, 0x00, 0x00, 0x00, 0x2c, 0x00,
|
||||
0x00, 0x00, 0x00, 0x08, 0x00, 0x02, 0x00, 0x00,
|
||||
0x02, 0x04, 0x84, 0x8f, 0x09, 0x05, 0x00, 0x21,
|
||||
0xf9, 0x04, 0x04, 0x64, 0x00, 0x00, 0x00, 0x2c,
|
||||
0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x00,
|
||||
0x81, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff,
|
||||
0x00, 0x00, 0xff, 0x00, 0x00, 0x02, 0x03, 0x44,
|
||||
0x34, 0x05, 0x00, 0x21, 0xf9, 0x04, 0x08, 0x64,
|
||||
0x00, 0x00, 0x00, 0x2c, 0x02, 0x00, 0x00, 0x00,
|
||||
0x02, 0x00, 0x02, 0x00, 0x81, 0x00, 0x00, 0xff,
|
||||
0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00,
|
||||
0xff, 0x02, 0x03, 0x44, 0x34, 0x05, 0x00, 0x21,
|
||||
0xf9, 0x04, 0x0c, 0x64, 0x00, 0x00, 0x00, 0x2c,
|
||||
0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x00,
|
||||
0x81, 0x00, 0x80, 0x00, 0x00, 0x80, 0x00, 0x00,
|
||||
0x80, 0x00, 0x00, 0x80, 0x00, 0x02, 0x03, 0x44,
|
||||
0x34, 0x05, 0x00, 0x21, 0xf9, 0x04, 0x00, 0x64,
|
||||
0x00, 0x00, 0x00, 0x2c, 0x06, 0x00, 0x00, 0x00,
|
||||
0x02, 0x00, 0x02, 0x00, 0x80, 0x7e, 0x7e, 0x7e,
|
||||
0x00, 0x00, 0x00, 0x02, 0x02, 0x84, 0x51, 0x00,
|
||||
0x3b
|
||||
};
|
||||
|
||||
static ARGB gifanimation2_pixels[5][4] = {
|
||||
{0, 0, 0, 0},
|
||||
{0xffff0000, 0, 0, 0},
|
||||
{0xffff0000, 0xff0000ff, 0, 0},
|
||||
{0xffff0000, 0, 0xff008000, 0},
|
||||
{0xffff0000, 0, 0, 0xff7e7e7e}
|
||||
};
|
||||
|
||||
static void test_multiframegif(void)
|
||||
{
|
||||
LPSTREAM stream;
|
||||
|
@ -2435,7 +2480,7 @@ static void test_multiframegif(void)
|
|||
UINT count;
|
||||
GUID dimension;
|
||||
PixelFormat pixel_format;
|
||||
INT palette_size;
|
||||
INT palette_size, i, j;
|
||||
|
||||
/* Test frame functions with an animated GIF */
|
||||
hglob = GlobalAlloc (0, sizeof(gifanimation));
|
||||
|
@ -2575,6 +2620,54 @@ static void test_multiframegif(void)
|
|||
|
||||
GdipDisposeImage((GpImage*)bmp);
|
||||
IStream_Release(stream);
|
||||
|
||||
/* Test frame dispose methods */
|
||||
hglob = GlobalAlloc (0, sizeof(gifanimation2));
|
||||
data = GlobalLock (hglob);
|
||||
memcpy(data, gifanimation2, sizeof(gifanimation2));
|
||||
GlobalUnlock(hglob);
|
||||
|
||||
hres = CreateStreamOnHGlobal(hglob, TRUE, &stream);
|
||||
ok(hres == S_OK, "Failed to create a stream\n");
|
||||
|
||||
stat = GdipCreateBitmapFromStream(stream, &bmp);
|
||||
ok(stat == Ok, "Failed to create a Bitmap\n");
|
||||
IStream_Release(stream);
|
||||
|
||||
stat = GdipImageGetFrameDimensionsList((GpImage*)bmp, &dimension, 1);
|
||||
expect(Ok, stat);
|
||||
expect_guid(&FrameDimensionTime, &dimension, __LINE__, FALSE);
|
||||
|
||||
stat = GdipImageGetFrameCount((GpImage*)bmp, &dimension, &count);
|
||||
expect(Ok, stat);
|
||||
expect(5, count);
|
||||
|
||||
stat = GdipBitmapGetPixel(bmp, 0, 0, &color);
|
||||
expect(Ok, stat);
|
||||
expect(0, color);
|
||||
|
||||
stat = GdipImageSelectActiveFrame((GpImage*)bmp, &dimension, 3);
|
||||
stat = GdipBitmapGetPixel(bmp, 2, 0, &color);
|
||||
expect(Ok, stat);
|
||||
ok(color==0 || broken(color==0xff0000ff), "color = %x\n", color);
|
||||
if(color != 0) {
|
||||
win_skip("broken animated gif support\n");
|
||||
GdipDisposeImage((GpImage*)bmp);
|
||||
return;
|
||||
}
|
||||
|
||||
for(i=0; i<6; i++) {
|
||||
stat = GdipImageSelectActiveFrame((GpImage*)bmp, &dimension, i%5);
|
||||
expect(Ok, stat);
|
||||
|
||||
for(j=0; j<4; j++) {
|
||||
stat = GdipBitmapGetPixel(bmp, j*2, 0, &color);
|
||||
expect(Ok, stat);
|
||||
ok(gifanimation2_pixels[i%5][j] == color, "at %d,%d got %x, expected %x\n", i, j, color, gifanimation2_pixels[i%5][j]);
|
||||
}
|
||||
}
|
||||
|
||||
GdipDisposeImage((GpImage*)bmp);
|
||||
}
|
||||
|
||||
static void test_rotateflip(void)
|
||||
|
|
Loading…
Reference in New Issue