Module: wine
Branch: master
Commit: 63bfd40f6177ca6bd54ac5497f84377e914e818b
URL: http://source.winehq.org/git/wine.git/?a=commit;h=63bfd40f6177ca6bd54ac5497…
Author: Evan Stade <estade(a)gmail.com>
Date: Mon Jun 11 11:51:15 2007 -0700
gdiplus: First pen implementation.
---
dlls/gdiplus/Makefile.in | 3 +-
dlls/gdiplus/gdiplus.c | 14 ++++++++
dlls/gdiplus/gdiplus.spec | 4 +-
dlls/gdiplus/gdiplus_private.h | 38 +++++++++++++++++++++
dlls/gdiplus/pen.c | 72 ++++++++++++++++++++++++++++++++++++++++
5 files changed, 128 insertions(+), 3 deletions(-)
diff --git a/dlls/gdiplus/Makefile.in b/dlls/gdiplus/Makefile.in
index f1d5040..a4edb46 100644
--- a/dlls/gdiplus/Makefile.in
+++ b/dlls/gdiplus/Makefile.in
@@ -7,7 +7,8 @@ IMPORTLIB = libgdiplus.$(IMPLIBEXT)
IMPORTS = gdi32 advapi32 kernel32 ntdll
C_SRCS = \
- gdiplus.c
+ gdiplus.c \
+ pen.c
@MAKE_DLL_RULES@
diff --git a/dlls/gdiplus/gdiplus.c b/dlls/gdiplus/gdiplus.c
index 2cb04a6..6b2683a 100644
--- a/dlls/gdiplus/gdiplus.c
+++ b/dlls/gdiplus/gdiplus.c
@@ -79,3 +79,17 @@ void WINGDIPAPI GdipFree(void* ptr)
{
HeapFree(GetProcessHeap(), 0, ptr);
}
+
+COLORREF ARGB2COLORREF(ARGB color)
+{
+ /*
+ Packing of these color structures:
+ COLORREF: 00bbggrr
+ ARGB: aarrggbb
+ FIXME:doesn't handle alpha channel
+ */
+ return (COLORREF)
+ ((color & 0x0000ff) << 16) +
+ (color & 0x00ff00) +
+ ((color & 0xff0000) >> 16);
+}
diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec
index 99b56b8..2bb3ba9 100644
--- a/dlls/gdiplus/gdiplus.spec
+++ b/dlls/gdiplus/gdiplus.spec
@@ -111,7 +111,7 @@
@ stub GdipCreatePathGradientFromPath
@ stub GdipCreatePathGradientI
@ stub GdipCreatePathIter
-@ stub GdipCreatePen1
+@ stdcall GdipCreatePen1(long long long ptr)
@ stub GdipCreatePen2
@ stub GdipCreateRegion
@ stub GdipCreateRegionHrgn
@@ -136,7 +136,7 @@
@ stub GdipDeleteMatrix
@ stub GdipDeletePath
@ stub GdipDeletePathIter
-@ stub GdipDeletePen
+@ stdcall GdipDeletePen(ptr)
@ stub GdipDeletePrivateFontCollection
@ stub GdipDeleteRegion
@ stub GdipDeleteStringFormat
diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h
new file mode 100644
index 0000000..2d3a179
--- /dev/null
+++ b/dlls/gdiplus/gdiplus_private.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2007 Google (Evan Stade)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#ifndef __WINE_GP_PRIVATE_H_
+#define __WINE_GP_PRIVATE_H_
+
+#include "windef.h"
+#include "winbase.h"
+#include "gdiplus.h"
+
+#define GP_DEFAULT_PENSTYLE (PS_GEOMETRIC | PS_ENDCAP_FLAT)
+
+COLORREF ARGB2COLORREF(ARGB color);
+
+struct GpPen{
+ UINT style;
+ COLORREF color;
+ GpUnit unit;
+ REAL width;
+ HPEN gdipen;
+};
+
+#endif
diff --git a/dlls/gdiplus/pen.c b/dlls/gdiplus/pen.c
new file mode 100644
index 0000000..2128d3b
--- /dev/null
+++ b/dlls/gdiplus/pen.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2007 Google (Evan Stade)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "wingdi.h"
+#include "gdiplus.h"
+#include "gdiplus_private.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
+
+GpStatus WINGDIPAPI GdipCreatePen1(ARGB color, FLOAT width, GpUnit unit,
+ GpPen **pen)
+{
+ LOGBRUSH lb;
+ GpPen *gp_pen;
+
+ gp_pen = GdipAlloc(sizeof(GpPen));
+ if(!pen) return OutOfMemory;
+
+ gp_pen->style = GP_DEFAULT_PENSTYLE;
+ gp_pen->color = ARGB2COLORREF(color);
+ gp_pen->width = width;
+ gp_pen->unit = unit;
+
+ /* FIXME: Currently only solid lines supported. */
+ lb.lbStyle = BS_SOLID;
+ lb.lbColor = gp_pen->color;
+ lb.lbHatch = 0;
+
+ if((gp_pen->unit == UnitWorld) || (gp_pen->unit == UnitPixel)) {
+ gp_pen->gdipen = ExtCreatePen(gp_pen->style, (INT) gp_pen->width, &lb,
+ 0, NULL);
+ } else {
+ FIXME("UnitWorld, UnitPixel only supported units");
+ return NotImplemented;
+ }
+
+ if(!gp_pen)
+ return GenericError;
+
+ *pen = gp_pen;
+
+ return Ok;
+}
+
+GpStatus WINGDIPAPI GdipDeletePen(GpPen *pen)
+{
+ if(!pen) return InvalidParameter;
+ DeleteObject(pen->gdipen);
+ GdipFree(pen);
+
+ return Ok;
+}