Author: rharabien
Date: Mon Mar 5 20:18:32 2012
New Revision: 56056
URL:
http://svn.reactos.org/svn/reactos?rev=56056&view=rev
Log:
[GDIPLUS_WINETEST]
- Sync to Wine 1.3.37
Modified:
trunk/rostests/winetests/gdiplus/brush.c
trunk/rostests/winetests/gdiplus/font.c
trunk/rostests/winetests/gdiplus/graphics.c
trunk/rostests/winetests/gdiplus/graphicspath.c
trunk/rostests/winetests/gdiplus/image.c
trunk/rostests/winetests/gdiplus/matrix.c
trunk/rostests/winetests/gdiplus/pathiterator.c
trunk/rostests/winetests/gdiplus/region.c
Modified: trunk/rostests/winetests/gdiplus/brush.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/gdiplus/brush.c…
==============================================================================
--- trunk/rostests/winetests/gdiplus/brush.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/gdiplus/brush.c [iso-8859-1] Mon Mar 5 20:18:32 2012
@@ -286,9 +286,14 @@
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;
@@ -301,7 +306,21 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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)
@@ -400,6 +519,10 @@
REAL res_factors[6] = {0.3f, 0.0f, 0.0f, 0.0f, 0.0f};
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;
Modified: trunk/rostests/winetests/gdiplus/font.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/gdiplus/font.c?…
==============================================================================
--- trunk/rostests/winetests/gdiplus/font.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/gdiplus/font.c [iso-8859-1] Mon Mar 5 20:18:32 2012
@@ -34,6 +34,7 @@
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 @@
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 @@
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 @@
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 @@
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));
-
- stat = GdipGetGenericFontFamilySansSerif (&family);
+ GpFontFamily *family;
+ WCHAR sansname[LF_FACESIZE], serifname[LF_FACESIZE], mononame[LF_FACESIZE];
+ int missingfonts = 0;
+
+ 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);
-
-serif:
- stat = GdipGetGenericFontFamilySerif (&family);
+ check_family("Sans Serif", family, sansname);
+
+ 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);
-
-monospace:
- stat = GdipGetGenericFontFamilyMonospace (&family);
+ missingfonts = 1;
+ else
+ check_family("Serif", family, serifname);
+
+ 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)
Modified: trunk/rostests/winetests/gdiplus/graphics.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/gdiplus/graphic…
==============================================================================
--- trunk/rostests/winetests/gdiplus/graphics.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/gdiplus/graphics.c [iso-8859-1] Mon Mar 5 20:18:32 2012
@@ -230,6 +230,139 @@
ReleaseDC(hwnd, hdc);
}
+static void test_GdipFillClosedCurve2(void)
+{
+ GpStatus status;
+ GpGraphics *graphics = NULL;
+ GpSolidFill *brush = NULL;
+ HDC hdc = GetDC( hwnd );
+ GpPointF points[3];
+
+ points[0].X = 0;
+ points[0].Y = 0;
+
+ points[1].X = 40;
+ points[1].Y = 20;
+
+ points[2].X = 10;
+ points[2].Y = 40;
+
+ /* make a graphics object and brush object */
+ ok(hdc != NULL, "Expected HDC to be initialized\n");
+
+ status = GdipCreateFromHDC(hdc, &graphics);
+ expect(Ok, status);
+ ok(graphics != NULL, "Expected graphics to be initialized\n");
+
+ GdipCreateSolidFill((ARGB)0xdeadbeef, &brush);
+
+ /* InvalidParameter cases: null graphics, null brush, null points */
+ status = GdipFillClosedCurve2(NULL, NULL, NULL, 3, 0.5, FillModeAlternate);
+ expect(InvalidParameter, status);
+
+ status = GdipFillClosedCurve2(graphics, NULL, NULL, 3, 0.5, FillModeAlternate);
+ expect(InvalidParameter, status);
+
+ status = GdipFillClosedCurve2(NULL, (GpBrush*)brush, NULL, 3, 0.5,
FillModeAlternate);
+ expect(InvalidParameter, status);
+
+ status = GdipFillClosedCurve2(NULL, NULL, points, 3, 0.5, FillModeAlternate);
+ expect(InvalidParameter, status);
+
+ status = GdipFillClosedCurve2(graphics, (GpBrush*)brush, NULL, 3, 0.5,
FillModeAlternate);
+ expect(InvalidParameter, status);
+
+ status = GdipFillClosedCurve2(graphics, NULL, points, 3, 0.5, FillModeAlternate);
+ expect(InvalidParameter, status);
+
+ status = GdipFillClosedCurve2(NULL, (GpBrush*)brush, points, 3, 0.5,
FillModeAlternate);
+ expect(InvalidParameter, status);
+
+ /* InvalidParameter cases: invalid count */
+ status = GdipFillClosedCurve2(graphics, (GpBrush*)brush, points, -1, 0.5,
FillModeAlternate);
+ expect(InvalidParameter, status);
+
+ status = GdipFillClosedCurve2(graphics, (GpBrush*)brush, points, 0, 0.5,
FillModeAlternate);
+ expect(InvalidParameter, status);
+
+ /* Valid test cases */
+ status = GdipFillClosedCurve2(graphics, (GpBrush*)brush, points, 1, 0.5,
FillModeAlternate);
+ expect(Ok, status);
+
+ status = GdipFillClosedCurve2(graphics, (GpBrush*)brush, points, 2, 0.5,
FillModeAlternate);
+ expect(Ok, status);
+
+ status = GdipFillClosedCurve2(graphics, (GpBrush*)brush, points, 3, 0.5,
FillModeAlternate);
+ expect(Ok, status);
+
+ GdipDeleteGraphics(graphics);
+ GdipDeleteBrush((GpBrush*)brush);
+
+ ReleaseDC(hwnd, hdc);
+}
+
+static void test_GdipFillClosedCurve2I(void)
+{
+ GpStatus status;
+ GpGraphics *graphics = NULL;
+ GpSolidFill *brush = NULL;
+ HDC hdc = GetDC( hwnd );
+ GpPoint points[3];
+
+ points[0].X = 0;
+ points[0].Y = 0;
+
+ points[1].X = 40;
+ points[1].Y = 20;
+
+ points[2].X = 10;
+ points[2].Y = 40;
+
+ /* make a graphics object and brush object */
+ ok(hdc != NULL, "Expected HDC to be initialized\n");
+
+ status = GdipCreateFromHDC(hdc, &graphics);
+ expect(Ok, status);
+ ok(graphics != NULL, "Expected graphics to be initialized\n");
+
+ GdipCreateSolidFill((ARGB)0xdeadbeef, &brush);
+
+ /* InvalidParameter cases: null graphics, null brush */
+ /* Note: GdipFillClosedCurveI and GdipFillClosedCurve2I hang in Windows
+ when points == NULL, so don't test this condition */
+ status = GdipFillClosedCurve2I(NULL, NULL, points, 3, 0.5, FillModeAlternate);
+ expect(InvalidParameter, status);
+
+ status = GdipFillClosedCurve2I(graphics, NULL, points, 3, 0.5, FillModeAlternate);
+ expect(InvalidParameter, status);
+
+ status = GdipFillClosedCurve2I(NULL, (GpBrush*)brush, points, 3, 0.5,
FillModeAlternate);
+ expect(InvalidParameter, status);
+
+ /* InvalidParameter cases: invalid count */
+ status = GdipFillClosedCurve2I(graphics, (GpBrush*)brush, points, 0, 0.5,
FillModeAlternate);
+ expect(InvalidParameter, status);
+
+ /* OutOfMemory cases: large (unsigned) int */
+ status = GdipFillClosedCurve2I(graphics, (GpBrush*)brush, points, -1, 0.5,
FillModeAlternate);
+ expect(OutOfMemory, status);
+
+ /* Valid test cases */
+ status = GdipFillClosedCurve2I(graphics, (GpBrush*)brush, points, 1, 0.5,
FillModeAlternate);
+ expect(Ok, status);
+
+ status = GdipFillClosedCurve2I(graphics, (GpBrush*)brush, points, 2, 0.5,
FillModeAlternate);
+ expect(Ok, status);
+
+ status = GdipFillClosedCurve2I(graphics, (GpBrush*)brush, points, 3, 0.5,
FillModeAlternate);
+ expect(Ok, status);
+
+ GdipDeleteGraphics(graphics);
+ GdipDeleteBrush((GpBrush*)brush);
+
+ ReleaseDC(hwnd, hdc);
+}
+
static void test_GdipDrawArc(void)
{
GpStatus status;
@@ -413,8 +546,9 @@
status = GdipBeginContainer2(graphics, &cont1);
expect(Ok, status);
- GdipCreateMatrix2(defTrans[0], defTrans[1], defTrans[2], defTrans[3],
+ status = GdipCreateMatrix2(defTrans[0], defTrans[1], defTrans[2], defTrans[3],
defTrans[4], defTrans[5], &transform);
+ expect(Ok, status);
GdipSetWorldTransform(graphics, transform);
GdipDeleteMatrix(transform);
transform = NULL;
@@ -422,7 +556,8 @@
status = GdipBeginContainer2(graphics, &cont2);
expect(Ok, status);
- GdipCreateMatrix2(10, 20, 30, 40, 50, 60, &transform);
+ status = GdipCreateMatrix2(10, 20, 30, 40, 50, 60, &transform);
+ expect(Ok, status);
GdipSetWorldTransform(graphics, transform);
GdipDeleteMatrix(transform);
transform = NULL;
@@ -430,7 +565,8 @@
status = GdipEndContainer(graphics, cont2);
expect(Ok, status);
- GdipCreateMatrix(&transform);
+ status = GdipCreateMatrix(&transform);
+ expect(Ok, status);
GdipGetWorldTransform(graphics, transform);
GdipGetMatrixElements(transform, elems);
ok(fabs(defTrans[0] - elems[0]) < 0.0001 &&
@@ -460,6 +596,7 @@
GdipSetClipRect(graphics, 2, 4, 6, 8, CombineModeReplace);
status = GdipEndContainer(graphics, cont2);
+ expect(Ok, status);
GdipGetClipBounds(graphics, &clip);
ok(fabs(defClip[0] - clip.X) < 0.0001 &&
@@ -471,6 +608,7 @@
clip.X, clip.Y, clip.Width, clip.Height);
status = GdipEndContainer(graphics, cont1);
+ expect(Ok, status);
/* nesting */
status = GdipBeginContainer2(graphics, &cont1);
@@ -995,6 +1133,60 @@
ReleaseDC(hwnd, hdc);
}
+static void test_GdipDrawImagePointsRect(void)
+{
+ GpStatus status;
+ GpGraphics *graphics = NULL;
+ GpPointF ptf[4];
+ GpBitmap *bm = NULL;
+ BYTE rbmi[sizeof(BITMAPINFOHEADER)];
+ BYTE buff[400];
+ BITMAPINFO *bmi = (BITMAPINFO*)rbmi;
+ HDC hdc = GetDC( hwnd );
+ if (!hdc)
+ return;
+
+ memset(rbmi, 0, sizeof(rbmi));
+ bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ bmi->bmiHeader.biWidth = 10;
+ bmi->bmiHeader.biHeight = 10;
+ bmi->bmiHeader.biPlanes = 1;
+ bmi->bmiHeader.biBitCount = 32;
+ bmi->bmiHeader.biCompression = BI_RGB;
+ status = GdipCreateBitmapFromGdiDib(bmi, buff, &bm);
+ expect(Ok, status);
+ ok(NULL != bm, "Expected bitmap to be initialized\n");
+ status = GdipCreateFromHDC(hdc, &graphics);
+ expect(Ok, status);
+ ptf[0].X = 0;
+ ptf[0].Y = 0;
+ ptf[1].X = 10;
+ ptf[1].Y = 0;
+ ptf[2].X = 0;
+ ptf[2].Y = 10;
+ ptf[3].X = 10;
+ ptf[3].Y = 10;
+ status = GdipDrawImagePointsRect(graphics, (GpImage*)bm, ptf, 4, 0, 0, 10, 10,
UnitPixel, NULL, NULL, NULL);
+ expect(NotImplemented, status);
+ status = GdipDrawImagePointsRect(graphics, (GpImage*)bm, ptf, 2, 0, 0, 10, 10,
UnitPixel, NULL, NULL, NULL);
+ expect(InvalidParameter, status);
+ status = GdipDrawImagePointsRect(graphics, (GpImage*)bm, ptf, 3, 0, 0, 10, 10,
UnitPixel, NULL, NULL, NULL);
+ expect(Ok, status);
+ status = GdipDrawImagePointsRect(graphics, NULL, ptf, 3, 0, 0, 10, 10, UnitPixel,
NULL, NULL, NULL);
+ expect(InvalidParameter, status);
+ status = GdipDrawImagePointsRect(graphics, (GpImage*)bm, NULL, 3, 0, 0, 10, 10,
UnitPixel, NULL, NULL, NULL);
+ expect(InvalidParameter, status);
+ status = GdipDrawImagePointsRect(graphics, (GpImage*)bm, ptf, 3, 0, 0, 0, 0,
UnitPixel, NULL, NULL, NULL);
+ expect(Ok, status);
+ memset(ptf, 0, sizeof(ptf));
+ status = GdipDrawImagePointsRect(graphics, (GpImage*)bm, ptf, 3, 0, 0, 10, 10,
UnitPixel, NULL, NULL, NULL);
+ expect(Ok, status);
+
+ GdipDisposeImage((GpImage*)bm);
+ GdipDeleteGraphics(graphics);
+ ReleaseDC(hwnd, hdc);
+}
+
static void test_GdipDrawLinesI(void)
{
GpStatus status;
@@ -1043,6 +1235,139 @@
GdipFree(ptf);
GdipDeletePen(pen);
GdipDeleteGraphics(graphics);
+
+ ReleaseDC(hwnd, hdc);
+}
+
+static void test_GdipFillClosedCurve(void)
+{
+ GpStatus status;
+ GpGraphics *graphics = NULL;
+ GpSolidFill *brush = NULL;
+ HDC hdc = GetDC( hwnd );
+ GpPointF points[3];
+
+ points[0].X = 0;
+ points[0].Y = 0;
+
+ points[1].X = 40;
+ points[1].Y = 20;
+
+ points[2].X = 10;
+ points[2].Y = 40;
+
+ /* make a graphics object and brush object */
+ ok(hdc != NULL, "Expected HDC to be initialized\n");
+
+ status = GdipCreateFromHDC(hdc, &graphics);
+ expect(Ok, status);
+ ok(graphics != NULL, "Expected graphics to be initialized\n");
+
+ GdipCreateSolidFill((ARGB)0xdeadbeef, &brush);
+
+ /* InvalidParameter cases: null graphics, null brush, null points */
+ status = GdipFillClosedCurve(NULL, NULL, NULL, 3);
+ expect(InvalidParameter, status);
+
+ status = GdipFillClosedCurve(graphics, NULL, NULL, 3);
+ expect(InvalidParameter, status);
+
+ status = GdipFillClosedCurve(NULL, (GpBrush*)brush, NULL, 3);
+ expect(InvalidParameter, status);
+
+ status = GdipFillClosedCurve(NULL, NULL, points, 3);
+ expect(InvalidParameter, status);
+
+ status = GdipFillClosedCurve(graphics, (GpBrush*)brush, NULL, 3);
+ expect(InvalidParameter, status);
+
+ status = GdipFillClosedCurve(graphics, NULL, points, 3);
+ expect(InvalidParameter, status);
+
+ status = GdipFillClosedCurve(NULL, (GpBrush*)brush, points, 3);
+ expect(InvalidParameter, status);
+
+ /* InvalidParameter cases: invalid count */
+ status = GdipFillClosedCurve(graphics, (GpBrush*)brush, points, -1);
+ expect(InvalidParameter, status);
+
+ status = GdipFillClosedCurve(graphics, (GpBrush*)brush, points, 0);
+ expect(InvalidParameter, status);
+
+ /* Valid test cases */
+ status = GdipFillClosedCurve(graphics, (GpBrush*)brush, points, 1);
+ expect(Ok, status);
+
+ status = GdipFillClosedCurve(graphics, (GpBrush*)brush, points, 2);
+ expect(Ok, status);
+
+ status = GdipFillClosedCurve(graphics, (GpBrush*)brush, points, 3);
+ expect(Ok, status);
+
+ GdipDeleteGraphics(graphics);
+ GdipDeleteBrush((GpBrush*)brush);
+
+ ReleaseDC(hwnd, hdc);
+}
+
+static void test_GdipFillClosedCurveI(void)
+{
+ GpStatus status;
+ GpGraphics *graphics = NULL;
+ GpSolidFill *brush = NULL;
+ HDC hdc = GetDC( hwnd );
+ GpPoint points[3];
+
+ points[0].X = 0;
+ points[0].Y = 0;
+
+ points[1].X = 40;
+ points[1].Y = 20;
+
+ points[2].X = 10;
+ points[2].Y = 40;
+
+ /* make a graphics object and brush object */
+ ok(hdc != NULL, "Expected HDC to be initialized\n");
+
+ status = GdipCreateFromHDC(hdc, &graphics);
+ expect(Ok, status);
+ ok(graphics != NULL, "Expected graphics to be initialized\n");
+
+ GdipCreateSolidFill((ARGB)0xdeadbeef, &brush);
+
+ /* InvalidParameter cases: null graphics, null brush */
+ /* Note: GdipFillClosedCurveI and GdipFillClosedCurve2I hang in Windows
+ when points == NULL, so don't test this condition */
+ status = GdipFillClosedCurveI(NULL, NULL, points, 3);
+ expect(InvalidParameter, status);
+
+ status = GdipFillClosedCurveI(graphics, NULL, points, 3);
+ expect(InvalidParameter, status);
+
+ status = GdipFillClosedCurveI(NULL, (GpBrush*)brush, points, 3);
+ expect(InvalidParameter, status);
+
+ /* InvalidParameter cases: invalid count */
+ status = GdipFillClosedCurveI(graphics, (GpBrush*)brush, points, 0);
+ expect(InvalidParameter, status);
+
+ /* OutOfMemory cases: large (unsigned) int */
+ status = GdipFillClosedCurveI(graphics, (GpBrush*)brush, points, -1);
+ expect(OutOfMemory, status);
+
+ /* Valid test cases */
+ status = GdipFillClosedCurveI(graphics, (GpBrush*)brush, points, 1);
+ expect(Ok, status);
+
+ status = GdipFillClosedCurveI(graphics, (GpBrush*)brush, points, 2);
+ expect(Ok, status);
+
+ status = GdipFillClosedCurveI(graphics, (GpBrush*)brush, points, 3);
+ expect(Ok, status);
+
+ GdipDeleteGraphics(graphics);
+ GdipDeleteBrush((GpBrush*)brush);
ReleaseDC(hwnd, hdc);
}
@@ -1108,7 +1433,8 @@
rectf[i].Width = (REAL)rect[i].Width;
}
- GdipCreateMatrix(&m);
+ status = GdipCreateMatrix(&m);
+ expect(Ok, status);
GdipCreateRegion(®ion);
GdipCreateSolidFill((ARGB)0xdeadbeef, &brush);
GdipCreatePath(FillModeAlternate, &path);
@@ -1148,189 +1474,194 @@
expect(ObjectBusy, status);
/* try all Graphics calls here */
- status = Ok;
status = GdipDrawArc(graphics, pen, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipDrawArcI(graphics, pen, 0, 0, 1, 1, 0.0, 0.0);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipDrawBezier(graphics, pen, 0.0, 10.0, 20.0, 15.0, 35.0, -10.0, 10.0,
10.0);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipDrawBezierI(graphics, pen, 0, 0, 0, 0, 0, 0, 0, 0);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipDrawBeziers(graphics, pen, ptf, 5);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipDrawBeziersI(graphics, pen, pt, 5);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipDrawClosedCurve(graphics, pen, ptf, 5);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipDrawClosedCurveI(graphics, pen, pt, 5);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipDrawClosedCurve2(graphics, pen, ptf, 5, 1.0);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipDrawClosedCurve2I(graphics, pen, pt, 5, 1.0);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipDrawCurve(graphics, pen, ptf, 5);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipDrawCurveI(graphics, pen, pt, 5);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipDrawCurve2(graphics, pen, ptf, 5, 1.0);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipDrawCurve2I(graphics, pen, pt, 5, 1.0);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipDrawEllipse(graphics, pen, 0.0, 0.0, 100.0, 50.0);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipDrawEllipseI(graphics, pen, 0, 0, 100, 50);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
/* GdipDrawImage/GdipDrawImageI */
/* GdipDrawImagePointsRect/GdipDrawImagePointsRectI */
/* GdipDrawImageRectRect/GdipDrawImageRectRectI */
/* GdipDrawImageRect/GdipDrawImageRectI */
status = GdipDrawLine(graphics, pen, 0.0, 0.0, 100.0, 200.0);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipDrawLineI(graphics, pen, 0, 0, 100, 200);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipDrawLines(graphics, pen, ptf, 5);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipDrawLinesI(graphics, pen, pt, 5);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipDrawPath(graphics, pen, path);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipDrawPie(graphics, pen, 0.0, 0.0, 100.0, 100.0, 0.0, 90.0);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipDrawPieI(graphics, pen, 0, 0, 100, 100, 0.0, 90.0);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipDrawRectangle(graphics, pen, 0.0, 0.0, 100.0, 300.0);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipDrawRectangleI(graphics, pen, 0, 0, 100, 300);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipDrawRectangles(graphics, pen, rectf, 2);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipDrawRectanglesI(graphics, pen, rect, 2);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
/* GdipDrawString */
status = GdipFillClosedCurve2(graphics, (GpBrush*)brush, ptf, 5, 1.0,
FillModeAlternate);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipFillClosedCurve2I(graphics, (GpBrush*)brush, pt, 5, 1.0,
FillModeAlternate);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
+ status = GdipFillClosedCurve(graphics, (GpBrush*)brush, ptf, 5);
+ expect(ObjectBusy, status);
+ status = GdipFillClosedCurveI(graphics, (GpBrush*)brush, pt, 5);
+ expect(ObjectBusy, status);
status = GdipFillEllipse(graphics, (GpBrush*)brush, 0.0, 0.0, 100.0, 100.0);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipFillEllipseI(graphics, (GpBrush*)brush, 0, 0, 100, 100);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipFillPath(graphics, (GpBrush*)brush, path);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipFillPie(graphics, (GpBrush*)brush, 0.0, 0.0, 100.0, 100.0, 0.0, 15.0);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipFillPieI(graphics, (GpBrush*)brush, 0, 0, 100, 100, 0.0, 15.0);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipFillPolygon(graphics, (GpBrush*)brush, ptf, 5, FillModeAlternate);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipFillPolygonI(graphics, (GpBrush*)brush, pt, 5, FillModeAlternate);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipFillPolygon2(graphics, (GpBrush*)brush, ptf, 5);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipFillPolygon2I(graphics, (GpBrush*)brush, pt, 5);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipFillRectangle(graphics, (GpBrush*)brush, 0.0, 0.0, 100.0, 100.0);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipFillRectangleI(graphics, (GpBrush*)brush, 0, 0, 100, 100);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipFillRectangles(graphics, (GpBrush*)brush, rectf, 2);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipFillRectanglesI(graphics, (GpBrush*)brush, rect, 2);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipFillRegion(graphics, (GpBrush*)brush, region);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipFlush(graphics, FlushIntentionFlush);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipGetClipBounds(graphics, rectf);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipGetClipBoundsI(graphics, rect);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipGetCompositingMode(graphics, &compmode);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipGetCompositingQuality(graphics, &quality);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipGetInterpolationMode(graphics, &intmode);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipGetNearestColor(graphics, &color);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipGetPageScale(graphics, &r);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipGetPageUnit(graphics, &unit);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipGetPixelOffsetMode(graphics, &offsetmode);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipGetSmoothingMode(graphics, &smoothmode);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipGetTextRenderingHint(graphics, &texthint);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipGetWorldTransform(graphics, m);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipGraphicsClear(graphics, 0xdeadbeef);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipIsVisiblePoint(graphics, 0.0, 0.0, &res);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipIsVisiblePointI(graphics, 0, 0, &res);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
/* GdipMeasureCharacterRanges */
/* GdipMeasureString */
status = GdipResetClip(graphics);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipResetWorldTransform(graphics);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
/* GdipRestoreGraphics */
status = GdipRotateWorldTransform(graphics, 15.0, MatrixOrderPrepend);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
/* GdipSaveGraphics */
status = GdipScaleWorldTransform(graphics, 1.0, 1.0, MatrixOrderPrepend);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipSetCompositingMode(graphics, CompositingModeSourceOver);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipSetCompositingQuality(graphics, CompositingQualityDefault);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipSetInterpolationMode(graphics, InterpolationModeDefault);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipSetPageScale(graphics, 1.0);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipSetPageUnit(graphics, UnitWorld);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipSetPixelOffsetMode(graphics, PixelOffsetModeDefault);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipSetSmoothingMode(graphics, SmoothingModeDefault);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipSetTextRenderingHint(graphics, TextRenderingHintSystemDefault);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipSetWorldTransform(graphics, m);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipTranslateWorldTransform(graphics, 0.0, 0.0, MatrixOrderPrepend);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipSetClipHrgn(graphics, hrgn, CombineModeReplace);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipSetClipPath(graphics, path, CombineModeReplace);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipSetClipRect(graphics, 0.0, 0.0, 10.0, 10.0, CombineModeReplace);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipSetClipRectI(graphics, 0, 0, 10, 10, CombineModeReplace);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipSetClipRegion(graphics, clip, CombineModeReplace);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipTranslateClip(graphics, 0.0, 0.0);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipTranslateClipI(graphics, 0, 0);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipDrawPolygon(graphics, pen, ptf, 5);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipDrawPolygonI(graphics, pen, pt, 5);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipGetDpiX(graphics, &r);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipGetDpiY(graphics, &r);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipMultiplyWorldTransform(graphics, m, MatrixOrderPrepend);
+ expect(ObjectBusy, status);
status = GdipGetClip(graphics, region);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
status = GdipTransformPoints(graphics, CoordinateSpacePage, CoordinateSpaceWorld,
ptf, 5);
- expect(ObjectBusy, status); status = Ok;
+ expect(ObjectBusy, status);
+
/* try to delete before release */
status = GdipDeleteGraphics(graphics);
expect(ObjectBusy, status);
@@ -1487,6 +1818,7 @@
rect.Height = rect.Width = 100.0;
status = GdipCreateRegionRect(&rect, &clip);
+ expect(Ok, status);
/* NULL arguments */
status = GdipGetClip(NULL, NULL);
@@ -1608,6 +1940,7 @@
status = GdipGetTextContrast(graphics, NULL);
expect(InvalidParameter, status);
status = GdipGetTextContrast(graphics, &contrast);
+ expect(Ok, status);
expect(4, contrast);
GdipDeleteGraphics(graphics);
@@ -1625,6 +1958,8 @@
LOGFONTA logfont;
HDC hdc = GetDC( hwnd );
static const WCHAR string[] = {'T','e','s','t',0};
+ static const PointF positions[4] = {{0,0}, {1,1}, {2,2}, {3,3}};
+ GpMatrix *matrix;
memset(&logfont,0,sizeof(logfont));
strcpy(logfont.lfFaceName,"Arial");
@@ -1656,6 +1991,34 @@
status = GdipDrawString(graphics, string, 4, fnt, &rect, format, brush);
expect(Ok, status);
+ status = GdipCreateMatrix(&matrix);
+ expect(Ok, status);
+
+ status = GdipDrawDriverString(NULL, string, 4, fnt, brush, positions,
DriverStringOptionsCmapLookup, matrix);
+ expect(InvalidParameter, status);
+
+ status = GdipDrawDriverString(graphics, NULL, 4, fnt, brush, positions,
DriverStringOptionsCmapLookup, matrix);
+ expect(InvalidParameter, status);
+
+ status = GdipDrawDriverString(graphics, string, 4, NULL, brush, positions,
DriverStringOptionsCmapLookup, matrix);
+ expect(InvalidParameter, status);
+
+ status = GdipDrawDriverString(graphics, string, 4, fnt, NULL, positions,
DriverStringOptionsCmapLookup, matrix);
+ expect(InvalidParameter, status);
+
+ status = GdipDrawDriverString(graphics, string, 4, fnt, brush, NULL,
DriverStringOptionsCmapLookup, matrix);
+ expect(InvalidParameter, status);
+
+ status = GdipDrawDriverString(graphics, string, 4, fnt, brush, positions,
DriverStringOptionsCmapLookup|0x10, matrix);
+ expect(Ok, status);
+
+ status = GdipDrawDriverString(graphics, string, 4, fnt, brush, positions,
DriverStringOptionsCmapLookup, NULL);
+ expect(Ok, status);
+
+ status = GdipDrawDriverString(graphics, string, 4, fnt, brush, positions,
DriverStringOptionsCmapLookup, matrix);
+ expect(Ok, status);
+
+ GdipDeleteMatrix(matrix);
GdipDeleteGraphics(graphics);
GdipDeleteBrush(brush);
GdipDeleteFont(fnt);
@@ -1887,6 +2250,8 @@
GpGraphics *graphics = NULL;
GpBitmap *bitmap = NULL;
BYTE bits[48] = {0};
+ HDC hdc=NULL;
+ COLORREF color;
status = GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB, bits,
&bitmap);
expect(Ok, status);
@@ -1900,7 +2265,51 @@
GdipDeleteGraphics(graphics);
/* drawing writes to the memory provided */
- todo_wine expect(0x68, bits[10]);
+ expect(0x68, bits[10]);
+
+ status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
+ expect(Ok, status);
+
+ status = GdipGetDC(graphics, &hdc);
+ expect(Ok, status);
+ ok(hdc != NULL, "got NULL hdc\n");
+
+ color = GetPixel(hdc, 0, 0);
+ /* The HDC is write-only, and native fills with a solid color to figure out
+ * which pixels have changed. */
+ todo_wine expect(0x0c0b0d, color);
+
+ SetPixel(hdc, 0, 0, 0x797979);
+ SetPixel(hdc, 1, 0, 0x0c0b0d);
+
+ status = GdipReleaseDC(graphics, hdc);
+ expect(Ok, status);
+
+ GdipDeleteGraphics(graphics);
+
+ expect(0x79, bits[0]);
+ todo_wine expect(0x68, bits[3]);
+
+ GdipDisposeImage((GpImage*)bitmap);
+
+ /* We get the same kind of write-only HDC for a "normal" bitmap */
+ status = GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB, NULL,
&bitmap);
+ expect(Ok, status);
+
+ status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
+ expect(Ok, status);
+
+ status = GdipGetDC(graphics, &hdc);
+ expect(Ok, status);
+ ok(hdc != NULL, "got NULL hdc\n");
+
+ color = GetPixel(hdc, 0, 0);
+ todo_wine expect(0x0c0b0d, color);
+
+ status = GdipReleaseDC(graphics, hdc);
+ expect(Ok, status);
+
+ GdipDeleteGraphics(graphics);
GdipDisposeImage((GpImage*)bitmap);
}
@@ -2347,33 +2756,42 @@
status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat48bppRGB, NULL,
&bitmap);
expect(Ok, status);
- status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
- expect(Ok, status);
- status = GdipGetNearestColor(graphics, &color);
- expect(Ok, status);
- expect(0xdeadbeef, color);
- GdipDeleteGraphics(graphics);
- GdipDisposeImage((GpImage*)bitmap);
+ if (status == Ok)
+ {
+ status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
+ expect(Ok, status);
+ status = GdipGetNearestColor(graphics, &color);
+ expect(Ok, status);
+ expect(0xdeadbeef, color);
+ GdipDeleteGraphics(graphics);
+ GdipDisposeImage((GpImage*)bitmap);
+ }
status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppARGB, NULL,
&bitmap);
expect(Ok, status);
- status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
- expect(Ok, status);
- status = GdipGetNearestColor(graphics, &color);
- expect(Ok, status);
- expect(0xdeadbeef, color);
- GdipDeleteGraphics(graphics);
- GdipDisposeImage((GpImage*)bitmap);
+ if (status == Ok)
+ {
+ status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
+ expect(Ok, status);
+ status = GdipGetNearestColor(graphics, &color);
+ expect(Ok, status);
+ expect(0xdeadbeef, color);
+ GdipDeleteGraphics(graphics);
+ GdipDisposeImage((GpImage*)bitmap);
+ }
status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat64bppPARGB, NULL,
&bitmap);
expect(Ok, status);
- status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
- expect(Ok, status);
- status = GdipGetNearestColor(graphics, &color);
- expect(Ok, status);
- expect(0xdeadbeef, color);
- GdipDeleteGraphics(graphics);
- GdipDisposeImage((GpImage*)bitmap);
+ if (status == Ok)
+ {
+ status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
+ expect(Ok, status);
+ status = GdipGetNearestColor(graphics, &color);
+ expect(Ok, status);
+ expect(0xdeadbeef, color);
+ GdipDeleteGraphics(graphics);
+ GdipDisposeImage((GpImage*)bitmap);
+ }
status = GdipCreateBitmapFromScan0(10, 10, 10, PixelFormat16bppRGB565, NULL,
&bitmap);
expect(Ok, status);
@@ -2413,6 +2831,7 @@
HDC hdc = GetDC( hwnd );
const WCHAR fontname[] =
{'T','a','h','o','m','a',0};
const WCHAR teststring[] = {'M','M','
','M','\n','M',0};
+ const WCHAR teststring2[] = {'j',0};
REAL char_width, char_height;
INT codepointsfitted, linesfilled;
GpStringFormat *format;
@@ -2420,6 +2839,8 @@
GpRegion *regions[4] = {0};
BOOL region_isempty[4];
int i;
+ PointF position;
+ GpMatrix *identity;
ok(hdc != NULL, "Expected HDC to be initialized\n");
status = GdipCreateFromHDC(hdc, &graphics);
@@ -2619,6 +3040,96 @@
for (i=0; i<4; i++)
GdipDeleteRegion(regions[i]);
+ status = GdipCreateMatrix(&identity);
+ expect(Ok, status);
+
+ position.X = 0;
+ position.Y = 0;
+
+ rc.X = 0;
+ rc.Y = 0;
+ rc.Width = 0;
+ rc.Height = 0;
+ status = GdipMeasureDriverString(NULL, teststring, 6, font, &position,
+ DriverStringOptionsCmapLookup|DriverStringOptionsRealizedAdvance,
+ identity, &rc);
+ expect(InvalidParameter, status);
+
+ status = GdipMeasureDriverString(graphics, NULL, 6, font, &position,
+ DriverStringOptionsCmapLookup|DriverStringOptionsRealizedAdvance,
+ identity, &rc);
+ expect(InvalidParameter, status);
+
+ status = GdipMeasureDriverString(graphics, teststring, 6, NULL, &position,
+ DriverStringOptionsCmapLookup|DriverStringOptionsRealizedAdvance,
+ identity, &rc);
+ expect(InvalidParameter, status);
+
+ status = GdipMeasureDriverString(graphics, teststring, 6, font, NULL,
+ DriverStringOptionsCmapLookup|DriverStringOptionsRealizedAdvance,
+ identity, &rc);
+ expect(InvalidParameter, status);
+
+ status = GdipMeasureDriverString(graphics, teststring, 6, font, &position,
+ 0x100, identity, &rc);
+ expect(Ok, status);
+
+ status = GdipMeasureDriverString(graphics, teststring, 6, font, &position,
+ DriverStringOptionsCmapLookup|DriverStringOptionsRealizedAdvance,
+ NULL, &rc);
+ expect(Ok, status);
+
+ status = GdipMeasureDriverString(graphics, teststring, 6, font, &position,
+ DriverStringOptionsCmapLookup|DriverStringOptionsRealizedAdvance,
+ identity, NULL);
+ expect(InvalidParameter, status);
+
+ rc.X = 0;
+ rc.Y = 0;
+ rc.Width = 0;
+ rc.Height = 0;
+ status = GdipMeasureDriverString(graphics, teststring, 6, font, &position,
+ DriverStringOptionsCmapLookup|DriverStringOptionsRealizedAdvance,
+ identity, &rc);
+ expect(Ok, status);
+
+ expectf(0.0, rc.X);
+ ok(rc.Y < 0.0, "unexpected Y %0.2f\n", rc.Y);
+ ok(rc.Width > 0.0, "unexpected Width %0.2f\n", rc.Width);
+ ok(rc.Height > 0.0, "unexpected Y %0.2f\n", rc.Y);
+
+ char_width = rc.Width;
+ char_height = rc.Height;
+
+ rc.X = 0;
+ rc.Y = 0;
+ rc.Width = 0;
+ rc.Height = 0;
+ status = GdipMeasureDriverString(graphics, teststring, 4, font, &position,
+ DriverStringOptionsCmapLookup|DriverStringOptionsRealizedAdvance,
+ identity, &rc);
+ expect(Ok, status);
+
+ expectf(0.0, rc.X);
+ ok(rc.Y < 0.0, "unexpected Y %0.2f\n", rc.Y);
+ ok(rc.Width < char_width, "got Width %0.2f, expecting less than
%0.2f\n", rc.Width, char_width);
+ expectf(char_height, rc.Height);
+
+ rc.X = 0;
+ rc.Y = 0;
+ rc.Width = 0;
+ rc.Height = 0;
+ status = GdipMeasureDriverString(graphics, teststring2, 1, font, &position,
+ DriverStringOptionsCmapLookup|DriverStringOptionsRealizedAdvance,
+ identity, &rc);
+ expect(Ok, status);
+
+ expectf(rc.X, 0.0);
+ ok(rc.Y < 0.0, "unexpected Y %0.2f\n", rc.Y);
+ ok(rc.Width > 0, "unexpected Width %0.2f\n", rc.Width);
+ expectf(rc.Height, char_height);
+
+ GdipDeleteMatrix(identity);
GdipDeleteStringFormat(format);
GdipDeleteBrush(brush);
GdipDeleteFont(font);
@@ -2626,6 +3137,171 @@
GdipDeleteGraphics(graphics);
ReleaseDC(hwnd, hdc);
+}
+
+static void test_get_set_interpolation(void)
+{
+ GpGraphics *graphics;
+ HDC hdc = GetDC( hwnd );
+ GpStatus status;
+ InterpolationMode mode;
+
+ ok(hdc != NULL, "Expected HDC to be initialized\n");
+ status = GdipCreateFromHDC(hdc, &graphics);
+ expect(Ok, status);
+ ok(graphics != NULL, "Expected graphics to be initialized\n");
+
+ status = GdipGetInterpolationMode(NULL, &mode);
+ expect(InvalidParameter, status);
+
+ if (0)
+ {
+ /* Crashes on Windows XP */
+ status = GdipGetInterpolationMode(graphics, NULL);
+ expect(InvalidParameter, status);
+ }
+
+ status = GdipSetInterpolationMode(NULL, InterpolationModeNearestNeighbor);
+ expect(InvalidParameter, status);
+
+ /* out of range */
+ status = GdipSetInterpolationMode(graphics, InterpolationModeHighQualityBicubic+1);
+ expect(InvalidParameter, status);
+
+ status = GdipSetInterpolationMode(graphics, InterpolationModeInvalid);
+ expect(InvalidParameter, status);
+
+ status = GdipGetInterpolationMode(graphics, &mode);
+ expect(Ok, status);
+ expect(InterpolationModeBilinear, mode);
+
+ status = GdipSetInterpolationMode(graphics, InterpolationModeNearestNeighbor);
+ expect(Ok, status);
+
+ status = GdipGetInterpolationMode(graphics, &mode);
+ expect(Ok, status);
+ expect(InterpolationModeNearestNeighbor, mode);
+
+ status = GdipSetInterpolationMode(graphics, InterpolationModeDefault);
+ expect(Ok, status);
+
+ status = GdipGetInterpolationMode(graphics, &mode);
+ expect(Ok, status);
+ expect(InterpolationModeBilinear, mode);
+
+ status = GdipSetInterpolationMode(graphics, InterpolationModeLowQuality);
+ expect(Ok, status);
+
+ status = GdipGetInterpolationMode(graphics, &mode);
+ expect(Ok, status);
+ expect(InterpolationModeBilinear, mode);
+
+ status = GdipSetInterpolationMode(graphics, InterpolationModeHighQuality);
+ expect(Ok, status);
+
+ status = GdipGetInterpolationMode(graphics, &mode);
+ expect(Ok, status);
+ expect(InterpolationModeHighQualityBicubic, mode);
+
+ GdipDeleteGraphics(graphics);
+
+ ReleaseDC(hwnd, hdc);
+}
+
+static void test_get_set_textrenderinghint(void)
+{
+ GpGraphics *graphics;
+ HDC hdc = GetDC( hwnd );
+ GpStatus status;
+ TextRenderingHint hint;
+
+ ok(hdc != NULL, "Expected HDC to be initialized\n");
+ status = GdipCreateFromHDC(hdc, &graphics);
+ expect(Ok, status);
+ ok(graphics != NULL, "Expected graphics to be initialized\n");
+
+ status = GdipGetTextRenderingHint(NULL, &hint);
+ expect(InvalidParameter, status);
+
+ status = GdipGetTextRenderingHint(graphics, NULL);
+ expect(InvalidParameter, status);
+
+ status = GdipSetTextRenderingHint(NULL, TextRenderingHintAntiAlias);
+ expect(InvalidParameter, status);
+
+ /* out of range */
+ status = GdipSetTextRenderingHint(graphics, TextRenderingHintClearTypeGridFit+1);
+ expect(InvalidParameter, status);
+
+ status = GdipGetTextRenderingHint(graphics, &hint);
+ expect(Ok, status);
+ expect(TextRenderingHintSystemDefault, hint);
+
+ status = GdipSetTextRenderingHint(graphics, TextRenderingHintSystemDefault);
+ expect(Ok, status);
+
+ status = GdipGetTextRenderingHint(graphics, &hint);
+ expect(Ok, status);
+ expect(TextRenderingHintSystemDefault, hint);
+
+ status = GdipSetTextRenderingHint(graphics, TextRenderingHintAntiAliasGridFit);
+ expect(Ok, status);
+
+ status = GdipGetTextRenderingHint(graphics, &hint);
+ expect(Ok, status);
+ expect(TextRenderingHintAntiAliasGridFit, hint);
+
+ GdipDeleteGraphics(graphics);
+
+ ReleaseDC(hwnd, hdc);
+}
+
+static void test_getdc_scaled(void)
+{
+ GpStatus status;
+ GpGraphics *graphics = NULL;
+ GpBitmap *bitmap = NULL;
+ HDC hdc=NULL;
+ HBRUSH hbrush, holdbrush;
+ ARGB color;
+
+ status = GdipCreateBitmapFromScan0(10, 10, 12, PixelFormat24bppRGB, NULL,
&bitmap);
+ expect(Ok, status);
+
+ status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
+ expect(Ok, status);
+
+ status = GdipScaleWorldTransform(graphics, 2.0, 2.0, MatrixOrderPrepend);
+ expect(Ok, status);
+
+ status = GdipGetDC(graphics, &hdc);
+ expect(Ok, status);
+ ok(hdc != NULL, "got NULL hdc\n");
+
+ hbrush = CreateSolidBrush(RGB(255, 0, 0));
+
+ holdbrush = SelectObject(hdc, hbrush);
+
+ Rectangle(hdc, 2, 2, 6, 6);
+
+ SelectObject(hdc, holdbrush);
+
+ DeleteObject(hbrush);
+
+ status = GdipReleaseDC(graphics, hdc);
+ expect(Ok, status);
+
+ GdipDeleteGraphics(graphics);
+
+ status = GdipBitmapGetPixel(bitmap, 3, 3, &color);
+ expect(Ok, status);
+ expect(0xffff0000, color);
+
+ status = GdipBitmapGetPixel(bitmap, 8, 8, &color);
+ expect(Ok, status);
+ expect(0xff000000, color);
+
+ GdipDisposeImage((GpImage*)bitmap);
}
START_TEST(graphics)
@@ -2656,6 +3332,8 @@
test_constructor_destructor();
test_save_restore();
+ test_GdipFillClosedCurve2();
+ test_GdipFillClosedCurve2I();
test_GdipDrawBezierI();
test_GdipDrawArc();
test_GdipDrawArcI();
@@ -2667,6 +3345,9 @@
test_GdipDrawCurve3I();
test_GdipDrawLineI();
test_GdipDrawLinesI();
+ test_GdipDrawImagePointsRect();
+ test_GdipFillClosedCurve();
+ test_GdipFillClosedCurveI();
test_GdipDrawString();
test_GdipGetNearestColor();
test_GdipGetVisibleClipBounds();
@@ -2681,6 +3362,9 @@
test_textcontrast();
test_fromMemoryBitmap();
test_string_functions();
+ test_get_set_interpolation();
+ test_get_set_textrenderinghint();
+ test_getdc_scaled();
GdiplusShutdown(gdiplusToken);
DestroyWindow( hwnd );
Modified: trunk/rostests/winetests/gdiplus/graphicspath.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/gdiplus/graphic…
==============================================================================
--- trunk/rostests/winetests/gdiplus/graphicspath.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/gdiplus/graphicspath.c [iso-8859-1] Mon Mar 5 20:18:32 2012
@@ -1106,6 +1106,34 @@
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 @@
test_addpie();
test_flatten();
test_isvisible();
+ test_empty_rect();
GdiplusShutdown(gdiplusToken);
}
Modified: trunk/rostests/winetests/gdiplus/image.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/gdiplus/image.c…
==============================================================================
--- trunk/rostests/winetests/gdiplus/image.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/gdiplus/image.c [iso-8859-1] Mon Mar 5 20:18:32 2012
@@ -516,6 +516,8 @@
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,14 +528,32 @@
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);
@@ -542,9 +562,15 @@
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);
@@ -568,6 +594,102 @@
stat = GdipBitmapUnlockBits(bm, &bd);
expect(Ok, stat);
+
+ stat = GdipDisposeImage((GpImage*)bm);
+ expect(Ok, stat);
+ 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);
@@ -609,6 +731,10 @@
expect(Ok, stat);
}
+ stat = GdipBitmapGetPixel(bm, 2, 3, &color);
+ expect(Ok, stat);
+ expect(0xffff0000, color);
+
stat = GdipDisposeImage((GpImage*)bm);
expect(Ok, stat);
@@ -620,6 +746,102 @@
stat = GdipDisposeImage((GpImage*)bm);
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)
{
@@ -635,8 +857,9 @@
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 @@
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;
-
- hbm = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
+ 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.bi, DIB_RGB_COLORS, (void**)&bits, NULL,
0);
ok(hbm != NULL, "CreateDIBSection failed\n");
bits[0] = 0;
@@ -707,15 +931,100 @@
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 @@
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 @@
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 @@
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 @@
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);
@@ -1204,6 +1630,49 @@
DeleteDC(hdc);
expect(0x686868, pixel);
+
+ DeleteObject(hbitmap);
+ }
+
+ 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);
}
@@ -1407,6 +1876,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
}
/* 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 @@
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 @@
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 @@
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 @@
{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 @@
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);
+ stat = GdipCreateBitmapFromScan0(1, 1, 0, PixelFormat32bppARGB, NULL, &bitmap1);
+ expect(Ok, stat);
+
+ stat = GdipCreateBitmapFromScan0(1, 1, 0, PixelFormat32bppARGB, NULL, &bitmap2);
+ expect(Ok, stat);
+
+ stat = GdipBitmapSetPixel(bitmap1, 0, 0, 0xff40ccee);
expect(Ok, stat);
stat = GdipGetImageGraphicsContext((GpImage*)bitmap2, &graphics);
@@ -1680,7 +2156,23 @@
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 @@
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 @@
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 @@
test_SavingImages();
test_encoders();
test_LockBits();
+ test_LockBits_UserBuf();
test_GdipCreateBitmapFromHBITMAP();
test_GdipGetImageFlags();
test_GdipCloneImage();
@@ -2180,6 +2696,7 @@
test_rotateflip();
test_remaptable();
test_colorkey();
+ test_dispose();
GdiplusShutdown(gdiplusToken);
}
Modified: trunk/rostests/winetests/gdiplus/matrix.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/gdiplus/matrix.…
==============================================================================
--- trunk/rostests/winetests/gdiplus/matrix.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/gdiplus/matrix.c [iso-8859-1] Mon Mar 5 20:18:32 2012
@@ -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 @@
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 @@
test_isinvertible();
test_invert();
test_shear();
+ test_constructor3();
GdiplusShutdown(gdiplusToken);
}
Modified: trunk/rostests/winetests/gdiplus/pathiterator.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/gdiplus/pathite…
==============================================================================
--- trunk/rostests/winetests/gdiplus/pathiterator.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/gdiplus/pathiterator.c [iso-8859-1] Mon Mar 5 20:18:32 2012
@@ -124,6 +124,7 @@
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);
Modified: trunk/rostests/winetests/gdiplus/region.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/gdiplus/region.…
==============================================================================
--- trunk/rostests/winetests/gdiplus/region.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/gdiplus/region.c [iso-8859-1] Mon Mar 5 20:18:32 2012
@@ -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
@@ -32,6 +33,9 @@
#define RGNDATA_MAGIC2 0xdbc01002
#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)
@@ -1123,6 +1127,251 @@
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(®ion);
+ expect(Ok, status);
+ status = GdipCreateRegion(®ion2);
+ 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(®ion);
+ 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 @@
test_gethrgn();
test_isequal();
test_translate();
+ test_transform();
+ test_scans();
test_getbounds();
test_isvisiblepoint();
test_isvisiblerect();