2 * Copyright (C) 2007 Google (Evan Stade)
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include "gdiplus_private.h"
28 #include "wine/debug.h"
30 GpStatus WINGDIPAPI GdipCreateFromHDC(HDC hdc, GpGraphics **graphics)
36 return InvalidParameter;
38 *graphics = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
40 (*graphics)->hdc = hdc;
41 (*graphics)->hwnd = NULL;
46 GpStatus WINGDIPAPI GdipCreateFromHWND(HWND hwnd, GpGraphics **graphics)
50 if((ret = GdipCreateFromHDC(GetDC(hwnd), graphics)) != Ok)
53 (*graphics)->hwnd = hwnd;
58 GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics)
60 if(!graphics) return InvalidParameter;
62 ReleaseDC(graphics->hwnd, graphics->hdc);
64 HeapFree(GetProcessHeap(), 0, graphics);
69 GpStatus WINGDIPAPI GdipDrawLineI(GpGraphics *graphics, GpPen *pen, INT x1,
70 INT y1, INT x2, INT y2)
75 return InvalidParameter;
77 old_obj = SelectObject(graphics->hdc, pen->gdipen);
78 MoveToEx(graphics->hdc, x1, y1, NULL);
79 LineTo(graphics->hdc, x2, y2);
80 SelectObject(graphics->hdc, old_obj);
85 GpStatus WINGDIPAPI GdipDrawRectangleI(GpGraphics *graphics, GpPen *pen, INT x,
86 INT y, INT width, INT height)
93 return InvalidParameter;
95 lb.lbStyle = BS_SOLID;
96 lb.lbColor = pen->color;
99 hpen = ExtCreatePen(PS_GEOMETRIC | PS_ENDCAP_SQUARE, (INT) pen->width,
102 old_obj = SelectObject(graphics->hdc, hpen);
104 /* assume pen aligment centered */
105 MoveToEx(graphics->hdc, x, y, NULL);
106 LineTo(graphics->hdc, x+width, y);
107 LineTo(graphics->hdc, x+width, y+height);
108 LineTo(graphics->hdc, x, y+height);
109 LineTo(graphics->hdc, x, y);
111 SelectObject(graphics->hdc, old_obj);