[GDIPLUS_WINETEST]

- Sync to Wine 1.3.37

svn path=/trunk/; revision=56056
This commit is contained in:
Rafal Harabien 2012-03-05 20:18:32 +00:00
parent 4ecb1c4ca7
commit 6e4c0662ea
8 changed files with 1883 additions and 188 deletions

View file

@ -286,10 +286,15 @@ static void test_texturewrap(void)
static void test_gradientgetrect(void)
{
GpLineGradient *brush;
GpMatrix *transform;
REAL elements[6];
GpRectF rectf;
GpStatus status;
GpPointF pt1, pt2;
status = GdipCreateMatrix(&transform);
expect(Ok, status);
pt1.X = pt1.Y = 1.0;
pt2.X = pt2.Y = 100.0;
status = GdipCreateLineBrush(&pt1, &pt2, 0, 0, WrapModeTile, &brush);
@ -301,7 +306,21 @@ static void test_gradientgetrect(void)
expectf(1.0, rectf.Y);
expectf(99.0, rectf.Width);
expectf(99.0, rectf.Height);
status = GdipGetLineTransform(brush, transform);
todo_wine expect(Ok, status);
if (status == Ok)
{
status = GdipGetMatrixElements(transform, elements);
expect(Ok, status);
expectf(1.0, elements[0]);
expectf(1.0, elements[1]);
expectf(-1.0, elements[2]);
expectf(1.0, elements[3]);
expectf(50.50, elements[4]);
expectf(-50.50, elements[5]);
}
status = GdipDeleteBrush((GpBrush*)brush);
expect(Ok, status);
/* vertical gradient */
pt1.X = pt1.Y = pt2.X = 0.0;
pt2.Y = 10.0;
@ -314,7 +333,21 @@ static void test_gradientgetrect(void)
expectf(0.0, rectf.Y);
expectf(10.0, rectf.Width);
expectf(10.0, rectf.Height);
status = GdipGetLineTransform(brush, transform);
todo_wine expect(Ok, status);
if (status == Ok)
{
status = GdipGetMatrixElements(transform, elements);
expect(Ok, status);
expectf(0.0, elements[0]);
expectf(1.0, elements[1]);
expectf(-1.0, elements[2]);
expectf(0.0, elements[3]);
expectf(5.0, elements[4]);
expectf(5.0, elements[5]);
}
status = GdipDeleteBrush((GpBrush*)brush);
expect(Ok, status);
/* horizontal gradient */
pt1.X = pt1.Y = pt2.Y = 0.0;
pt2.X = 10.0;
@ -327,7 +360,21 @@ static void test_gradientgetrect(void)
expectf(-5.0, rectf.Y);
expectf(10.0, rectf.Width);
expectf(10.0, rectf.Height);
status = GdipGetLineTransform(brush, transform);
todo_wine expect(Ok, status);
if (status == Ok)
{
status = GdipGetMatrixElements(transform, elements);
expect(Ok, status);
expectf(1.0, elements[0]);
expectf(0.0, elements[1]);
expectf(0.0, elements[2]);
expectf(1.0, elements[3]);
expectf(0.0, elements[4]);
expectf(0.0, elements[5]);
}
status = GdipDeleteBrush((GpBrush*)brush);
expect(Ok, status);
/* slope = -1 */
pt1.X = pt1.Y = 0.0;
pt2.X = 20.0;
@ -341,7 +388,21 @@ static void test_gradientgetrect(void)
expectf(-20.0, rectf.Y);
expectf(20.0, rectf.Width);
expectf(20.0, rectf.Height);
status = GdipGetLineTransform(brush, transform);
todo_wine expect(Ok, status);
if (status == Ok)
{
status = GdipGetMatrixElements(transform, elements);
expect(Ok, status);
expectf(1.0, elements[0]);
expectf(-1.0, elements[1]);
expectf(1.0, elements[2]);
expectf(1.0, elements[3]);
expectf(10.0, elements[4]);
expectf(10.0, elements[5]);
}
status = GdipDeleteBrush((GpBrush*)brush);
expect(Ok, status);
/* slope = 1/100 */
pt1.X = pt1.Y = 0.0;
pt2.X = 100.0;
@ -355,7 +416,35 @@ static void test_gradientgetrect(void)
expectf(0.0, rectf.Y);
expectf(100.0, rectf.Width);
expectf(1.0, rectf.Height);
status = GdipGetLineTransform(brush, transform);
todo_wine expect(Ok, status);
if (status == Ok)
{
status = GdipGetMatrixElements(transform, elements);
expect(Ok,status);
expectf(1.0, elements[0]);
expectf(0.01, elements[1]);
expectf(-0.02, elements[2]);
/* expectf(2.0, elements[3]); */
expectf(0.01, elements[4]);
/* expectf(-1.0, elements[5]); */
}
status = GdipDeleteBrush((GpBrush*)brush);
expect(Ok,status);
/* zero height rect */
rectf.X = rectf.Y = 10.0;
rectf.Width = 100.0;
rectf.Height = 0.0;
status = GdipCreateLineBrushFromRect(&rectf, 0, 0, LinearGradientModeVertical,
WrapModeTile, &brush);
expect(OutOfMemory, status);
/* zero width rect */
rectf.X = rectf.Y = 10.0;
rectf.Width = 0.0;
rectf.Height = 100.0;
status = GdipCreateLineBrushFromRect(&rectf, 0, 0, LinearGradientModeHorizontal,
WrapModeTile, &brush);
expect(OutOfMemory, status);
/* from rect with LinearGradientModeHorizontal */
rectf.X = rectf.Y = 10.0;
rectf.Width = rectf.Height = 100.0;
@ -369,7 +458,21 @@ static void test_gradientgetrect(void)
expectf(10.0, rectf.Y);
expectf(100.0, rectf.Width);
expectf(100.0, rectf.Height);
status = GdipGetLineTransform(brush, transform);
todo_wine expect(Ok, status);
if (status == Ok)
{
status = GdipGetMatrixElements(transform, elements);
expect(Ok,status);
expectf(1.0, elements[0]);
expectf(0.0, elements[1]);
expectf(0.0, elements[2]);
expectf(1.0, elements[3]);
expectf(0.0, elements[4]);
expectf(0.0, elements[5]);
}
status = GdipDeleteBrush((GpBrush*)brush);
expect(Ok,status);
/* passing negative Width/Height to LinearGradientModeHorizontal */
rectf.X = rectf.Y = 10.0;
rectf.Width = rectf.Height = -100.0;
@ -383,7 +486,23 @@ static void test_gradientgetrect(void)
expectf(10.0, rectf.Y);
expectf(-100.0, rectf.Width);
expectf(-100.0, rectf.Height);
status = GdipGetLineTransform(brush, transform);
todo_wine expect(Ok, status);
if (status == Ok)
{
status = GdipGetMatrixElements(transform, elements);
expect(Ok,status);
expectf(1.0, elements[0]);
expectf(0.0, elements[1]);
expectf(0.0, elements[2]);
expectf(1.0, elements[3]);
expectf(0.0, elements[4]);
expectf(0.0, elements[5]);
}
status = GdipDeleteBrush((GpBrush*)brush);
expect(Ok,status);
GdipDeleteMatrix(transform);
}
static void test_lineblend(void)
@ -401,6 +520,10 @@ static void test_lineblend(void)
REAL res_positions[6] = {0.3f, 0.0f, 0.0f, 0.0f, 0.0f};
ARGB res_colors[6] = {0xdeadbeef, 0, 0, 0, 0};
pt1.X = pt1.Y = pt2.Y = pt2.X = 1.0;
status = GdipCreateLineBrush(&pt1, &pt2, 0, 0, WrapModeTile, &brush);
expect(OutOfMemory, status);
pt1.X = pt1.Y = 1.0;
pt2.X = pt2.Y = 100.0;
status = GdipCreateLineBrush(&pt1, &pt2, 0, 0, WrapModeTile, &brush);

View file

@ -34,6 +34,7 @@ static const WCHAR MicrosoftSansSerif[] = {'M','i','c','r','o','s','o','f','t','
static const WCHAR TimesNewRoman[] = {'T','i','m','e','s',' ','N','e','w',' ','R','o','m','a','n','\0'};
static const WCHAR CourierNew[] = {'C','o','u','r','i','e','r',' ','N','e','w','\0'};
static const WCHAR Tahoma[] = {'T','a','h','o','m','a',0};
static const WCHAR LiberationSerif[] = {'L','i','b','e','r','a','t','i','o','n',' ','S','e','r','i','f',0};
static void test_createfont(void)
{
@ -129,7 +130,8 @@ static void test_logfont(void)
expect(0, lfa2.lfItalic);
expect(0, lfa2.lfUnderline);
expect(0, lfa2.lfStrikeOut);
expect(GetTextCharset(hdc), lfa2.lfCharSet);
ok(lfa2.lfCharSet == GetTextCharset(hdc) || lfa2.lfCharSet == ANSI_CHARSET,
"Expected %x or %x, got %x\n", GetTextCharset(hdc), ANSI_CHARSET, lfa2.lfCharSet);
expect(0, lfa2.lfOutPrecision);
expect(0, lfa2.lfClipPrecision);
expect(0, lfa2.lfQuality);
@ -159,7 +161,8 @@ static void test_logfont(void)
expect(TRUE, lfa2.lfItalic);
expect(TRUE, lfa2.lfUnderline);
expect(TRUE, lfa2.lfStrikeOut);
expect(GetTextCharset(hdc), lfa2.lfCharSet);
ok(lfa2.lfCharSet == GetTextCharset(hdc) || lfa2.lfCharSet == ANSI_CHARSET,
"Expected %x or %x, got %x\n", GetTextCharset(hdc), ANSI_CHARSET, lfa2.lfCharSet);
expect(0, lfa2.lfOutPrecision);
expect(0, lfa2.lfClipPrecision);
expect(0, lfa2.lfQuality);
@ -252,6 +255,7 @@ static void test_fontfamily_properties (void)
ok(result == 1854, "Expected 1854, got %d\n", result);
result = 0;
stat = GdipGetCellDescent(FontFamily, FontStyleRegular, &result);
expect(Ok, stat);
ok(result == 434, "Expected 434, got %d\n", result);
GdipDeleteFontFamily(FontFamily);
}
@ -275,65 +279,68 @@ static void test_fontfamily_properties (void)
ok(result == 1825, "Expected 1825, got %d\n", result);
result = 0;
stat = GdipGetCellDescent(FontFamily, FontStyleRegular, &result);
expect(Ok, stat);
ok(result == 443, "Expected 443 got %d\n", result);
GdipDeleteFontFamily(FontFamily);
}
}
static void check_family(const char* context, GpFontFamily *family, WCHAR *name)
{
GpStatus stat;
GpFont* font;
*name = 0;
stat = GdipGetFamilyName(family, name, LANG_NEUTRAL);
ok(stat == Ok, "could not get the %s family name: %.8x\n", context, stat);
stat = GdipCreateFont(family, 12, FontStyleRegular, UnitPixel, &font);
ok(stat == Ok, "could not create a font for the %s family: %.8x\n", context, stat);
if (stat == Ok)
{
stat = GdipDeleteFont(font);
ok(stat == Ok, "could not delete the %s family font: %.8x\n", context, stat);
}
stat = GdipDeleteFontFamily(family);
ok(stat == Ok, "could not delete the %s family: %.8x\n", context, stat);
}
static void test_getgenerics (void)
{
GpStatus stat;
GpFontFamily* family;
WCHAR familyName[LF_FACESIZE];
ZeroMemory(familyName, sizeof(familyName)/sizeof(WCHAR));
GpFontFamily *family;
WCHAR sansname[LF_FACESIZE], serifname[LF_FACESIZE], mononame[LF_FACESIZE];
int missingfonts = 0;
stat = GdipGetGenericFontFamilySansSerif (&family);
stat = GdipGetGenericFontFamilySansSerif(&family);
expect (Ok, stat);
if (stat == FontFamilyNotFound)
{
skip("Microsoft Sans Serif not installed\n");
goto serif;
}
expect (Ok, stat);
stat = GdipGetFamilyName (family, familyName, LANG_NEUTRAL);
expect (Ok, stat);
if (!lstrcmpiW(familyName, Tahoma))
todo_wine ok ((lstrcmpiW(familyName, MicrosoftSansSerif) == 0),
"Expected Microsoft Sans Serif, got Tahoma\n");
missingfonts = 1;
else
ok ((lstrcmpiW(familyName, MicrosoftSansSerif) == 0),
"Expected Microsoft Sans Serif, got %s\n", wine_dbgstr_w(familyName));
stat = GdipDeleteFontFamily (family);
expect (Ok, stat);
check_family("Sans Serif", family, sansname);
serif:
stat = GdipGetGenericFontFamilySerif (&family);
stat = GdipGetGenericFontFamilySerif(&family);
expect (Ok, stat);
if (stat == FontFamilyNotFound)
{
skip("Times New Roman not installed\n");
goto monospace;
}
expect (Ok, stat);
stat = GdipGetFamilyName (family, familyName, LANG_NEUTRAL);
expect (Ok, stat);
ok (lstrcmpiW(familyName, TimesNewRoman) == 0,
"Expected Times New Roman, got %s\n", wine_dbgstr_w(familyName));
stat = GdipDeleteFontFamily (family);
expect (Ok, stat);
missingfonts = 1;
else
check_family("Serif", family, serifname);
monospace:
stat = GdipGetGenericFontFamilyMonospace (&family);
stat = GdipGetGenericFontFamilyMonospace(&family);
expect (Ok, stat);
if (stat == FontFamilyNotFound)
{
skip("Courier New not installed\n");
return;
}
expect (Ok, stat);
stat = GdipGetFamilyName (family, familyName, LANG_NEUTRAL);
expect (Ok, stat);
ok (lstrcmpiW(familyName, CourierNew) == 0,
"Expected Courier New, got %s\n", wine_dbgstr_w(familyName));
stat = GdipDeleteFontFamily (family);
expect (Ok, stat);
missingfonts = 1;
else
check_family("Monospace", family, mononame);
if (missingfonts && strcmp(winetest_platform, "wine") == 0)
trace("You may need to install either the Microsoft Web Fonts or the Liberation Fonts\n");
/* Check that the family names are all different */
ok(lstrcmpiW(sansname, serifname) != 0, "Sans Serif and Serif families should be different: %s\n", wine_dbgstr_w(sansname));
ok(lstrcmpiW(sansname, mononame) != 0, "Sans Serif and Monospace families should be different: %s\n", wine_dbgstr_w(sansname));
ok(lstrcmpiW(serifname, mononame) != 0, "Serif and Monospace families should be different: %s\n", wine_dbgstr_w(serifname));
}
static void test_installedfonts (void)

File diff suppressed because it is too large Load diff

View file

@ -1106,6 +1106,34 @@ static void test_isvisible(void)
ReleaseDC(0, hdc);
}
static void test_empty_rect(void)
{
GpPath *path;
GpStatus status;
BOOL result;
status = GdipCreatePath(FillModeAlternate, &path);
expect(Ok, status);
status = GdipAddPathRectangle(path, 0.0, 0.0, -5.0, 5.0);
expect(Ok, status);
status = GdipIsVisiblePathPoint(path, -2.0, 2.0, NULL, &result);
expect(Ok, status);
expect(FALSE, status);
status = GdipAddPathRectangle(path, 0.0, 0.0, 5.0, -5.0);
expect(Ok, status);
status = GdipAddPathRectangle(path, 0.0, 0.0, 0.0, 5.0);
expect(Ok, status);
status = GdipAddPathRectangle(path, 0.0, 0.0, 5.0, 0.0);
expect(Ok, status);
GdipDeletePath(path);
}
START_TEST(graphicspath)
{
struct GdiplusStartupInput gdiplusStartupInput;
@ -1135,6 +1163,7 @@ START_TEST(graphicspath)
test_addpie();
test_flatten();
test_isvisible();
test_empty_rect();
GdiplusShutdown(gdiplusToken);
}

View file

@ -516,6 +516,8 @@ static void test_LockBits(void)
GpRect rect;
BitmapData bd;
const INT WIDTH = 10, HEIGHT = 20;
ARGB color;
int y;
bm = NULL;
stat = GdipCreateBitmapFromScan0(WIDTH, HEIGHT, 0, PixelFormat24bppRGB, NULL, &bm);
@ -526,15 +528,33 @@ static void test_LockBits(void)
rect.Width = 4;
rect.Height = 5;
stat = GdipBitmapSetPixel(bm, 2, 3, 0xffc30000);
expect(Ok, stat);
stat = GdipBitmapSetPixel(bm, 2, 8, 0xff480000);
expect(Ok, stat);
/* read-only */
stat = GdipBitmapLockBits(bm, &rect, ImageLockModeRead, PixelFormat24bppRGB, &bd);
expect(Ok, stat);
if (stat == Ok) {
expect(0xc3, ((BYTE*)bd.Scan0)[2]);
expect(0x48, ((BYTE*)bd.Scan0)[2 + bd.Stride * 5]);
((char*)bd.Scan0)[2] = 0xff;
stat = GdipBitmapUnlockBits(bm, &bd);
expect(Ok, stat);
}
stat = GdipBitmapGetPixel(bm, 2, 3, &color);
expect(Ok, stat);
expect(0xffff0000, color);
stat = GdipBitmapSetPixel(bm, 2, 3, 0xffc30000);
expect(Ok, stat);
/* read-only, with NULL rect -> whole bitmap lock */
stat = GdipBitmapLockBits(bm, NULL, ImageLockModeRead, PixelFormat24bppRGB, &bd);
expect(Ok, stat);
@ -542,10 +562,16 @@ static void test_LockBits(void)
expect(bd.Height, HEIGHT);
if (stat == Ok) {
((char*)bd.Scan0)[2 + 2*3 + 3*bd.Stride] = 0xff;
stat = GdipBitmapUnlockBits(bm, &bd);
expect(Ok, stat);
}
stat = GdipBitmapGetPixel(bm, 2, 3, &color);
expect(Ok, stat);
expect(0xffff0000, color);
/* read-only, consecutive */
stat = GdipBitmapLockBits(bm, &rect, ImageLockModeRead, PixelFormat24bppRGB, &bd);
expect(Ok, stat);
@ -574,6 +600,102 @@ static void test_LockBits(void)
stat = GdipCreateBitmapFromScan0(WIDTH, HEIGHT, 0, PixelFormat24bppRGB, NULL, &bm);
expect(Ok, stat);
stat = GdipBitmapSetPixel(bm, 2, 3, 0xffff0000);
expect(Ok, stat);
stat = GdipBitmapSetPixel(bm, 2, 8, 0xffc30000);
expect(Ok, stat);
/* write, no conversion */
stat = GdipBitmapLockBits(bm, &rect, ImageLockModeWrite, PixelFormat24bppRGB, &bd);
expect(Ok, stat);
if (stat == Ok) {
/* all bits are readable, inside the rect or not */
expect(0xff, ((BYTE*)bd.Scan0)[2]);
expect(0xc3, ((BYTE*)bd.Scan0)[2 + bd.Stride * 5]);
stat = GdipBitmapUnlockBits(bm, &bd);
expect(Ok, stat);
}
/* read, conversion */
stat = GdipBitmapLockBits(bm, &rect, ImageLockModeRead, PixelFormat32bppARGB, &bd);
expect(Ok, stat);
if (stat == Ok) {
expect(0xff, ((BYTE*)bd.Scan0)[2]);
if (0)
/* Areas outside the rectangle appear to be uninitialized */
ok(0xc3 != ((BYTE*)bd.Scan0)[2 + bd.Stride * 5], "original image bits are readable\n");
((BYTE*)bd.Scan0)[2] = 0xc3;
stat = GdipBitmapUnlockBits(bm, &bd);
expect(Ok, stat);
}
/* writes do not work in read mode if there was a conversion */
stat = GdipBitmapGetPixel(bm, 2, 3, &color);
expect(Ok, stat);
expect(0xffff0000, color);
/* read/write, conversion */
stat = GdipBitmapLockBits(bm, &rect, ImageLockModeRead|ImageLockModeWrite, PixelFormat32bppARGB, &bd);
expect(Ok, stat);
if (stat == Ok) {
expect(0xff, ((BYTE*)bd.Scan0)[2]);
((BYTE*)bd.Scan0)[1] = 0x88;
if (0)
/* Areas outside the rectangle appear to be uninitialized */
ok(0xc3 != ((BYTE*)bd.Scan0)[2 + bd.Stride * 5], "original image bits are readable\n");
stat = GdipBitmapUnlockBits(bm, &bd);
expect(Ok, stat);
}
stat = GdipBitmapGetPixel(bm, 2, 3, &color);
expect(Ok, stat);
expect(0xffff8800, color);
/* write, conversion */
stat = GdipBitmapLockBits(bm, &rect, ImageLockModeWrite, PixelFormat32bppARGB, &bd);
expect(Ok, stat);
if (stat == Ok) {
if (0)
{
/* This is completely uninitialized. */
ok(0xff != ((BYTE*)bd.Scan0)[2], "original image bits are readable\n");
ok(0xc3 != ((BYTE*)bd.Scan0)[2 + bd.Stride * 5], "original image bits are readable\n");
}
/* Initialize the buffer so the unlock doesn't access undefined memory */
for (y=0; y<5; y++)
memset(((BYTE*)bd.Scan0) + bd.Stride * y, 0, 12);
((BYTE*)bd.Scan0)[0] = 0x12;
((BYTE*)bd.Scan0)[1] = 0x34;
((BYTE*)bd.Scan0)[2] = 0x56;
stat = GdipBitmapUnlockBits(bm, &bd);
expect(Ok, stat);
}
stat = GdipBitmapGetPixel(bm, 2, 3, &color);
expect(Ok, stat);
expect(0xff563412, color);
stat = GdipBitmapGetPixel(bm, 2, 8, &color);
expect(Ok, stat);
expect(0xffc30000, color);
stat = GdipDisposeImage((GpImage*)bm);
expect(Ok, stat);
stat = GdipCreateBitmapFromScan0(WIDTH, HEIGHT, 0, PixelFormat24bppRGB, NULL, &bm);
expect(Ok, stat);
/* write, no modification */
stat = GdipBitmapLockBits(bm, &rect, ImageLockModeWrite, PixelFormat24bppRGB, &bd);
expect(Ok, stat);
@ -609,6 +731,10 @@ static void test_LockBits(void)
expect(Ok, stat);
}
stat = GdipBitmapGetPixel(bm, 2, 3, &color);
expect(Ok, stat);
expect(0xffff0000, color);
stat = GdipDisposeImage((GpImage*)bm);
expect(Ok, stat);
@ -621,6 +747,102 @@ static void test_LockBits(void)
expect(Ok, stat);
}
static void test_LockBits_UserBuf(void)
{
GpStatus stat;
GpBitmap *bm;
GpRect rect;
BitmapData bd;
const INT WIDTH = 10, HEIGHT = 20;
DWORD bits[200];
ARGB color;
bm = NULL;
stat = GdipCreateBitmapFromScan0(WIDTH, HEIGHT, 0, PixelFormat32bppARGB, NULL, &bm);
expect(Ok, stat);
memset(bits, 0xaa, sizeof(bits));
rect.X = 2;
rect.Y = 3;
rect.Width = 4;
rect.Height = 5;
bd.Width = 4;
bd.Height = 6;
bd.Stride = WIDTH * 4;
bd.PixelFormat = PixelFormat32bppARGB;
bd.Scan0 = &bits[2+3*WIDTH];
bd.Reserved = 0xaaaaaaaa;
/* read-only */
stat = GdipBitmapLockBits(bm, &rect, ImageLockModeRead|ImageLockModeUserInputBuf, PixelFormat32bppARGB, &bd);
expect(Ok, stat);
expect(0xaaaaaaaa, bits[0]);
expect(0, bits[2+3*WIDTH]);
bits[2+3*WIDTH] = 0xdeadbeef;
if (stat == Ok) {
stat = GdipBitmapUnlockBits(bm, &bd);
expect(Ok, stat);
}
stat = GdipBitmapGetPixel(bm, 2, 3, &color);
expect(Ok, stat);
expect(0, color);
/* write-only */
stat = GdipBitmapLockBits(bm, &rect, ImageLockModeWrite|ImageLockModeUserInputBuf, PixelFormat32bppARGB, &bd);
expect(Ok, stat);
expect(0xdeadbeef, bits[2+3*WIDTH]);
bits[2+3*WIDTH] = 0x12345678;
if (stat == Ok) {
stat = GdipBitmapUnlockBits(bm, &bd);
expect(Ok, stat);
}
stat = GdipBitmapGetPixel(bm, 2, 3, &color);
expect(Ok, stat);
expect(0x12345678, color);
bits[2+3*WIDTH] = 0;
/* read/write */
stat = GdipBitmapLockBits(bm, &rect, ImageLockModeRead|ImageLockModeWrite|ImageLockModeUserInputBuf, PixelFormat32bppARGB, &bd);
expect(Ok, stat);
expect(0x12345678, bits[2+3*WIDTH]);
bits[2+3*WIDTH] = 0xdeadbeef;
if (stat == Ok) {
stat = GdipBitmapUnlockBits(bm, &bd);
expect(Ok, stat);
}
stat = GdipBitmapGetPixel(bm, 2, 3, &color);
expect(Ok, stat);
expect(0xdeadbeef, color);
stat = GdipDisposeImage((GpImage*)bm);
expect(Ok, stat);
}
struct BITMAPINFOWITHBITFIELDS
{
BITMAPINFOHEADER bmiHeader;
DWORD masks[3];
};
union BITMAPINFOUNION
{
BITMAPINFO bi;
struct BITMAPINFOWITHBITFIELDS bf;
};
static void test_GdipCreateBitmapFromHBITMAP(void)
{
GpBitmap* gpbm = NULL;
@ -635,8 +857,9 @@ static void test_GdipCreateBitmapFromHBITMAP(void)
const REAL WIDTH2 = 10;
const REAL HEIGHT2 = 20;
HDC hdc;
BITMAPINFO bmi;
union BITMAPINFOUNION bmi;
BYTE *bits;
PixelFormat format;
stat = GdipCreateBitmapFromHBITMAP(NULL, NULL, NULL);
expect(InvalidParameter, stat);
@ -670,14 +893,15 @@ static void test_GdipCreateBitmapFromHBITMAP(void)
hdc = CreateCompatibleDC(0);
ok(hdc != NULL, "CreateCompatibleDC failed\n");
bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader);
bmi.bmiHeader.biHeight = HEIGHT1;
bmi.bmiHeader.biWidth = WIDTH1;
bmi.bmiHeader.biBitCount = 24;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bi.bmiHeader.biSize = sizeof(bmi.bi.bmiHeader);
bmi.bi.bmiHeader.biHeight = HEIGHT1;
bmi.bi.bmiHeader.biWidth = WIDTH1;
bmi.bi.bmiHeader.biBitCount = 24;
bmi.bi.bmiHeader.biPlanes = 1;
bmi.bi.bmiHeader.biCompression = BI_RGB;
bmi.bi.bmiHeader.biClrUsed = 0;
hbm = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
hbm = CreateDIBSection(hdc, &bmi.bi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
ok(hbm != NULL, "CreateDIBSection failed\n");
bits[0] = 0;
@ -707,15 +931,100 @@ static void test_GdipCreateBitmapFromHBITMAP(void)
GdipFree(LogPal);
stat = GdipCreateBitmapFromHBITMAP(hbm, hpal, &gpbm);
todo_wine
{
expect(Ok, stat);
}
expect(Ok, stat);
if (stat == Ok)
GdipDisposeImage((GpImage*)gpbm);
DeleteObject(hpal);
DeleteObject(hbm);
/* 16-bit 555 dib, rgb */
bmi.bi.bmiHeader.biBitCount = 16;
bmi.bi.bmiHeader.biCompression = BI_RGB;
hbm = CreateDIBSection(hdc, &bmi.bi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
ok(hbm != NULL, "CreateDIBSection failed\n");
bits[0] = 0;
stat = GdipCreateBitmapFromHBITMAP(hbm, NULL, &gpbm);
expect(Ok, stat);
if (stat == Ok)
{
stat = GdipGetImageDimension((GpImage*) gpbm, &width, &height);
expect(Ok, stat);
expectf(WIDTH1, width);
expectf(HEIGHT1, height);
stat = GdipGetImagePixelFormat((GpImage*) gpbm, &format);
expect(Ok, stat);
expect(PixelFormat16bppRGB555, format);
GdipDisposeImage((GpImage*)gpbm);
}
DeleteObject(hbm);
/* 16-bit 555 dib, with bitfields */
bmi.bi.bmiHeader.biSize = sizeof(bmi);
bmi.bi.bmiHeader.biCompression = BI_BITFIELDS;
bmi.bf.masks[0] = 0x7c00;
bmi.bf.masks[1] = 0x3e0;
bmi.bf.masks[2] = 0x1f;
hbm = CreateDIBSection(hdc, &bmi.bi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
ok(hbm != NULL, "CreateDIBSection failed\n");
bits[0] = 0;
stat = GdipCreateBitmapFromHBITMAP(hbm, NULL, &gpbm);
expect(Ok, stat);
if (stat == Ok)
{
stat = GdipGetImageDimension((GpImage*) gpbm, &width, &height);
expect(Ok, stat);
expectf(WIDTH1, width);
expectf(HEIGHT1, height);
stat = GdipGetImagePixelFormat((GpImage*) gpbm, &format);
expect(Ok, stat);
expect(PixelFormat16bppRGB555, format);
GdipDisposeImage((GpImage*)gpbm);
}
DeleteObject(hbm);
/* 16-bit 565 dib, with bitfields */
bmi.bf.masks[0] = 0xf800;
bmi.bf.masks[1] = 0x7e0;
bmi.bf.masks[2] = 0x1f;
hbm = CreateDIBSection(hdc, &bmi.bi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
ok(hbm != NULL, "CreateDIBSection failed\n");
bits[0] = 0;
stat = GdipCreateBitmapFromHBITMAP(hbm, NULL, &gpbm);
expect(Ok, stat);
if (stat == Ok)
{
stat = GdipGetImageDimension((GpImage*) gpbm, &width, &height);
expect(Ok, stat);
expectf(WIDTH1, width);
expectf(HEIGHT1, height);
stat = GdipGetImagePixelFormat((GpImage*) gpbm, &format);
expect(Ok, stat);
expect(PixelFormat16bppRGB565, format);
GdipDisposeImage((GpImage*)gpbm);
}
DeleteObject(hbm);
DeleteDC(hdc);
}
static void test_GdipGetImageFlags(void)
@ -734,6 +1043,115 @@ static void test_GdipGetImageFlags(void)
stat = GdipGetImageFlags(img, NULL);
expect(InvalidParameter, stat);
stat = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat1bppIndexed, NULL, (GpBitmap**)&img);
expect(Ok, stat);
stat = GdipGetImageFlags(img, &flags);
expect(Ok, stat);
expect(ImageFlagsHasAlpha, flags);
GdipDisposeImage(img);
stat = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat4bppIndexed, NULL, (GpBitmap**)&img);
expect(Ok, stat);
stat = GdipGetImageFlags(img, &flags);
expect(Ok, stat);
expect(ImageFlagsHasAlpha, flags);
GdipDisposeImage(img);
stat = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat8bppIndexed, NULL, (GpBitmap**)&img);
expect(Ok, stat);
stat = GdipGetImageFlags(img, &flags);
expect(Ok, stat);
expect(ImageFlagsHasAlpha, flags);
GdipDisposeImage(img);
stat = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppGrayScale, NULL, (GpBitmap**)&img);
expect(Ok, stat);
stat = GdipGetImageFlags(img, &flags);
expect(Ok, stat);
expect(ImageFlagsNone, flags);
GdipDisposeImage(img);
stat = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB555, NULL, (GpBitmap**)&img);
expect(Ok, stat);
stat = GdipGetImageFlags(img, &flags);
expect(Ok, stat);
expect(ImageFlagsNone, flags);
GdipDisposeImage(img);
stat = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB565, NULL, (GpBitmap**)&img);
expect(Ok, stat);
stat = GdipGetImageFlags(img, &flags);
expect(Ok, stat);
expect(ImageFlagsNone, flags);
GdipDisposeImage(img);
stat = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppARGB1555, NULL, (GpBitmap**)&img);
expect(Ok, stat);
stat = GdipGetImageFlags(img, &flags);
expect(Ok, stat);
expect(ImageFlagsHasAlpha, flags);
GdipDisposeImage(img);
stat = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat24bppRGB, NULL, (GpBitmap**)&img);
expect(Ok, stat);
stat = GdipGetImageFlags(img, &flags);
expect(Ok, stat);
expect(ImageFlagsNone, flags);
GdipDisposeImage(img);
stat = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppRGB, NULL, (GpBitmap**)&img);
expect(Ok, stat);
stat = GdipGetImageFlags(img, &flags);
expect(Ok, stat);
expect(ImageFlagsNone, flags);
GdipDisposeImage(img);
stat = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppARGB, NULL, (GpBitmap**)&img);
expect(Ok, stat);
stat = GdipGetImageFlags(img, &flags);
expect(Ok, stat);
expect(ImageFlagsHasAlpha, flags);
GdipDisposeImage(img);
stat = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat32bppPARGB, NULL, (GpBitmap**)&img);
expect(Ok, stat);
stat = GdipGetImageFlags(img, &flags);
expect(Ok, stat);
expect(ImageFlagsHasAlpha, flags);
GdipDisposeImage(img);
stat = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat48bppRGB, NULL, (GpBitmap**)&img);
expect(Ok, stat);
if (stat == Ok)
{
stat = GdipGetImageFlags(img, &flags);
expect(Ok, stat);
expect(ImageFlagsNone, flags);
GdipDisposeImage(img);
}
stat = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppARGB, NULL, (GpBitmap**)&img);
expect(Ok, stat);
if (stat == Ok)
{
expect(Ok, stat);
stat = GdipGetImageFlags(img, &flags);
expect(Ok, stat);
expect(ImageFlagsHasAlpha, flags);
GdipDisposeImage(img);
}
stat = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppPARGB, NULL, (GpBitmap**)&img);
expect(Ok, stat);
if (stat == Ok)
{
expect(Ok, stat);
stat = GdipGetImageFlags(img, &flags);
expect(Ok, stat);
expect(ImageFlagsHasAlpha, flags);
GdipDisposeImage(img);
}
}
static void test_GdipCloneImage(void)
@ -828,6 +1246,7 @@ static void test_fromhicon(void)
expect(Ok, stat);
expect(ImageTypeBitmap, type);
stat = GdipGetImagePixelFormat((GpImage*)bitmap, &format);
expect(Ok, stat);
expect(PixelFormat32bppARGB, format);
/* raw format */
expect_rawformat(&ImageFormatMemoryBMP, (GpImage*)bitmap, __LINE__, FALSE);
@ -864,6 +1283,7 @@ static void test_fromhicon(void)
expect(Ok, stat);
expect(ImageTypeBitmap, type);
stat = GdipGetImagePixelFormat((GpImage*)bitmap, &format);
expect(Ok, stat);
expect(PixelFormat32bppARGB, format);
/* raw format */
expect_rawformat(&ImageFormatMemoryBMP, (GpImage*)bitmap, __LINE__, FALSE);
@ -1195,6 +1615,12 @@ static void test_createhbitmap(void)
expect(32, bm.bmBitsPixel);
ok(bm.bmBits != NULL, "got DDB, expected DIB\n");
if (bm.bmBits)
{
DWORD val = *(DWORD*)bm.bmBits;
ok(val == 0xff686868, "got %x, expected 0xff686868\n", val);
}
hdc = CreateCompatibleDC(NULL);
oldhbitmap = SelectObject(hdc, hbitmap);
@ -1210,6 +1636,49 @@ static void test_createhbitmap(void)
stat = GdipDisposeImage((GpImage*)bitmap);
expect(Ok, stat);
/* create alpha Bitmap */
stat = GdipCreateBitmapFromScan0(8, 20, 32, PixelFormat32bppARGB, bits, &bitmap);
expect(Ok, stat);
/* create HBITMAP */
stat = GdipCreateHBITMAPFromBitmap(bitmap, &hbitmap, 0);
expect(Ok, stat);
if (stat == Ok)
{
ret = GetObjectA(hbitmap, sizeof(BITMAP), &bm);
expect(sizeof(BITMAP), ret);
expect(0, bm.bmType);
expect(8, bm.bmWidth);
expect(20, bm.bmHeight);
expect(32, bm.bmWidthBytes);
expect(1, bm.bmPlanes);
expect(32, bm.bmBitsPixel);
ok(bm.bmBits != NULL, "got DDB, expected DIB\n");
if (bm.bmBits)
{
DWORD val = *(DWORD*)bm.bmBits;
ok(val == 0x682a2a2a, "got %x, expected 0x682a2a2a\n", val);
}
hdc = CreateCompatibleDC(NULL);
oldhbitmap = SelectObject(hdc, hbitmap);
pixel = GetPixel(hdc, 5, 5);
SelectObject(hdc, oldhbitmap);
DeleteDC(hdc);
expect(0x2a2a2a, pixel);
DeleteObject(hbitmap);
}
stat = GdipDisposeImage((GpImage*)bitmap);
expect(Ok, stat);
}
static void test_getthumbnail(void)
@ -1407,6 +1876,7 @@ static void test_palette(void)
INT size;
BYTE buffer[1040];
ColorPalette *palette=(ColorPalette*)buffer;
ARGB *entries = palette->Entries;
ARGB color=0;
/* test initial palette from non-indexed bitmap */
@ -1450,8 +1920,8 @@ static void test_palette(void)
expect(PaletteFlagsGrayScale, palette->Flags);
expect(2, palette->Count);
expect(0xff000000, palette->Entries[0]);
expect(0xffffffff, palette->Entries[1]);
expect(0xff000000, entries[0]);
expect(0xffffffff, entries[1]);
/* test getting/setting pixels */
stat = GdipBitmapGetPixel(bitmap, 0, 0, &color);
@ -1459,7 +1929,7 @@ static void test_palette(void)
expect(0xff000000, color);
stat = GdipBitmapSetPixel(bitmap, 0, 1, 0xffffffff);
todo_wine ok((stat == Ok) ||
ok((stat == Ok) ||
broken(stat == InvalidParameter) /* pre-win7 */, "stat=%.8x\n", stat);
if (stat == Ok)
@ -1492,7 +1962,7 @@ static void test_palette(void)
expect(0xff000000, color);
stat = GdipBitmapSetPixel(bitmap, 0, 1, 0xffff00ff);
todo_wine ok((stat == Ok) ||
ok((stat == Ok) ||
broken(stat == InvalidParameter) /* pre-win7 */, "stat=%.8x\n", stat);
if (stat == Ok)
@ -1525,7 +1995,7 @@ static void test_palette(void)
expect(0xff000000, color);
stat = GdipBitmapSetPixel(bitmap, 0, 1, 0xffcccccc);
todo_wine ok((stat == Ok) ||
ok((stat == Ok) ||
broken(stat == InvalidParameter) /* pre-win7 */, "stat=%.8x\n", stat);
if (stat == Ok)
@ -1536,12 +2006,12 @@ static void test_palette(void)
}
/* test setting/getting a different palette */
palette->Entries[1] = 0xffcccccc;
entries[1] = 0xffcccccc;
stat = GdipSetImagePalette((GpImage*)bitmap, palette);
expect(Ok, stat);
palette->Entries[1] = 0;
entries[1] = 0;
stat = GdipGetImagePaletteSize((GpImage*)bitmap, &size);
expect(Ok, stat);
@ -1551,7 +2021,7 @@ static void test_palette(void)
expect(Ok, stat);
expect(PaletteFlagsHalftone, palette->Flags);
expect(256, palette->Count);
expect(0xffcccccc, palette->Entries[1]);
expect(0xffcccccc, entries[1]);
/* test count < 256 */
palette->Flags = 12345;
@ -1560,8 +2030,8 @@ static void test_palette(void)
stat = GdipSetImagePalette((GpImage*)bitmap, palette);
expect(Ok, stat);
palette->Entries[1] = 0;
palette->Entries[3] = 0xdeadbeef;
entries[1] = 0;
entries[3] = 0xdeadbeef;
stat = GdipGetImagePaletteSize((GpImage*)bitmap, &size);
expect(Ok, stat);
@ -1571,8 +2041,8 @@ static void test_palette(void)
expect(Ok, stat);
expect(12345, palette->Flags);
expect(3, palette->Count);
expect(0xffcccccc, palette->Entries[1]);
expect(0xdeadbeef, palette->Entries[3]);
expect(0xffcccccc, entries[1]);
expect(0xdeadbeef, entries[3]);
/* test count > 256 */
palette->Count = 257;
@ -1602,6 +2072,12 @@ static void test_colormatrix(void)
{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 asymmetric = {{
{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},
{1.0,0.0,0.0,0.0,0.0},
{0.0,0.0,0.0,0.0,1.0}}};
GpBitmap *bitmap1, *bitmap2;
GpGraphics *graphics;
ARGB color;
@ -1662,13 +2138,13 @@ static void test_colormatrix(void)
TRUE, &colormatrix, NULL, ColorMatrixFlagsDefault);
expect(Ok, stat);
stat = GdipCreateBitmapFromScan0(1, 1, 0, PixelFormat32bppRGB, NULL, &bitmap1);
stat = GdipCreateBitmapFromScan0(1, 1, 0, PixelFormat32bppARGB, NULL, &bitmap1);
expect(Ok, stat);
stat = GdipCreateBitmapFromScan0(1, 1, 0, PixelFormat32bppRGB, NULL, &bitmap2);
stat = GdipCreateBitmapFromScan0(1, 1, 0, PixelFormat32bppARGB, NULL, &bitmap2);
expect(Ok, stat);
stat = GdipBitmapSetPixel(bitmap1, 0, 0, 0xff40ffff);
stat = GdipBitmapSetPixel(bitmap1, 0, 0, 0xff40ccee);
expect(Ok, stat);
stat = GdipGetImageGraphicsContext((GpImage*)bitmap2, &graphics);
@ -1680,7 +2156,23 @@ static void test_colormatrix(void)
stat = GdipBitmapGetPixel(bitmap2, 0, 0, &color);
expect(Ok, stat);
todo_wine expect(0xff80ffff, color);
expect(0xff80ccee, color);
colormatrix = asymmetric;
stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeDefault,
TRUE, &colormatrix, NULL, ColorMatrixFlagsDefault);
expect(Ok, stat);
stat = GdipBitmapSetPixel(bitmap2, 0, 0, 0);
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);
ok(color_match(0xeeff40cc, color, 3), "expected 0xeeff40cc, got 0x%08x\n", color);
GdipDeleteGraphics(graphics);
GdipDisposeImage((GpImage*)bitmap1);
@ -1742,7 +2234,7 @@ static void test_gamma(void)
stat = GdipBitmapGetPixel(bitmap2, 0, 0, &color);
expect(Ok, stat);
todo_wine ok(color_match(0xff20ffff, color, 1), "Expected ff20ffff, got %.8x\n", color);
ok(color_match(0xff20ffff, color, 1), "Expected ff20ffff, got %.8x\n", color);
GdipDeleteGraphics(graphics);
GdipDisposeImage((GpImage*)bitmap1);
@ -2141,6 +2633,29 @@ static void test_colorkey(void)
GdipDisposeImageAttributes(imageattr);
}
static void test_dispose(void)
{
GpStatus stat;
GpImage *image;
char invalid_image[256];
stat = GdipDisposeImage(NULL);
expect(InvalidParameter, stat);
stat = GdipCreateBitmapFromScan0(2, 2, 0, PixelFormat32bppARGB, NULL, (GpBitmap**)&image);
expect(Ok, stat);
stat = GdipDisposeImage(image);
expect(Ok, stat);
stat = GdipDisposeImage(image);
expect(ObjectBusy, stat);
memset(invalid_image, 0, 256);
stat = GdipDisposeImage((GpImage*)invalid_image);
expect(ObjectBusy, stat);
}
START_TEST(image)
{
struct GdiplusStartupInput gdiplusStartupInput;
@ -2161,6 +2676,7 @@ START_TEST(image)
test_SavingImages();
test_encoders();
test_LockBits();
test_LockBits_UserBuf();
test_GdipCreateBitmapFromHBITMAP();
test_GdipGetImageFlags();
test_GdipCloneImage();
@ -2180,6 +2696,7 @@ START_TEST(image)
test_rotateflip();
test_remaptable();
test_colorkey();
test_dispose();
GdiplusShutdown(gdiplusToken);
}

View file

@ -26,6 +26,7 @@
#include "wine/test.h"
#define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
#define expectf(expected, got) ok(fabs(expected - got) < 0.0001, "Expected %.2f, got %.2f\n", expected, got)
static void test_constructor_destructor(void)
{
@ -220,6 +221,87 @@ static void test_shear(void)
GdipDeleteMatrix(matrix);
}
static void test_constructor3(void)
{
/* MSDN is on crack. GdipCreateMatrix3 makes a matrix that transforms the
* corners of the given rectangle to the three points given. */
GpMatrix *matrix;
REAL values[6];
GpRectF rc;
GpPointF pt[3];
GpStatus stat;
rc.X = 10;
rc.Y = 10;
rc.Width = 10;
rc.Height = 10;
pt[0].X = 10;
pt[0].Y = 10;
pt[1].X = 20;
pt[1].Y = 10;
pt[2].X = 10;
pt[2].Y = 20;
stat = GdipCreateMatrix3(&rc, pt, &matrix);
expect(Ok, stat);
stat = GdipGetMatrixElements(matrix, values);
expect(Ok, stat);
expectf(1.0, values[0]);
expectf(0.0, values[1]);
expectf(0.0, values[2]);
expectf(1.0, values[3]);
expectf(0.0, values[4]);
expectf(0.0, values[5]);
GdipDeleteMatrix(matrix);
pt[0].X = 20;
pt[0].Y = 10;
pt[1].X = 40;
pt[1].Y = 10;
pt[2].X = 20;
pt[2].Y = 20;
stat = GdipCreateMatrix3(&rc, pt, &matrix);
expect(Ok, stat);
stat = GdipGetMatrixElements(matrix, values);
expect(Ok, stat);
expectf(2.0, values[0]);
expectf(0.0, values[1]);
expectf(0.0, values[2]);
expectf(1.0, values[3]);
expectf(0.0, values[4]);
expectf(0.0, values[5]);
GdipDeleteMatrix(matrix);
pt[0].X = 10;
pt[0].Y = 20;
pt[1].X = 20;
pt[1].Y = 30;
pt[2].X = 10;
pt[2].Y = 30;
stat = GdipCreateMatrix3(&rc, pt, &matrix);
expect(Ok, stat);
stat = GdipGetMatrixElements(matrix, values);
expect(Ok, stat);
expectf(1.0, values[0]);
expectf(1.0, values[1]);
expectf(0.0, values[2]);
expectf(1.0, values[3]);
expectf(0.0, values[4]);
expectf(0.0, values[5]);
GdipDeleteMatrix(matrix);}
START_TEST(matrix)
{
struct GdiplusStartupInput gdiplusStartupInput;
@ -237,6 +319,7 @@ START_TEST(matrix)
test_isinvertible();
test_invert();
test_shear();
test_constructor3();
GdiplusShutdown(gdiplusToken);
}

View file

@ -124,6 +124,7 @@ static void test_nextmarker(void)
expect(4, result);
start = end = result = (INT)0xdeadbeef;
stat = GdipPathIterNextMarker(iter, &result, &start, &end);
expect(Ok, stat);
/* start/end remain unchanged */
expect((INT)0xdeadbeef, start);
expect((INT)0xdeadbeef, end);

View file

@ -22,6 +22,7 @@
#include "gdiplus.h"
#include "wingdi.h"
#include "wine/test.h"
#include <math.h>
#define RGNDATA_RECT 0x10000000
#define RGNDATA_PATH 0x10000001
@ -33,6 +34,9 @@
#define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
#define expectf_(expected, got, precision) ok(fabs(expected - got) < precision, "Expected %.2f, got %.2f\n", expected, got)
#define expectf(expected, got) expectf_(expected, got, 0.0001)
#define expect_magic(value) ok(*value == RGNDATA_MAGIC || *value == RGNDATA_MAGIC2, "Expected a known magic value, got %8x\n", *value)
#define expect_dword(value, expected) ok(*(value) == expected, "expected %08x got %08x\n", expected, *(value))
@ -1123,6 +1127,251 @@ static void test_translate(void)
ReleaseDC(0, hdc);
}
static void test_transform(void)
{
GpRegion *region, *region2;
GpMatrix *matrix;
GpGraphics *graphics;
GpPath *path;
GpRectF rectf;
GpStatus status;
HDC hdc = GetDC(0);
BOOL res;
status = GdipCreateFromHDC(hdc, &graphics);
expect(Ok, status);
status = GdipCreatePath(FillModeAlternate, &path);
expect(Ok, status);
status = GdipCreateRegion(&region);
expect(Ok, status);
status = GdipCreateRegion(&region2);
expect(Ok, status);
status = GdipCreateMatrix(&matrix);
expect(Ok, status);
status = GdipScaleMatrix(matrix, 2.0, 3.0, MatrixOrderAppend);
expect(Ok, status);
/* NULL */
status = GdipTransformRegion(NULL, matrix);
expect(InvalidParameter, status);
status = GdipTransformRegion(region, NULL);
expect(InvalidParameter, status);
/* infinite */
status = GdipTransformRegion(region, matrix);
expect(Ok, status);
res = FALSE;
status = GdipIsEqualRegion(region, region2, graphics, &res);
expect(Ok, status);
ok(res, "Expected to be equal.\n");
/* empty */
status = GdipSetEmpty(region);
expect(Ok, status);
status = GdipTransformRegion(region, matrix);
expect(Ok, status);
status = GdipSetEmpty(region2);
expect(Ok, status);
res = FALSE;
status = GdipIsEqualRegion(region, region2, graphics, &res);
expect(Ok, status);
ok(res, "Expected to be equal.\n");
/* rect */
rectf.X = 10.0;
rectf.Y = 0.0;
rectf.Width = rectf.Height = 100.0;
status = GdipCombineRegionRect(region, &rectf, CombineModeReplace);
expect(Ok, status);
rectf.X = 20.0;
rectf.Y = 0.0;
rectf.Width = 200.0;
rectf.Height = 300.0;
status = GdipCombineRegionRect(region2, &rectf, CombineModeReplace);
expect(Ok, status);
status = GdipTransformRegion(region, matrix);
expect(Ok, status);
res = FALSE;
status = GdipIsEqualRegion(region, region2, graphics, &res);
expect(Ok, status);
ok(res, "Expected to be equal.\n");
/* path */
status = GdipAddPathEllipse(path, 0.0, 10.0, 100.0, 150.0);
expect(Ok, status);
status = GdipCombineRegionPath(region, path, CombineModeReplace);
expect(Ok, status);
status = GdipResetPath(path);
expect(Ok, status);
status = GdipAddPathEllipse(path, 0.0, 30.0, 200.0, 450.0);
expect(Ok, status);
status = GdipCombineRegionPath(region2, path, CombineModeReplace);
expect(Ok, status);
status = GdipTransformRegion(region, matrix);
expect(Ok, status);
res = FALSE;
status = GdipIsEqualRegion(region, region2, graphics, &res);
expect(Ok, status);
ok(res, "Expected to be equal.\n");
status = GdipDeleteRegion(region);
expect(Ok, status);
status = GdipDeleteRegion(region2);
expect(Ok, status);
status = GdipDeleteGraphics(graphics);
expect(Ok, status);
status = GdipDeletePath(path);
expect(Ok, status);
status = GdipDeleteMatrix(matrix);
expect(Ok, status);
ReleaseDC(0, hdc);
}
static void test_scans(void)
{
GpRegion *region;
GpMatrix *matrix;
GpRectF rectf;
GpStatus status;
ULONG count=80085;
INT icount;
GpRectF scans[2];
GpRect scansi[2];
status = GdipCreateRegion(&region);
expect(Ok, status);
status = GdipCreateMatrix(&matrix);
expect(Ok, status);
/* test NULL values */
status = GdipGetRegionScansCount(NULL, &count, matrix);
expect(InvalidParameter, status);
status = GdipGetRegionScansCount(region, NULL, matrix);
expect(InvalidParameter, status);
status = GdipGetRegionScansCount(region, &count, NULL);
expect(InvalidParameter, status);
status = GdipGetRegionScans(NULL, scans, &icount, matrix);
expect(InvalidParameter, status);
status = GdipGetRegionScans(region, scans, NULL, matrix);
expect(InvalidParameter, status);
status = GdipGetRegionScans(region, scans, &icount, NULL);
expect(InvalidParameter, status);
/* infinite */
status = GdipGetRegionScansCount(region, &count, matrix);
expect(Ok, status);
expect(1, count);
status = GdipGetRegionScans(region, NULL, &icount, matrix);
expect(Ok, status);
expect(1, icount);
status = GdipGetRegionScans(region, scans, &icount, matrix);
expect(Ok, status);
expect(1, icount);
status = GdipGetRegionScansI(region, scansi, &icount, matrix);
expect(Ok, status);
expect(1, icount);
expect(-0x400000, scansi[0].X);
expect(-0x400000, scansi[0].Y);
expect(0x800000, scansi[0].Width);
expect(0x800000, scansi[0].Height);
status = GdipGetRegionScans(region, scans, &icount, matrix);
expect(Ok, status);
expect(1, icount);
expectf((double)-0x400000, scans[0].X);
expectf((double)-0x400000, scans[0].Y);
expectf((double)0x800000, scans[0].Width);
expectf((double)0x800000, scans[0].Height);
/* empty */
status = GdipSetEmpty(region);
expect(Ok, status);
status = GdipGetRegionScansCount(region, &count, matrix);
expect(Ok, status);
expect(0, count);
status = GdipGetRegionScans(region, scans, &icount, matrix);
expect(Ok, status);
expect(0, icount);
/* single rectangle */
rectf.X = rectf.Y = 0.0;
rectf.Width = rectf.Height = 5.0;
status = GdipCombineRegionRect(region, &rectf, CombineModeReplace);
expect(Ok, status);
status = GdipGetRegionScansCount(region, &count, matrix);
expect(Ok, status);
expect(1, count);
status = GdipGetRegionScans(region, scans, &icount, matrix);
expect(Ok, status);
expect(1, icount);
expectf(0.0, scans[0].X);
expectf(0.0, scans[0].Y);
expectf(5.0, scans[0].Width);
expectf(5.0, scans[0].Height);
/* two rectangles */
rectf.X = rectf.Y = 5.0;
rectf.Width = rectf.Height = 5.0;
status = GdipCombineRegionRect(region, &rectf, CombineModeUnion);
expect(Ok, status);
status = GdipGetRegionScansCount(region, &count, matrix);
expect(Ok, status);
expect(2, count);
/* Native ignores the initial value of count */
scans[1].X = scans[1].Y = scans[1].Width = scans[1].Height = 8.0;
icount = 1;
status = GdipGetRegionScans(region, scans, &icount, matrix);
expect(Ok, status);
expect(2, icount);
expectf(0.0, scans[0].X);
expectf(0.0, scans[0].Y);
expectf(5.0, scans[0].Width);
expectf(5.0, scans[0].Height);
expectf(5.0, scans[1].X);
expectf(5.0, scans[1].Y);
expectf(5.0, scans[1].Width);
expectf(5.0, scans[1].Height);
status = GdipGetRegionScansI(region, scansi, &icount, matrix);
expect(Ok, status);
expect(2, icount);
expect(0, scansi[0].X);
expect(0, scansi[0].Y);
expect(5, scansi[0].Width);
expect(5, scansi[0].Height);
expect(5, scansi[1].X);
expect(5, scansi[1].Y);
expect(5, scansi[1].Width);
expect(5, scansi[1].Height);
status = GdipDeleteRegion(region);
expect(Ok, status);
status = GdipDeleteMatrix(matrix);
expect(Ok, status);
}
static void test_getbounds(void)
{
GpRegion *region;
@ -1634,6 +1883,8 @@ START_TEST(region)
test_gethrgn();
test_isequal();
test_translate();
test_transform();
test_scans();
test_getbounds();
test_isvisiblepoint();
test_isvisiblerect();