gdiplus/tests: Some tests for Image raw format value.
This commit is contained in:
parent
bc1e27d99a
commit
df9831d60a
|
@ -18,6 +18,8 @@
|
|||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#define COBJMACROS
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "initguid.h"
|
||||
|
@ -27,6 +29,58 @@
|
|||
|
||||
#define expect(expected, got) ok(((UINT)got) == ((UINT)expected), "Expected %.8x, got %.8x\n", (UINT)expected, (UINT)got)
|
||||
|
||||
static void expect_rawformat(REFGUID expected, GpImage *img, int line, BOOL todo)
|
||||
{
|
||||
GUID raw;
|
||||
WCHAR bufferW[39];
|
||||
char buffer[39];
|
||||
char buffer2[39];
|
||||
GpStatus stat;
|
||||
|
||||
stat = GdipGetImageRawFormat(img, &raw);
|
||||
ok_(__FILE__, line)(stat == Ok, "GdipGetImageRawFormat failed with %d\n", stat);
|
||||
if(stat != Ok) return;
|
||||
StringFromGUID2(&raw, bufferW, sizeof(bufferW)/sizeof(bufferW[0]));
|
||||
WideCharToMultiByte(CP_ACP, 0, bufferW, sizeof(bufferW)/sizeof(bufferW[0]), buffer, sizeof(buffer), NULL, NULL);
|
||||
StringFromGUID2(expected, bufferW, sizeof(bufferW)/sizeof(bufferW[0]));
|
||||
WideCharToMultiByte(CP_ACP, 0, bufferW, sizeof(bufferW)/sizeof(bufferW[0]), buffer2, sizeof(buffer2), NULL, NULL);
|
||||
if(todo)
|
||||
todo_wine ok_(__FILE__, line)(IsEqualGUID(&raw, expected), "Expected format %s, got %s\n", buffer2, buffer);
|
||||
else
|
||||
ok_(__FILE__, line)(IsEqualGUID(&raw, expected), "Expected format %s, got %s\n", buffer2, buffer);
|
||||
}
|
||||
|
||||
static void test_bufferrawformat(void* buff, int size, REFGUID expected, int line, BOOL todo)
|
||||
{
|
||||
LPSTREAM stream;
|
||||
HGLOBAL hglob;
|
||||
LPBYTE data;
|
||||
HRESULT hres;
|
||||
GpStatus stat;
|
||||
GpBitmap *bmp;
|
||||
|
||||
hglob = GlobalAlloc (0, size);
|
||||
data = GlobalLock (hglob);
|
||||
memcpy(data, buff, size);
|
||||
GlobalUnlock(hglob); data = NULL;
|
||||
|
||||
hres = CreateStreamOnHGlobal(hglob, TRUE, &stream);
|
||||
ok_(__FILE__, line)(hres == S_OK, "Failed to create a stream\n");
|
||||
if(hres != S_OK) return;
|
||||
|
||||
stat = GdipCreateBitmapFromStream(stream, &bmp);
|
||||
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);
|
||||
|
||||
GdipDisposeImage((GpImage*)bmp);
|
||||
IStream_Release(stream);
|
||||
}
|
||||
|
||||
static void test_Scan0(void)
|
||||
{
|
||||
GpBitmap *bm;
|
||||
|
@ -426,6 +480,9 @@ static void test_GdipCreateBitmapFromHBITMAP(void)
|
|||
hbm = CreateBitmap(WIDTH2, HEIGHT2, 1, 1, &buff);
|
||||
stat = GdipCreateBitmapFromHBITMAP(hbm, NULL, &gpbm);
|
||||
expect(Ok, stat);
|
||||
/* raw format */
|
||||
expect_rawformat(&ImageFormatMemoryBMP, (GpImage*)gpbm, __LINE__, TRUE);
|
||||
|
||||
expect(Ok, GdipGetImageDimension((GpImage*) gpbm, &width, &height));
|
||||
ok(fabs(WIDTH2 - width) < .0001, "width wrong\n");
|
||||
ok(fabs(HEIGHT2 - height) < .0001, "height wrong\n");
|
||||
|
@ -502,10 +559,12 @@ static void test_GdipCloneImage(void)
|
|||
/* Create an image, clone it, delete the original, make sure the copy works */
|
||||
stat = GdipCreateBitmapFromScan0(WIDTH, HEIGHT, 0, PixelFormat24bppRGB, NULL, &bm);
|
||||
expect(Ok, stat);
|
||||
expect_rawformat(&ImageFormatMemoryBMP, (GpImage*)bm, __LINE__, TRUE);
|
||||
|
||||
image_src = ((GpImage*)bm);
|
||||
stat = GdipCloneImage(image_src, &image_dest);
|
||||
expect(Ok, stat);
|
||||
expect_rawformat(&ImageFormatMemoryBMP, image_dest, __LINE__, TRUE);
|
||||
|
||||
stat = GdipDisposeImage((GpImage*)bm);
|
||||
expect(Ok, stat);
|
||||
|
@ -542,10 +601,6 @@ static void test_fromhicon(void)
|
|||
UINT dim;
|
||||
ImageType type;
|
||||
PixelFormat format;
|
||||
GUID raw;
|
||||
WCHAR bufferW[39];
|
||||
char buffer[39];
|
||||
char buffer2[39];
|
||||
|
||||
/* NULL */
|
||||
stat = GdipCreateBitmapFromHICON(NULL, NULL);
|
||||
|
@ -584,12 +639,7 @@ static void test_fromhicon(void)
|
|||
stat = GdipGetImagePixelFormat((GpImage*)bitmap, &format);
|
||||
expect(PixelFormat32bppARGB, format);
|
||||
/* raw format */
|
||||
stat = GdipGetImageRawFormat((GpImage*)bitmap, &raw);
|
||||
StringFromGUID2(&raw, bufferW, sizeof(bufferW)/sizeof(bufferW[0]));
|
||||
WideCharToMultiByte(CP_ACP, 0, bufferW, sizeof(bufferW)/sizeof(bufferW[0]), buffer, sizeof(buffer), NULL, NULL);
|
||||
StringFromGUID2(&ImageFormatMemoryBMP, bufferW, sizeof(bufferW)/sizeof(bufferW[0]));
|
||||
WideCharToMultiByte(CP_ACP, 0, bufferW, sizeof(bufferW)/sizeof(bufferW[0]), buffer2, sizeof(buffer2), NULL, NULL);
|
||||
todo_wine ok(IsEqualGUID(&raw, &ImageFormatMemoryBMP), "Expected format %s, got %s\n", buffer2, buffer);
|
||||
expect_rawformat(&ImageFormatMemoryBMP, (GpImage*)bitmap, __LINE__, TRUE);
|
||||
GdipDisposeImage((GpImage*)bitmap);
|
||||
}
|
||||
DestroyIcon(hIcon);
|
||||
|
@ -625,17 +675,65 @@ static void test_fromhicon(void)
|
|||
stat = GdipGetImagePixelFormat((GpImage*)bitmap, &format);
|
||||
expect(PixelFormat32bppARGB, format);
|
||||
/* raw format */
|
||||
stat = GdipGetImageRawFormat((GpImage*)bitmap, &raw);
|
||||
StringFromGUID2(&raw, bufferW, sizeof(bufferW)/sizeof(bufferW[0]));
|
||||
WideCharToMultiByte(CP_ACP, 0, bufferW, sizeof(bufferW)/sizeof(bufferW[0]), buffer, sizeof(buffer), NULL, NULL);
|
||||
StringFromGUID2(&ImageFormatMemoryBMP, bufferW, sizeof(bufferW)/sizeof(bufferW[0]));
|
||||
WideCharToMultiByte(CP_ACP, 0, bufferW, sizeof(bufferW)/sizeof(bufferW[0]), buffer2, sizeof(buffer2), NULL, NULL);
|
||||
todo_wine ok(IsEqualGUID(&raw, &ImageFormatMemoryBMP), "Expected format %s, got %s\n", buffer2, buffer);
|
||||
expect_rawformat(&ImageFormatMemoryBMP, (GpImage*)bitmap, __LINE__, TRUE);
|
||||
GdipDisposeImage((GpImage*)bitmap);
|
||||
}
|
||||
DestroyIcon(hIcon);
|
||||
}
|
||||
|
||||
/* 1x1 pixel png */
|
||||
static const unsigned char pngimage[285] = {
|
||||
0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52,
|
||||
0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x08,0x02,0x00,0x00,0x00,0x90,0x77,0x53,
|
||||
0xde,0x00,0x00,0x00,0x09,0x70,0x48,0x59,0x73,0x00,0x00,0x0b,0x13,0x00,0x00,0x0b,
|
||||
0x13,0x01,0x00,0x9a,0x9c,0x18,0x00,0x00,0x00,0x07,0x74,0x49,0x4d,0x45,0x07,0xd5,
|
||||
0x06,0x03,0x0f,0x07,0x2d,0x12,0x10,0xf0,0xfd,0x00,0x00,0x00,0x0c,0x49,0x44,0x41,
|
||||
0x54,0x08,0xd7,0x63,0xf8,0xff,0xff,0x3f,0x00,0x05,0xfe,0x02,0xfe,0xdc,0xcc,0x59,
|
||||
0xe7,0x00,0x00,0x00,0x00,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
|
||||
};
|
||||
/* 1x1 pixel gif */
|
||||
static const unsigned char gifimage[35] = {
|
||||
0x47,0x49,0x46,0x38,0x37,0x61,0x01,0x00,0x01,0x00,0x80,0x00,0x00,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x02,0x02,0x44,
|
||||
0x01,0x00,0x3b
|
||||
};
|
||||
/* 1x1 pixel bmp */
|
||||
static const unsigned char bmpimage[66] = {
|
||||
0x42,0x4d,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x00,0x00,0x00,0x28,0x00,
|
||||
0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x00,
|
||||
0x00,0x00,0x04,0x00,0x00,0x00,0x12,0x0b,0x00,0x00,0x12,0x0b,0x00,0x00,0x02,0x00,
|
||||
0x00,0x00,0x02,0x00,0x00,0x00,0xff,0xff,0xff,0x00,0xff,0xff,0xff,0x00,0x00,0x00,
|
||||
0x00,0x00
|
||||
};
|
||||
/* 1x1 pixel jpg */
|
||||
static const unsigned char jpgimage[285] = {
|
||||
0xff,0xd8,0xff,0xe0,0x00,0x10,0x4a,0x46,0x49,0x46,0x00,0x01,0x01,0x01,0x01,0x2c,
|
||||
0x01,0x2c,0x00,0x00,0xff,0xdb,0x00,0x43,0x00,0x05,0x03,0x04,0x04,0x04,0x03,0x05,
|
||||
0x04,0x04,0x04,0x05,0x05,0x05,0x06,0x07,0x0c,0x08,0x07,0x07,0x07,0x07,0x0f,0x0b,
|
||||
0x0b,0x09,0x0c,0x11,0x0f,0x12,0x12,0x11,0x0f,0x11,0x11,0x13,0x16,0x1c,0x17,0x13,
|
||||
0x14,0x1a,0x15,0x11,0x11,0x18,0x21,0x18,0x1a,0x1d,0x1d,0x1f,0x1f,0x1f,0x13,0x17,
|
||||
0x22,0x24,0x22,0x1e,0x24,0x1c,0x1e,0x1f,0x1e,0xff,0xdb,0x00,0x43,0x01,0x05,0x05,
|
||||
0x05,0x07,0x06,0x07,0x0e,0x08,0x08,0x0e,0x1e,0x14,0x11,0x14,0x1e,0x1e,0x1e,0x1e,
|
||||
0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,
|
||||
0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,
|
||||
0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0xff,0xc0,
|
||||
0x00,0x11,0x08,0x00,0x01,0x00,0x01,0x03,0x01,0x22,0x00,0x02,0x11,0x01,0x03,0x11,
|
||||
0x01,0xff,0xc4,0x00,0x15,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0xff,0xc4,0x00,0x14,0x10,0x01,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xc4,
|
||||
0x00,0x14,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0xff,0xc4,0x00,0x14,0x11,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
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
|
||||
};
|
||||
static void test_getrawformat(void)
|
||||
{
|
||||
test_bufferrawformat((void*)pngimage, sizeof(pngimage), &ImageFormatPNG, __LINE__, TRUE);
|
||||
test_bufferrawformat((void*)gifimage, sizeof(gifimage), &ImageFormatGIF, __LINE__, TRUE);
|
||||
test_bufferrawformat((void*)bmpimage, sizeof(bmpimage), &ImageFormatBMP, __LINE__, FALSE);
|
||||
test_bufferrawformat((void*)jpgimage, sizeof(jpgimage), &ImageFormatJPEG, __LINE__, TRUE);
|
||||
}
|
||||
|
||||
START_TEST(image)
|
||||
{
|
||||
struct GdiplusStartupInput gdiplusStartupInput;
|
||||
|
@ -660,6 +758,7 @@ START_TEST(image)
|
|||
test_GdipCloneImage();
|
||||
test_testcontrol();
|
||||
test_fromhicon();
|
||||
test_getrawformat();
|
||||
|
||||
GdiplusShutdown(gdiplusToken);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue