From d50be49775ce850e9f045e9c4272d3e8137e3159 Mon Sep 17 00:00:00 2001 From: Evan Stade Date: Mon, 11 Jun 2007 11:54:03 -0700 Subject: [PATCH] gdiplus: Added first GDI+ graphics implementation. --- dlls/gdiplus/Makefile.in | 3 +- dlls/gdiplus/gdiplus.spec | 6 +-- dlls/gdiplus/gdiplus_private.h | 5 +++ dlls/gdiplus/graphics.c | 67 ++++++++++++++++++++++++++++++++++ 4 files changed, 77 insertions(+), 4 deletions(-) create mode 100644 dlls/gdiplus/graphics.c diff --git a/dlls/gdiplus/Makefile.in b/dlls/gdiplus/Makefile.in index a4edb46f02..d1089af679 100644 --- a/dlls/gdiplus/Makefile.in +++ b/dlls/gdiplus/Makefile.in @@ -4,10 +4,11 @@ SRCDIR = @srcdir@ VPATH = @srcdir@ MODULE = gdiplus.dll IMPORTLIB = libgdiplus.$(IMPLIBEXT) -IMPORTS = gdi32 advapi32 kernel32 ntdll +IMPORTS = user32 gdi32 advapi32 kernel32 ntdll C_SRCS = \ gdiplus.c \ + graphics.c \ pen.c @MAKE_DLL_RULES@ diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec index 2bb3ba9d54..c80fbbb3fa 100644 --- a/dlls/gdiplus/gdiplus.spec +++ b/dlls/gdiplus/gdiplus.spec @@ -81,8 +81,8 @@ @ stub GdipCreateFontFromLogfontA @ stub GdipCreateFontFromLogfontW @ stub GdipCreateFromHDC2 -@ stub GdipCreateFromHDC -@ stub GdipCreateFromHWND +@ stdcall GdipCreateFromHDC(long ptr) +@ stdcall GdipCreateFromHWND(long ptr) @ stub GdipCreateFromHWNDICM @ stub GdipCreateHBITMAPFromBitmap @ stub GdipCreateHICONFromBitmap @@ -132,7 +132,7 @@ @ stub GdipDeleteCustomLineCap @ stub GdipDeleteFont @ stub GdipDeleteFontFamily -@ stub GdipDeleteGraphics +@ stdcall GdipDeleteGraphics(ptr) @ stub GdipDeleteMatrix @ stub GdipDeletePath @ stub GdipDeletePathIter diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index 2d3a17921c..f6e238ae03 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -35,4 +35,9 @@ struct GpPen{ HPEN gdipen; }; +struct GpGraphics{ + HDC hdc; + HWND hwnd; +}; + #endif diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c new file mode 100644 index 0000000000..37af012756 --- /dev/null +++ b/dlls/gdiplus/graphics.c @@ -0,0 +1,67 @@ +/* + * 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 +#include + +#include "windef.h" +#include "winbase.h" +#include "winuser.h" +#include "wingdi.h" +#include "gdiplus.h" +#include "gdiplus_private.h" +#include "wine/debug.h" + +GpStatus WINGDIPAPI GdipCreateFromHDC(HDC hdc, GpGraphics **graphics) +{ + if(hdc == NULL) + return OutOfMemory; + + if(graphics == NULL) + return InvalidParameter; + + *graphics = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, + sizeof(GpGraphics)); + (*graphics)->hdc = hdc; + (*graphics)->hwnd = NULL; + + return Ok; +} + +GpStatus WINGDIPAPI GdipCreateFromHWND(HWND hwnd, GpGraphics **graphics) +{ + GpStatus ret; + + if((ret = GdipCreateFromHDC(GetDC(hwnd), graphics)) != Ok) + return ret; + + (*graphics)->hwnd = hwnd; + + return Ok; +} + +GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics) +{ + if(!graphics) return InvalidParameter; + if(graphics->hwnd) + ReleaseDC(graphics->hwnd, graphics->hdc); + + HeapFree(GetProcessHeap(), 0, graphics); + + return Ok; +} -- 2.32.0.93.g670b81a890