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 "wine/unicode.h"
39 #include "gdiplus_private.h"
40 #include "wine/debug.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
44 /* looks-right constants */
45 #define TENSION_CONST (0.3)
46 #define ANCHOR_WIDTH (2.0)
47 #define MAX_ITERS (50)
49 /* Converts angle (in degrees) to x/y coordinates */
50 static void deg2xy(REAL angle, REAL x_0, REAL y_0, REAL *x, REAL *y)
52 REAL radAngle, hypotenuse;
54 radAngle = deg2rad(angle);
55 hypotenuse = 50.0; /* arbitrary */
57 *x = x_0 + cos(radAngle) * hypotenuse;
58 *y = y_0 + sin(radAngle) * hypotenuse;
61 /* Converts from gdiplus path point type to gdi path point type. */
62 static BYTE convert_path_point_type(BYTE type)
66 switch(type & PathPointTypePathTypeMask){
67 case PathPointTypeBezier:
70 case PathPointTypeLine:
73 case PathPointTypeStart:
77 ERR("Bad point type\n");
81 if(type & PathPointTypeCloseSubpath)
82 ret |= PT_CLOSEFIGURE;
87 static INT prepare_dc(GpGraphics *graphics, GpPen *pen)
91 INT save_state = SaveDC(graphics->hdc), i, numdashes;
93 DWORD dash_array[MAX_DASHLEN];
95 EndPath(graphics->hdc);
97 if(pen->unit == UnitPixel){
101 /* Get an estimate for the amount the pen width is affected by the world
102 * transform. (This is similar to what some of the wine drivers do.) */
107 GdipTransformMatrixPoints(graphics->worldtrans, pt, 2);
108 width = sqrt((pt[1].X - pt[0].X) * (pt[1].X - pt[0].X) +
109 (pt[1].Y - pt[0].Y) * (pt[1].Y - pt[0].Y)) / sqrt(2.0);
111 width *= pen->width * convert_unit(graphics->hdc,
112 pen->unit == UnitWorld ? graphics->unit : pen->unit);
115 if(pen->dash == DashStyleCustom){
116 numdashes = min(pen->numdashes, MAX_DASHLEN);
118 TRACE("dashes are: ");
119 for(i = 0; i < numdashes; i++){
120 dash_array[i] = roundr(width * pen->dashes[i]);
121 TRACE("%d, ", dash_array[i]);
123 TRACE("\n and the pen style is %x\n", pen->style);
125 gdipen = ExtCreatePen(pen->style, roundr(width), &pen->brush->lb,
126 numdashes, dash_array);
129 gdipen = ExtCreatePen(pen->style, roundr(width), &pen->brush->lb, 0, NULL);
131 SelectObject(graphics->hdc, gdipen);
136 static void restore_dc(GpGraphics *graphics, INT state)
138 DeleteObject(SelectObject(graphics->hdc, GetStockObject(NULL_PEN)));
139 RestoreDC(graphics->hdc, state);
142 /* This helper applies all the changes that the points listed in ptf need in
143 * order to be drawn on the device context. In the end, this should include at
145 * -scaling by page unit
146 * -applying world transformation
147 * -converting from float to int
148 * Native gdiplus uses gdi32 to do all this (via SetMapMode, SetViewportExtEx,
149 * SetWindowExtEx, SetWorldTransform, etc.) but we cannot because we are using
150 * gdi to draw, and these functions would irreparably mess with line widths.
152 static void transform_and_round_points(GpGraphics *graphics, POINT *pti,
153 GpPointF *ptf, INT count)
159 unitscale = convert_unit(graphics->hdc, graphics->unit);
161 /* apply page scale */
162 if(graphics->unit != UnitDisplay)
163 unitscale *= graphics->scale;
165 GdipCloneMatrix(graphics->worldtrans, &matrix);
166 GdipScaleMatrix(matrix, unitscale, unitscale, MatrixOrderAppend);
167 GdipTransformMatrixPoints(matrix, ptf, count);
168 GdipDeleteMatrix(matrix);
170 for(i = 0; i < count; i++){
171 pti[i].x = roundr(ptf[i].X);
172 pti[i].y = roundr(ptf[i].Y);
176 /* GdipDrawPie/GdipFillPie helper function */
177 static void draw_pie(GpGraphics *graphics, REAL x, REAL y, REAL width,
178 REAL height, REAL startAngle, REAL sweepAngle)
185 ptf[1].X = x + width;
186 ptf[1].Y = y + height;
188 deg2xy(startAngle+sweepAngle, x + width / 2.0, y + width / 2.0, &ptf[2].X, &ptf[2].Y);
189 deg2xy(startAngle, x + width / 2.0, y + width / 2.0, &ptf[3].X, &ptf[3].Y);
191 transform_and_round_points(graphics, pti, ptf, 4);
193 Pie(graphics->hdc, pti[0].x, pti[0].y, pti[1].x, pti[1].y, pti[2].x,
194 pti[2].y, pti[3].x, pti[3].y);
197 /* GdipDrawCurve helper function.
198 * Calculates Bezier points from cardinal spline points. */
199 static void calc_curve_bezier(CONST GpPointF *pts, REAL tension, REAL *x1,
200 REAL *y1, REAL *x2, REAL *y2)
204 /* calculate tangent */
205 xdiff = pts[2].X - pts[0].X;
206 ydiff = pts[2].Y - pts[0].Y;
208 /* apply tangent to get control points */
209 *x1 = pts[1].X - tension * xdiff;
210 *y1 = pts[1].Y - tension * ydiff;
211 *x2 = pts[1].X + tension * xdiff;
212 *y2 = pts[1].Y + tension * ydiff;
215 /* GdipDrawCurve helper function.
216 * Calculates Bezier points from cardinal spline endpoints. */
217 static void calc_curve_bezier_endp(REAL xend, REAL yend, REAL xadj, REAL yadj,
218 REAL tension, REAL *x, REAL *y)
220 /* tangent at endpoints is the line from the endpoint to the adjacent point */
221 *x = roundr(tension * (xadj - xend) + xend);
222 *y = roundr(tension * (yadj - yend) + yend);
225 /* Draws the linecap the specified color and size on the hdc. The linecap is in
226 * direction of the line from x1, y1 to x2, y2 and is anchored on x2, y2. Probably
227 * should not be called on an hdc that has a path you care about. */
228 static void draw_cap(GpGraphics *graphics, COLORREF color, GpLineCap cap, REAL size,
229 const GpCustomLineCap *custom, REAL x1, REAL y1, REAL x2, REAL y2)
231 HGDIOBJ oldbrush = NULL, oldpen = NULL;
232 GpMatrix *matrix = NULL;
235 PointF ptf[4], *custptf = NULL;
236 POINT pt[4], *custpt = NULL;
238 REAL theta, dsmall, dbig, dx, dy = 0.0;
243 if((x1 == x2) && (y1 == y2))
246 theta = gdiplus_atan2(y2 - y1, x2 - x1);
248 customstroke = (cap == LineCapCustom) && custom && (!custom->fill);
250 brush = CreateSolidBrush(color);
251 lb.lbStyle = BS_SOLID;
254 pen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_FLAT |
255 PS_JOIN_MITER, 1, &lb, 0,
257 oldbrush = SelectObject(graphics->hdc, brush);
258 oldpen = SelectObject(graphics->hdc, pen);
265 case LineCapSquareAnchor:
266 case LineCapDiamondAnchor:
267 size = size * (cap & LineCapNoAnchor ? ANCHOR_WIDTH : 1.0) / 2.0;
268 if(cap == LineCapDiamondAnchor){
269 dsmall = cos(theta + M_PI_2) * size;
270 dbig = sin(theta + M_PI_2) * size;
273 dsmall = cos(theta + M_PI_4) * size;
274 dbig = sin(theta + M_PI_4) * size;
277 ptf[0].X = x2 - dsmall;
278 ptf[1].X = x2 + dbig;
280 ptf[0].Y = y2 - dbig;
281 ptf[3].Y = y2 + dsmall;
283 ptf[1].Y = y2 - dsmall;
284 ptf[2].Y = y2 + dbig;
286 ptf[3].X = x2 - dbig;
287 ptf[2].X = x2 + dsmall;
289 transform_and_round_points(graphics, pt, ptf, 4);
290 Polygon(graphics->hdc, pt, 4);
293 case LineCapArrowAnchor:
294 size = size * 4.0 / sqrt(3.0);
296 dx = cos(M_PI / 6.0 + theta) * size;
297 dy = sin(M_PI / 6.0 + theta) * size;
302 dx = cos(- M_PI / 6.0 + theta) * size;
303 dy = sin(- M_PI / 6.0 + theta) * size;
311 transform_and_round_points(graphics, pt, ptf, 3);
312 Polygon(graphics->hdc, pt, 3);
315 case LineCapRoundAnchor:
316 dx = dy = ANCHOR_WIDTH * size / 2.0;
323 transform_and_round_points(graphics, pt, ptf, 2);
324 Ellipse(graphics->hdc, pt[0].x, pt[0].y, pt[1].x, pt[1].y);
327 case LineCapTriangle:
329 dx = cos(M_PI_2 + theta) * size;
330 dy = sin(M_PI_2 + theta) * size;
337 dx = cos(theta) * size;
338 dy = sin(theta) * size;
343 transform_and_round_points(graphics, pt, ptf, 3);
344 Polygon(graphics->hdc, pt, 3);
348 dx = dy = size / 2.0;
355 dx = -cos(M_PI_2 + theta) * size;
356 dy = -sin(M_PI_2 + theta) * size;
363 transform_and_round_points(graphics, pt, ptf, 4);
364 Pie(graphics->hdc, pt[0].x, pt[0].y, pt[1].x, pt[1].y, pt[2].x,
365 pt[2].y, pt[3].x, pt[3].y);
372 count = custom->pathdata.Count;
373 custptf = GdipAlloc(count * sizeof(PointF));
374 custpt = GdipAlloc(count * sizeof(POINT));
375 tp = GdipAlloc(count);
377 if(!custptf || !custpt || !tp || (GdipCreateMatrix(&matrix) != Ok))
380 memcpy(custptf, custom->pathdata.Points, count * sizeof(PointF));
382 GdipScaleMatrix(matrix, size, size, MatrixOrderAppend);
383 GdipRotateMatrix(matrix, (180.0 / M_PI) * (theta - M_PI_2),
385 GdipTranslateMatrix(matrix, x2, y2, MatrixOrderAppend);
386 GdipTransformMatrixPoints(matrix, custptf, count);
388 transform_and_round_points(graphics, custpt, custptf, count);
390 for(i = 0; i < count; i++)
391 tp[i] = convert_path_point_type(custom->pathdata.Types[i]);
394 BeginPath(graphics->hdc);
395 PolyDraw(graphics->hdc, custpt, tp, count);
396 EndPath(graphics->hdc);
397 StrokeAndFillPath(graphics->hdc);
400 PolyDraw(graphics->hdc, custpt, tp, count);
406 GdipDeleteMatrix(matrix);
413 SelectObject(graphics->hdc, oldbrush);
414 SelectObject(graphics->hdc, oldpen);
420 /* Shortens the line by the given percent by changing x2, y2.
421 * If percent is > 1.0 then the line will change direction.
422 * If percent is negative it can lengthen the line. */
423 static void shorten_line_percent(REAL x1, REAL y1, REAL *x2, REAL *y2, REAL percent)
425 REAL dist, theta, dx, dy;
427 if((y1 == *y2) && (x1 == *x2))
430 dist = sqrt((*x2 - x1) * (*x2 - x1) + (*y2 - y1) * (*y2 - y1)) * -percent;
431 theta = gdiplus_atan2((*y2 - y1), (*x2 - x1));
432 dx = cos(theta) * dist;
433 dy = sin(theta) * dist;
439 /* Shortens the line by the given amount by changing x2, y2.
440 * If the amount is greater than the distance, the line will become length 0.
441 * If the amount is negative, it can lengthen the line. */
442 static void shorten_line_amt(REAL x1, REAL y1, REAL *x2, REAL *y2, REAL amt)
444 REAL dx, dy, percent;
448 if(dx == 0 && dy == 0)
451 percent = amt / sqrt(dx * dx + dy * dy);
458 shorten_line_percent(x1, y1, x2, y2, percent);
461 /* Draws lines between the given points, and if caps is true then draws an endcap
462 * at the end of the last line. */
463 static GpStatus draw_polyline(GpGraphics *graphics, GpPen *pen,
464 GDIPCONST GpPointF * pt, INT count, BOOL caps)
467 GpPointF *ptcopy = NULL;
468 GpStatus status = GenericError;
473 pti = GdipAlloc(count * sizeof(POINT));
474 ptcopy = GdipAlloc(count * sizeof(GpPointF));
477 status = OutOfMemory;
481 memcpy(ptcopy, pt, count * sizeof(GpPointF));
484 if(pen->endcap == LineCapArrowAnchor)
485 shorten_line_amt(ptcopy[count-2].X, ptcopy[count-2].Y,
486 &ptcopy[count-1].X, &ptcopy[count-1].Y, pen->width);
487 else if((pen->endcap == LineCapCustom) && pen->customend)
488 shorten_line_amt(ptcopy[count-2].X, ptcopy[count-2].Y,
489 &ptcopy[count-1].X, &ptcopy[count-1].Y,
490 pen->customend->inset * pen->width);
492 if(pen->startcap == LineCapArrowAnchor)
493 shorten_line_amt(ptcopy[1].X, ptcopy[1].Y,
494 &ptcopy[0].X, &ptcopy[0].Y, pen->width);
495 else if((pen->startcap == LineCapCustom) && pen->customstart)
496 shorten_line_amt(ptcopy[1].X, ptcopy[1].Y,
497 &ptcopy[0].X, &ptcopy[0].Y,
498 pen->customstart->inset * pen->width);
500 draw_cap(graphics, pen->brush->lb.lbColor, pen->endcap, pen->width, pen->customend,
501 pt[count - 2].X, pt[count - 2].Y, pt[count - 1].X, pt[count - 1].Y);
502 draw_cap(graphics, pen->brush->lb.lbColor, pen->startcap, pen->width, pen->customstart,
503 pt[1].X, pt[1].Y, pt[0].X, pt[0].Y);
506 transform_and_round_points(graphics, pti, ptcopy, count);
508 if(Polyline(graphics->hdc, pti, count))
518 /* Conducts a linear search to find the bezier points that will back off
519 * the endpoint of the curve by a distance of amt. Linear search works
520 * better than binary in this case because there are multiple solutions,
521 * and binary searches often find a bad one. I don't think this is what
522 * Windows does but short of rendering the bezier without GDI's help it's
523 * the best we can do. If rev then work from the start of the passed points
524 * instead of the end. */
525 static void shorten_bezier_amt(GpPointF * pt, REAL amt, BOOL rev)
528 REAL percent = 0.00, dx, dy, origx, origy, diff = -1.0;
529 INT i, first = 0, second = 1, third = 2, fourth = 3;
538 origx = pt[fourth].X;
539 origy = pt[fourth].Y;
540 memcpy(origpt, pt, sizeof(GpPointF) * 4);
542 for(i = 0; (i < MAX_ITERS) && (diff < amt); i++){
543 /* reset bezier points to original values */
544 memcpy(pt, origpt, sizeof(GpPointF) * 4);
545 /* Perform magic on bezier points. Order is important here.*/
546 shorten_line_percent(pt[third].X, pt[third].Y, &pt[fourth].X, &pt[fourth].Y, percent);
547 shorten_line_percent(pt[second].X, pt[second].Y, &pt[third].X, &pt[third].Y, percent);
548 shorten_line_percent(pt[third].X, pt[third].Y, &pt[fourth].X, &pt[fourth].Y, percent);
549 shorten_line_percent(pt[first].X, pt[first].Y, &pt[second].X, &pt[second].Y, percent);
550 shorten_line_percent(pt[second].X, pt[second].Y, &pt[third].X, &pt[third].Y, percent);
551 shorten_line_percent(pt[third].X, pt[third].Y, &pt[fourth].X, &pt[fourth].Y, percent);
553 dx = pt[fourth].X - origx;
554 dy = pt[fourth].Y - origy;
556 diff = sqrt(dx * dx + dy * dy);
557 percent += 0.0005 * amt;
561 /* Draws bezier curves between given points, and if caps is true then draws an
562 * endcap at the end of the last line. */
563 static GpStatus draw_polybezier(GpGraphics *graphics, GpPen *pen,
564 GDIPCONST GpPointF * pt, INT count, BOOL caps)
568 GpStatus status = GenericError;
573 pti = GdipAlloc(count * sizeof(POINT));
574 ptcopy = GdipAlloc(count * sizeof(GpPointF));
577 status = OutOfMemory;
581 memcpy(ptcopy, pt, count * sizeof(GpPointF));
584 if(pen->endcap == LineCapArrowAnchor)
585 shorten_bezier_amt(&ptcopy[count-4], pen->width, FALSE);
586 else if((pen->endcap == LineCapCustom) && pen->customend)
587 shorten_bezier_amt(&ptcopy[count-4], pen->width * pen->customend->inset,
590 if(pen->startcap == LineCapArrowAnchor)
591 shorten_bezier_amt(ptcopy, pen->width, TRUE);
592 else if((pen->startcap == LineCapCustom) && pen->customstart)
593 shorten_bezier_amt(ptcopy, pen->width * pen->customstart->inset, TRUE);
595 /* the direction of the line cap is parallel to the direction at the
596 * end of the bezier (which, if it has been shortened, is not the same
597 * as the direction from pt[count-2] to pt[count-1]) */
598 draw_cap(graphics, pen->brush->lb.lbColor, pen->endcap, pen->width, pen->customend,
599 pt[count - 1].X - (ptcopy[count - 1].X - ptcopy[count - 2].X),
600 pt[count - 1].Y - (ptcopy[count - 1].Y - ptcopy[count - 2].Y),
601 pt[count - 1].X, pt[count - 1].Y);
603 draw_cap(graphics, pen->brush->lb.lbColor, pen->startcap, pen->width, pen->customstart,
604 pt[0].X - (ptcopy[0].X - ptcopy[1].X),
605 pt[0].Y - (ptcopy[0].Y - ptcopy[1].Y), pt[0].X, pt[0].Y);
608 transform_and_round_points(graphics, pti, ptcopy, count);
610 PolyBezier(graphics->hdc, pti, count);
621 /* Draws a combination of bezier curves and lines between points. */
622 static GpStatus draw_poly(GpGraphics *graphics, GpPen *pen, GDIPCONST GpPointF * pt,
623 GDIPCONST BYTE * types, INT count, BOOL caps)
625 POINT *pti = GdipAlloc(count * sizeof(POINT));
626 BYTE *tp = GdipAlloc(count);
627 GpPointF *ptcopy = GdipAlloc(count * sizeof(GpPointF));
629 GpStatus status = GenericError;
635 if(!pti || !tp || !ptcopy){
636 status = OutOfMemory;
640 for(i = 1; i < count; i++){
641 if((types[i] & PathPointTypePathTypeMask) == PathPointTypeBezier){
642 if((i + 2 >= count) || !(types[i + 1] & PathPointTypeBezier)
643 || !(types[i + 1] & PathPointTypeBezier)){
644 ERR("Bad bezier points\n");
651 memcpy(ptcopy, pt, count * sizeof(GpPointF));
653 /* If we are drawing caps, go through the points and adjust them accordingly,
654 * and draw the caps. */
656 switch(types[count - 1] & PathPointTypePathTypeMask){
657 case PathPointTypeBezier:
658 if(pen->endcap == LineCapArrowAnchor)
659 shorten_bezier_amt(&ptcopy[count - 4], pen->width, FALSE);
660 else if((pen->endcap == LineCapCustom) && pen->customend)
661 shorten_bezier_amt(&ptcopy[count - 4],
662 pen->width * pen->customend->inset, FALSE);
664 draw_cap(graphics, pen->brush->lb.lbColor, pen->endcap, pen->width, pen->customend,
665 pt[count - 1].X - (ptcopy[count - 1].X - ptcopy[count - 2].X),
666 pt[count - 1].Y - (ptcopy[count - 1].Y - ptcopy[count - 2].Y),
667 pt[count - 1].X, pt[count - 1].Y);
670 case PathPointTypeLine:
671 if(pen->endcap == LineCapArrowAnchor)
672 shorten_line_amt(ptcopy[count - 2].X, ptcopy[count - 2].Y,
673 &ptcopy[count - 1].X, &ptcopy[count - 1].Y,
675 else if((pen->endcap == LineCapCustom) && pen->customend)
676 shorten_line_amt(ptcopy[count - 2].X, ptcopy[count - 2].Y,
677 &ptcopy[count - 1].X, &ptcopy[count - 1].Y,
678 pen->customend->inset * pen->width);
680 draw_cap(graphics, pen->brush->lb.lbColor, pen->endcap, pen->width, pen->customend,
681 pt[count - 2].X, pt[count - 2].Y, pt[count - 1].X,
686 ERR("Bad path last point\n");
690 /* Find start of points */
691 for(j = 1; j < count && ((types[j] & PathPointTypePathTypeMask)
692 == PathPointTypeStart); j++);
694 switch(types[j] & PathPointTypePathTypeMask){
695 case PathPointTypeBezier:
696 if(pen->startcap == LineCapArrowAnchor)
697 shorten_bezier_amt(&ptcopy[j - 1], pen->width, TRUE);
698 else if((pen->startcap == LineCapCustom) && pen->customstart)
699 shorten_bezier_amt(&ptcopy[j - 1],
700 pen->width * pen->customstart->inset, TRUE);
702 draw_cap(graphics, pen->brush->lb.lbColor, pen->startcap, pen->width, pen->customstart,
703 pt[j - 1].X - (ptcopy[j - 1].X - ptcopy[j].X),
704 pt[j - 1].Y - (ptcopy[j - 1].Y - ptcopy[j].Y),
705 pt[j - 1].X, pt[j - 1].Y);
708 case PathPointTypeLine:
709 if(pen->startcap == LineCapArrowAnchor)
710 shorten_line_amt(ptcopy[j].X, ptcopy[j].Y,
711 &ptcopy[j - 1].X, &ptcopy[j - 1].Y,
713 else if((pen->startcap == LineCapCustom) && pen->customstart)
714 shorten_line_amt(ptcopy[j].X, ptcopy[j].Y,
715 &ptcopy[j - 1].X, &ptcopy[j - 1].Y,
716 pen->customstart->inset * pen->width);
718 draw_cap(graphics, pen->brush->lb.lbColor, pen->startcap, pen->width, pen->customstart,
719 pt[j].X, pt[j].Y, pt[j - 1].X,
724 ERR("Bad path points\n");
729 transform_and_round_points(graphics, pti, ptcopy, count);
731 for(i = 0; i < count; i++){
732 tp[i] = convert_path_point_type(types[i]);
735 PolyDraw(graphics->hdc, pti, tp, count);
747 GpStatus WINGDIPAPI GdipCreateFromHDC(HDC hdc, GpGraphics **graphics)
749 return GdipCreateFromHDC2(hdc, NULL, graphics);
752 GpStatus WINGDIPAPI GdipCreateFromHDC2(HDC hdc, HANDLE hDevice, GpGraphics **graphics)
756 if(hDevice != NULL) {
757 FIXME("Don't know how to hadle parameter hDevice\n");
758 return NotImplemented;
765 return InvalidParameter;
767 *graphics = GdipAlloc(sizeof(GpGraphics));
768 if(!*graphics) return OutOfMemory;
770 if((retval = GdipCreateMatrix(&(*graphics)->worldtrans)) != Ok){
775 (*graphics)->hdc = hdc;
776 (*graphics)->hwnd = NULL;
777 (*graphics)->smoothing = SmoothingModeDefault;
778 (*graphics)->compqual = CompositingQualityDefault;
779 (*graphics)->interpolation = InterpolationModeDefault;
780 (*graphics)->pixeloffset = PixelOffsetModeDefault;
781 (*graphics)->compmode = CompositingModeSourceOver;
782 (*graphics)->unit = UnitDisplay;
783 (*graphics)->scale = 1.0;
788 GpStatus WINGDIPAPI GdipCreateFromHWND(HWND hwnd, GpGraphics **graphics)
792 if((ret = GdipCreateFromHDC(GetDC(hwnd), graphics)) != Ok)
795 (*graphics)->hwnd = hwnd;
800 /* FIXME: no icm handling */
801 GpStatus WINGDIPAPI GdipCreateFromHWNDICM(HWND hwnd, GpGraphics **graphics)
803 return GdipCreateFromHWND(hwnd, graphics);
806 GpStatus WINGDIPAPI GdipCreateMetafileFromEmf(HENHMETAFILE hemf, BOOL delete,
807 GpMetafile **metafile)
811 if(!hemf || !metafile)
812 return InvalidParameter;
815 FIXME("not implemented\n");
817 return NotImplemented;
820 GpStatus WINGDIPAPI GdipCreateMetafileFromWmf(HMETAFILE hwmf, BOOL delete,
821 GDIPCONST WmfPlaceableFileHeader * placeable, GpMetafile **metafile)
823 IStream *stream = NULL;
827 GpStatus retval = GenericError;
829 if(!hwmf || !metafile || !placeable)
830 return InvalidParameter;
833 read = GetMetaFileBitsEx(hwmf, 0, NULL);
836 copy = GdipAlloc(read);
837 GetMetaFileBitsEx(hwmf, read, copy);
839 hemf = SetWinMetaFileBits(read, copy, NULL, NULL);
842 read = GetEnhMetaFileBits(hemf, 0, NULL);
843 copy = GdipAlloc(read);
844 GetEnhMetaFileBits(hemf, read, copy);
845 DeleteEnhMetaFile(hemf);
847 if(CreateStreamOnHGlobal(copy, TRUE, &stream) != S_OK){
848 ERR("could not make stream\n");
853 *metafile = GdipAlloc(sizeof(GpMetafile));
855 retval = OutOfMemory;
859 if(OleLoadPicture(stream, 0, FALSE, &IID_IPicture,
860 (LPVOID*) &((*metafile)->image.picture)) != S_OK)
864 (*metafile)->image.type = ImageTypeMetafile;
865 (*metafile)->bounds.X = ((REAL) placeable->BoundingBox.Left) / ((REAL) placeable->Inch);
866 (*metafile)->bounds.Y = ((REAL) placeable->BoundingBox.Right) / ((REAL) placeable->Inch);
867 (*metafile)->bounds.Width = ((REAL) (placeable->BoundingBox.Right
868 - placeable->BoundingBox.Left)) / ((REAL) placeable->Inch);
869 (*metafile)->bounds.Height = ((REAL) (placeable->BoundingBox.Bottom
870 - placeable->BoundingBox.Top)) / ((REAL) placeable->Inch);
871 (*metafile)->unit = UnitInch;
874 DeleteMetaFile(hwmf);
880 IStream_Release(stream);
884 GpStatus WINGDIPAPI GdipCreateStreamOnFile(GDIPCONST WCHAR * filename,
885 UINT access, IStream **stream)
890 if(!stream || !filename)
891 return InvalidParameter;
893 if(access & GENERIC_WRITE)
894 dwMode = STGM_SHARE_DENY_WRITE | STGM_WRITE | STGM_CREATE;
895 else if(access & GENERIC_READ)
896 dwMode = STGM_SHARE_DENY_WRITE | STGM_READ | STGM_FAILIFTHERE;
898 return InvalidParameter;
900 ret = SHCreateStreamOnFileW(filename, dwMode, stream);
902 return hresult_to_status(ret);
905 GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics)
907 if(!graphics) return InvalidParameter;
909 ReleaseDC(graphics->hwnd, graphics->hdc);
911 GdipDeleteMatrix(graphics->worldtrans);
912 HeapFree(GetProcessHeap(), 0, graphics);
917 GpStatus WINGDIPAPI GdipDrawArc(GpGraphics *graphics, GpPen *pen, REAL x,
918 REAL y, REAL width, REAL height, REAL startAngle, REAL sweepAngle)
920 INT save_state, num_pts;
921 GpPointF points[MAX_ARC_PTS];
924 if(!graphics || !pen || width <= 0 || height <= 0)
925 return InvalidParameter;
927 num_pts = arc2polybezier(points, x, y, width, height, startAngle, sweepAngle);
929 save_state = prepare_dc(graphics, pen);
931 retval = draw_polybezier(graphics, pen, points, num_pts, TRUE);
933 restore_dc(graphics, save_state);
938 GpStatus WINGDIPAPI GdipDrawArcI(GpGraphics *graphics, GpPen *pen, INT x,
939 INT y, INT width, INT height, REAL startAngle, REAL sweepAngle)
941 return GdipDrawArc(graphics,pen,(REAL)x,(REAL)y,(REAL)width,(REAL)height,startAngle,sweepAngle);
944 GpStatus WINGDIPAPI GdipDrawBezier(GpGraphics *graphics, GpPen *pen, REAL x1,
945 REAL y1, REAL x2, REAL y2, REAL x3, REAL y3, REAL x4, REAL y4)
951 if(!graphics || !pen)
952 return InvalidParameter;
963 save_state = prepare_dc(graphics, pen);
965 retval = draw_polybezier(graphics, pen, pt, 4, TRUE);
967 restore_dc(graphics, save_state);
972 GpStatus WINGDIPAPI GdipDrawBezierI(GpGraphics *graphics, GpPen *pen, INT x1,
973 INT y1, INT x2, INT y2, INT x3, INT y3, INT x4, INT y4)
979 if(!graphics || !pen)
980 return InvalidParameter;
991 save_state = prepare_dc(graphics, pen);
993 retval = draw_polybezier(graphics, pen, pt, 4, TRUE);
995 restore_dc(graphics, save_state);
1000 GpStatus WINGDIPAPI GdipDrawBeziers(GpGraphics *graphics, GpPen *pen,
1001 GDIPCONST GpPointF *points, INT count)
1006 if(!graphics || !pen || !points || (count <= 0))
1007 return InvalidParameter;
1009 for(i = 0; i < floor(count / 4); i++){
1010 ret = GdipDrawBezier(graphics, pen,
1011 points[4*i].X, points[4*i].Y,
1012 points[4*i + 1].X, points[4*i + 1].Y,
1013 points[4*i + 2].X, points[4*i + 2].Y,
1014 points[4*i + 3].X, points[4*i + 3].Y);
1022 GpStatus WINGDIPAPI GdipDrawBeziersI(GpGraphics *graphics, GpPen *pen,
1023 GDIPCONST GpPoint *points, INT count)
1029 if(!graphics || !pen || !points || (count <= 0))
1030 return InvalidParameter;
1032 pts = GdipAlloc(sizeof(GpPointF) * count);
1036 for(i = 0; i < count; i++){
1037 pts[i].X = (REAL)points[i].X;
1038 pts[i].Y = (REAL)points[i].Y;
1041 ret = GdipDrawBeziers(graphics,pen,pts,count);
1048 GpStatus WINGDIPAPI GdipDrawClosedCurve(GpGraphics *graphics, GpPen *pen,
1049 GDIPCONST GpPointF *points, INT count)
1051 return GdipDrawClosedCurve2(graphics, pen, points, count, 1.0);
1054 GpStatus WINGDIPAPI GdipDrawClosedCurveI(GpGraphics *graphics, GpPen *pen,
1055 GDIPCONST GpPoint *points, INT count)
1057 return GdipDrawClosedCurve2I(graphics, pen, points, count, 1.0);
1060 GpStatus WINGDIPAPI GdipDrawClosedCurve2(GpGraphics *graphics, GpPen *pen,
1061 GDIPCONST GpPointF *points, INT count, REAL tension)
1066 if(!graphics || !pen || !points || count <= 0)
1067 return InvalidParameter;
1069 /* make a full points copy.. */
1070 ptf = GdipAlloc(sizeof(GpPointF)*(count+1));
1073 memcpy(ptf, points, sizeof(GpPointF)*count);
1075 /* ..and add a first point as a last one */
1076 ptf[count] = ptf[0];
1078 stat = GdipDrawCurve2(graphics, pen, ptf, count + 1, tension);
1085 GpStatus WINGDIPAPI GdipDrawClosedCurve2I(GpGraphics *graphics, GpPen *pen,
1086 GDIPCONST GpPoint *points, INT count, REAL tension)
1092 if(!points || count <= 0)
1093 return InvalidParameter;
1095 ptf = GdipAlloc(sizeof(GpPointF)*count);
1099 for(i = 0; i < count; i++){
1100 ptf[i].X = (REAL)points[i].X;
1101 ptf[i].Y = (REAL)points[i].Y;
1104 stat = GdipDrawClosedCurve2(graphics, pen, ptf, count, tension);
1111 GpStatus WINGDIPAPI GdipDrawCurve(GpGraphics *graphics, GpPen *pen,
1112 GDIPCONST GpPointF *points, INT count)
1114 return GdipDrawCurve2(graphics,pen,points,count,1.0);
1117 GpStatus WINGDIPAPI GdipDrawCurveI(GpGraphics *graphics, GpPen *pen,
1118 GDIPCONST GpPoint *points, INT count)
1124 if(!points || count <= 0)
1125 return InvalidParameter;
1127 pointsF = GdipAlloc(sizeof(GpPointF)*count);
1131 for(i = 0; i < count; i++){
1132 pointsF[i].X = (REAL)points[i].X;
1133 pointsF[i].Y = (REAL)points[i].Y;
1136 ret = GdipDrawCurve(graphics,pen,pointsF,count);
1142 /* Approximates cardinal spline with Bezier curves. */
1143 GpStatus WINGDIPAPI GdipDrawCurve2(GpGraphics *graphics, GpPen *pen,
1144 GDIPCONST GpPointF *points, INT count, REAL tension)
1146 /* PolyBezier expects count*3-2 points. */
1147 INT i, len_pt = count*3-2, save_state;
1149 REAL x1, x2, y1, y2;
1152 if(!graphics || !pen)
1153 return InvalidParameter;
1155 pt = GdipAlloc(len_pt * sizeof(GpPointF));
1156 tension = tension * TENSION_CONST;
1158 calc_curve_bezier_endp(points[0].X, points[0].Y, points[1].X, points[1].Y,
1161 pt[0].X = points[0].X;
1162 pt[0].Y = points[0].Y;
1166 for(i = 0; i < count-2; i++){
1167 calc_curve_bezier(&(points[i]), tension, &x1, &y1, &x2, &y2);
1171 pt[3*i+3].X = points[i+1].X;
1172 pt[3*i+3].Y = points[i+1].Y;
1177 calc_curve_bezier_endp(points[count-1].X, points[count-1].Y,
1178 points[count-2].X, points[count-2].Y, tension, &x1, &y1);
1180 pt[len_pt-2].X = x1;
1181 pt[len_pt-2].Y = y1;
1182 pt[len_pt-1].X = points[count-1].X;
1183 pt[len_pt-1].Y = points[count-1].Y;
1185 save_state = prepare_dc(graphics, pen);
1187 retval = draw_polybezier(graphics, pen, pt, len_pt, TRUE);
1190 restore_dc(graphics, save_state);
1195 GpStatus WINGDIPAPI GdipDrawCurve2I(GpGraphics *graphics, GpPen *pen,
1196 GDIPCONST GpPoint *points, INT count, REAL tension)
1202 if(!points || count <= 0)
1203 return InvalidParameter;
1205 pointsF = GdipAlloc(sizeof(GpPointF)*count);
1209 for(i = 0; i < count; i++){
1210 pointsF[i].X = (REAL)points[i].X;
1211 pointsF[i].Y = (REAL)points[i].Y;
1214 ret = GdipDrawCurve2(graphics,pen,pointsF,count,tension);
1220 GpStatus WINGDIPAPI GdipDrawEllipse(GpGraphics *graphics, GpPen *pen, REAL x,
1221 REAL y, REAL width, REAL height)
1227 if(!graphics || !pen)
1228 return InvalidParameter;
1232 ptf[1].X = x + width;
1233 ptf[1].Y = y + height;
1235 save_state = prepare_dc(graphics, pen);
1236 SelectObject(graphics->hdc, GetStockObject(NULL_BRUSH));
1238 transform_and_round_points(graphics, pti, ptf, 2);
1240 Ellipse(graphics->hdc, pti[0].x, pti[0].y, pti[1].x, pti[1].y);
1242 restore_dc(graphics, save_state);
1247 GpStatus WINGDIPAPI GdipDrawEllipseI(GpGraphics *graphics, GpPen *pen, INT x,
1248 INT y, INT width, INT height)
1250 return GdipDrawEllipse(graphics,pen,(REAL)x,(REAL)y,(REAL)width,(REAL)height);
1254 GpStatus WINGDIPAPI GdipDrawImage(GpGraphics *graphics, GpImage *image, REAL x, REAL y)
1256 /* IPicture::Render uses LONG coords */
1257 return GdipDrawImageI(graphics,image,roundr(x),roundr(y));
1260 GpStatus WINGDIPAPI GdipDrawImageI(GpGraphics *graphics, GpImage *image, INT x,
1263 UINT width, height, srcw, srch;
1265 if(!graphics || !image)
1266 return InvalidParameter;
1268 GdipGetImageWidth(image, &width);
1269 GdipGetImageHeight(image, &height);
1271 srcw = width * (((REAL) INCH_HIMETRIC) /
1272 ((REAL) GetDeviceCaps(graphics->hdc, LOGPIXELSX)));
1273 srch = height * (((REAL) INCH_HIMETRIC) /
1274 ((REAL) GetDeviceCaps(graphics->hdc, LOGPIXELSY)));
1276 if(image->type != ImageTypeMetafile){
1281 IPicture_Render(image->picture, graphics->hdc, x, y, width, height,
1282 0, 0, srcw, srch, NULL);
1287 /* FIXME: partially implemented (only works for rectangular parallelograms) */
1288 GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image,
1289 GDIPCONST GpPointF *points, INT count, REAL srcx, REAL srcy, REAL srcwidth,
1290 REAL srcheight, GpUnit srcUnit, GDIPCONST GpImageAttributes* imageAttributes,
1291 DrawImageAbort callback, VOID * callbackData)
1297 TRACE("%p %p %p %d %f %f %f %f %d %p %p %p\n", graphics, image, points, count,
1298 srcx, srcy, srcwidth, srcheight, srcUnit, imageAttributes, callback,
1301 if(!graphics || !image || !points || count != 3)
1302 return InvalidParameter;
1304 if(srcUnit == UnitInch)
1305 dx = dy = (REAL) INCH_HIMETRIC;
1306 else if(srcUnit == UnitPixel){
1307 dx = ((REAL) INCH_HIMETRIC) /
1308 ((REAL) GetDeviceCaps(graphics->hdc, LOGPIXELSX));
1309 dy = ((REAL) INCH_HIMETRIC) /
1310 ((REAL) GetDeviceCaps(graphics->hdc, LOGPIXELSY));
1313 return NotImplemented;
1315 memcpy(ptf, points, 3 * sizeof(GpPointF));
1316 transform_and_round_points(graphics, pti, ptf, 3);
1318 /* IPicture renders bitmaps with the y-axis reversed
1319 * FIXME: flipping for unknown image type might not be correct. */
1320 if(image->type != ImageTypeMetafile){
1323 pti[0].y = pti[2].y;
1327 if(IPicture_Render(image->picture, graphics->hdc,
1328 pti[0].x, pti[0].y, pti[1].x - pti[0].x, pti[2].y - pti[0].y,
1329 srcx * dx, srcy * dy,
1330 srcwidth * dx, srcheight * dy,
1333 callback(callbackData);
1334 return GenericError;
1340 GpStatus WINGDIPAPI GdipDrawImagePointsRectI(GpGraphics *graphics, GpImage *image,
1341 GDIPCONST GpPoint *points, INT count, INT srcx, INT srcy, INT srcwidth,
1342 INT srcheight, GpUnit srcUnit, GDIPCONST GpImageAttributes* imageAttributes,
1343 DrawImageAbort callback, VOID * callbackData)
1345 GpPointF pointsF[3];
1348 if(!points || count!=3)
1349 return InvalidParameter;
1351 for(i = 0; i < count; i++){
1352 pointsF[i].X = (REAL)points[i].X;
1353 pointsF[i].Y = (REAL)points[i].Y;
1356 return GdipDrawImagePointsRect(graphics, image, pointsF, count, (REAL)srcx, (REAL)srcy,
1357 (REAL)srcwidth, (REAL)srcheight, srcUnit, imageAttributes,
1358 callback, callbackData);
1361 GpStatus WINGDIPAPI GdipDrawImageRectRect(GpGraphics *graphics, GpImage *image,
1362 REAL dstx, REAL dsty, REAL dstwidth, REAL dstheight, REAL srcx, REAL srcy,
1363 REAL srcwidth, REAL srcheight, GpUnit srcUnit,
1364 GDIPCONST GpImageAttributes* imageattr, DrawImageAbort callback,
1365 VOID * callbackData)
1371 points[1].X = dstx + dstwidth;
1374 points[2].Y = dsty + dstheight;
1376 return GdipDrawImagePointsRect(graphics, image, points, 3, srcx, srcy,
1377 srcwidth, srcheight, srcUnit, imageattr, callback, callbackData);
1380 GpStatus WINGDIPAPI GdipDrawImageRectRectI(GpGraphics *graphics, GpImage *image,
1381 INT dstx, INT dsty, INT dstwidth, INT dstheight, INT srcx, INT srcy,
1382 INT srcwidth, INT srcheight, GpUnit srcUnit,
1383 GDIPCONST GpImageAttributes* imageAttributes, DrawImageAbort callback,
1384 VOID * callbackData)
1390 points[1].X = dstx + dstwidth;
1393 points[2].Y = dsty + dstheight;
1395 return GdipDrawImagePointsRect(graphics, image, points, 3, srcx, srcy,
1396 srcwidth, srcheight, srcUnit, imageAttributes, callback, callbackData);
1399 GpStatus WINGDIPAPI GdipDrawImageRect(GpGraphics *graphics, GpImage *image,
1400 REAL x, REAL y, REAL width, REAL height)
1406 if(!graphics || !image)
1407 return InvalidParameter;
1409 ret = GdipGetImageBounds(image, &bounds, &unit);
1413 return GdipDrawImageRectRect(graphics, image, x, y, width, height,
1414 bounds.X, bounds.Y, bounds.Width, bounds.Height,
1415 unit, NULL, NULL, NULL);
1418 GpStatus WINGDIPAPI GdipDrawImageRectI(GpGraphics *graphics, GpImage *image,
1419 INT x, INT y, INT width, INT height)
1421 return GdipDrawImageRect(graphics, image, (REAL)x, (REAL)y, (REAL)width, (REAL)height);
1424 GpStatus WINGDIPAPI GdipDrawLine(GpGraphics *graphics, GpPen *pen, REAL x1,
1425 REAL y1, REAL x2, REAL y2)
1431 if(!pen || !graphics)
1432 return InvalidParameter;
1439 save_state = prepare_dc(graphics, pen);
1441 retval = draw_polyline(graphics, pen, pt, 2, TRUE);
1443 restore_dc(graphics, save_state);
1448 GpStatus WINGDIPAPI GdipDrawLineI(GpGraphics *graphics, GpPen *pen, INT x1,
1449 INT y1, INT x2, INT y2)
1455 if(!pen || !graphics)
1456 return InvalidParameter;
1463 save_state = prepare_dc(graphics, pen);
1465 retval = draw_polyline(graphics, pen, pt, 2, TRUE);
1467 restore_dc(graphics, save_state);
1472 GpStatus WINGDIPAPI GdipDrawLines(GpGraphics *graphics, GpPen *pen, GDIPCONST
1473 GpPointF *points, INT count)
1478 if(!pen || !graphics || (count < 2))
1479 return InvalidParameter;
1481 save_state = prepare_dc(graphics, pen);
1483 retval = draw_polyline(graphics, pen, points, count, TRUE);
1485 restore_dc(graphics, save_state);
1490 GpStatus WINGDIPAPI GdipDrawLinesI(GpGraphics *graphics, GpPen *pen, GDIPCONST
1491 GpPoint *points, INT count)
1495 GpPointF *ptf = NULL;
1498 if(!pen || !graphics || (count < 2))
1499 return InvalidParameter;
1501 ptf = GdipAlloc(count * sizeof(GpPointF));
1502 if(!ptf) return OutOfMemory;
1504 for(i = 0; i < count; i ++){
1505 ptf[i].X = (REAL) points[i].X;
1506 ptf[i].Y = (REAL) points[i].Y;
1509 save_state = prepare_dc(graphics, pen);
1511 retval = draw_polyline(graphics, pen, ptf, count, TRUE);
1513 restore_dc(graphics, save_state);
1519 GpStatus WINGDIPAPI GdipDrawPath(GpGraphics *graphics, GpPen *pen, GpPath *path)
1524 if(!pen || !graphics)
1525 return InvalidParameter;
1527 save_state = prepare_dc(graphics, pen);
1529 retval = draw_poly(graphics, pen, path->pathdata.Points,
1530 path->pathdata.Types, path->pathdata.Count, TRUE);
1532 restore_dc(graphics, save_state);
1537 GpStatus WINGDIPAPI GdipDrawPie(GpGraphics *graphics, GpPen *pen, REAL x,
1538 REAL y, REAL width, REAL height, REAL startAngle, REAL sweepAngle)
1542 if(!graphics || !pen)
1543 return InvalidParameter;
1545 save_state = prepare_dc(graphics, pen);
1546 SelectObject(graphics->hdc, GetStockObject(NULL_BRUSH));
1548 draw_pie(graphics, x, y, width, height, startAngle, sweepAngle);
1550 restore_dc(graphics, save_state);
1555 GpStatus WINGDIPAPI GdipDrawPieI(GpGraphics *graphics, GpPen *pen, INT x,
1556 INT y, INT width, INT height, REAL startAngle, REAL sweepAngle)
1558 return GdipDrawPie(graphics,pen,(REAL)x,(REAL)y,(REAL)width,(REAL)height,startAngle,sweepAngle);
1561 GpStatus WINGDIPAPI GdipDrawRectangle(GpGraphics *graphics, GpPen *pen, REAL x,
1562 REAL y, REAL width, REAL height)
1568 if(!pen || !graphics)
1569 return InvalidParameter;
1573 ptf[1].X = x + width;
1575 ptf[2].X = x + width;
1576 ptf[2].Y = y + height;
1578 ptf[3].Y = y + height;
1580 save_state = prepare_dc(graphics, pen);
1581 SelectObject(graphics->hdc, GetStockObject(NULL_BRUSH));
1583 transform_and_round_points(graphics, pti, ptf, 4);
1584 Polygon(graphics->hdc, pti, 4);
1586 restore_dc(graphics, save_state);
1591 GpStatus WINGDIPAPI GdipDrawRectangleI(GpGraphics *graphics, GpPen *pen, INT x,
1592 INT y, INT width, INT height)
1594 return GdipDrawRectangle(graphics,pen,(REAL)x,(REAL)y,(REAL)width,(REAL)height);
1597 GpStatus WINGDIPAPI GdipDrawRectangles(GpGraphics *graphics, GpPen *pen,
1598 GDIPCONST GpRectF* rects, INT count)
1604 if(!graphics || !pen || !rects || count < 1)
1605 return InvalidParameter;
1607 ptf = GdipAlloc(4 * count * sizeof(GpPointF));
1608 pti = GdipAlloc(4 * count * sizeof(POINT));
1616 for(i = 0; i < count; i++){
1617 ptf[4 * i + 3].X = ptf[4 * i].X = rects[i].X;
1618 ptf[4 * i + 1].Y = ptf[4 * i].Y = rects[i].Y;
1619 ptf[4 * i + 2].X = ptf[4 * i + 1].X = rects[i].X + rects[i].Width;
1620 ptf[4 * i + 3].Y = ptf[4 * i + 2].Y = rects[i].Y + rects[i].Height;
1623 save_state = prepare_dc(graphics, pen);
1624 SelectObject(graphics->hdc, GetStockObject(NULL_BRUSH));
1626 transform_and_round_points(graphics, pti, ptf, 4 * count);
1628 for(i = 0; i < count; i++)
1629 Polygon(graphics->hdc, &pti[4 * i], 4);
1631 restore_dc(graphics, save_state);
1639 GpStatus WINGDIPAPI GdipDrawRectanglesI(GpGraphics *graphics, GpPen *pen,
1640 GDIPCONST GpRect* rects, INT count)
1646 if(!rects || count<=0)
1647 return InvalidParameter;
1649 rectsF = GdipAlloc(sizeof(GpRectF) * count);
1653 for(i = 0;i < count;i++){
1654 rectsF[i].X = (REAL)rects[i].X;
1655 rectsF[i].Y = (REAL)rects[i].Y;
1656 rectsF[i].Width = (REAL)rects[i].Width;
1657 rectsF[i].Height = (REAL)rects[i].Height;
1660 ret = GdipDrawRectangles(graphics, pen, rectsF, count);
1666 GpStatus WINGDIPAPI GdipDrawString(GpGraphics *graphics, GDIPCONST WCHAR *string,
1667 INT length, GDIPCONST GpFont *font, GDIPCONST RectF *rect,
1668 GDIPCONST GpStringFormat *format, GDIPCONST GpBrush *brush)
1673 TEXTMETRICW textmet;
1674 GpPointF pt[2], rectcpy[4];
1677 REAL angle, ang_cos, ang_sin, rel_width, rel_height;
1678 INT sum = 0, height = 0, fit, fitcpy, save_state, i, j, lret, nwidth,
1683 if(!graphics || !string || !font || !brush || !rect)
1684 return InvalidParameter;
1686 if((brush->bt != BrushTypeSolidColor)){
1687 FIXME("not implemented for given parameters\n");
1688 return NotImplemented;
1692 TRACE("may be ignoring some format flags: attr %x\n", format->attr);
1694 if(length == -1) length = lstrlenW(string);
1696 stringdup = GdipAlloc(length * sizeof(WCHAR));
1697 if(!stringdup) return OutOfMemory;
1699 save_state = SaveDC(graphics->hdc);
1700 SetBkMode(graphics->hdc, TRANSPARENT);
1701 SetTextColor(graphics->hdc, brush->lb.lbColor);
1703 rectcpy[3].X = rectcpy[0].X = rect->X;
1704 rectcpy[1].Y = rectcpy[0].Y = rect->Y;
1705 rectcpy[2].X = rectcpy[1].X = rect->X + rect->Width;
1706 rectcpy[3].Y = rectcpy[2].Y = rect->Y + rect->Height;
1707 transform_and_round_points(graphics, corners, rectcpy, 4);
1709 if(roundr(rect->Width) == 0 && roundr(rect->Height) == 0){
1710 rel_width = rel_height = 1.0;
1711 nwidth = nheight = INT_MAX;
1714 rel_width = sqrt((corners[1].x - corners[0].x) * (corners[1].x - corners[0].x) +
1715 (corners[1].y - corners[0].y) * (corners[1].y - corners[0].y))
1717 rel_height = sqrt((corners[2].x - corners[1].x) * (corners[2].x - corners[1].x) +
1718 (corners[2].y - corners[1].y) * (corners[2].y - corners[1].y))
1721 nwidth = roundr(rel_width * rect->Width);
1722 nheight = roundr(rel_height * rect->Height);
1723 rgn = CreatePolygonRgn(corners, 4, ALTERNATE);
1724 SelectClipRgn(graphics->hdc, rgn);
1727 /* Use gdi to find the font, then perform transformations on it (height,
1729 SelectObject(graphics->hdc, CreateFontIndirectW(&font->lfw));
1730 GetTextMetricsW(graphics->hdc, &textmet);
1733 lfw.lfHeight = roundr(((REAL)lfw.lfHeight) * rel_height);
1734 lfw.lfWidth = roundr(textmet.tmAveCharWidth * rel_width);
1740 GdipTransformMatrixPoints(graphics->worldtrans, pt, 2);
1741 angle = gdiplus_atan2((pt[1].Y - pt[0].Y), (pt[1].X - pt[0].X));
1742 ang_cos = cos(angle);
1743 ang_sin = sin(angle);
1744 lfw.lfEscapement = lfw.lfOrientation = -roundr((angle / M_PI) * 1800.0);
1746 gdifont = CreateFontIndirectW(&lfw);
1747 DeleteObject(SelectObject(graphics->hdc, CreateFontIndirectW(&lfw)));
1749 for(i = 0, j = 0; i < length; i++){
1750 if(!isprintW(string[i]) && (string[i] != '\n'))
1753 stringdup[j] = string[i];
1760 while(sum < length){
1761 drawcoord.left = corners[0].x + roundr(ang_sin * (REAL) height);
1762 drawcoord.top = corners[0].y + roundr(ang_cos * (REAL) height);
1764 GetTextExtentExPointW(graphics->hdc, stringdup + sum, length - sum,
1765 nwidth, &fit, NULL, &size);
1769 DrawTextW(graphics->hdc, stringdup + sum, 1, &drawcoord, DT_NOCLIP |
1774 for(lret = 0; lret < fit; lret++)
1775 if(*(stringdup + sum + lret) == '\n')
1778 /* Line break code (may look strange, but it imitates windows). */
1780 fit = lret; /* this is not an off-by-one error */
1781 else if(fit < (length - sum)){
1782 if(*(stringdup + sum + fit) == ' ')
1783 while(*(stringdup + sum + fit) == ' ')
1786 while(*(stringdup + sum + fit - 1) != ' '){
1789 if(*(stringdup + sum + fit) == '\t')
1798 DrawTextW(graphics->hdc, stringdup + sum, min(length - sum, fit),
1799 &drawcoord, DT_NOCLIP | DT_EXPANDTABS);
1801 sum += fit + (lret < fitcpy ? 1 : 0);
1804 if(height > nheight)
1807 /* Stop if this was a linewrap (but not if it was a linebreak). */
1808 if((lret == fitcpy) && format && (format->attr & StringFormatFlagsNoWrap))
1812 GdipFree(stringdup);
1814 DeleteObject(gdifont);
1816 RestoreDC(graphics->hdc, save_state);
1821 GpStatus WINGDIPAPI GdipFillEllipse(GpGraphics *graphics, GpBrush *brush, REAL x,
1822 REAL y, REAL width, REAL height)
1828 if(!graphics || !brush)
1829 return InvalidParameter;
1833 ptf[1].X = x + width;
1834 ptf[1].Y = y + height;
1836 save_state = SaveDC(graphics->hdc);
1837 EndPath(graphics->hdc);
1838 SelectObject(graphics->hdc, brush->gdibrush);
1839 SelectObject(graphics->hdc, GetStockObject(NULL_PEN));
1841 transform_and_round_points(graphics, pti, ptf, 2);
1843 Ellipse(graphics->hdc, pti[0].x, pti[0].y, pti[1].x, pti[1].y);
1845 RestoreDC(graphics->hdc, save_state);
1850 GpStatus WINGDIPAPI GdipFillEllipseI(GpGraphics *graphics, GpBrush *brush, INT x,
1851 INT y, INT width, INT height)
1853 return GdipFillEllipse(graphics,brush,(REAL)x,(REAL)y,(REAL)width,(REAL)height);
1856 GpStatus WINGDIPAPI GdipFillPath(GpGraphics *graphics, GpBrush *brush, GpPath *path)
1861 if(!brush || !graphics || !path)
1862 return InvalidParameter;
1864 save_state = SaveDC(graphics->hdc);
1865 EndPath(graphics->hdc);
1866 SelectObject(graphics->hdc, brush->gdibrush);
1867 SetPolyFillMode(graphics->hdc, (path->fill == FillModeAlternate ? ALTERNATE
1870 BeginPath(graphics->hdc);
1871 retval = draw_poly(graphics, NULL, path->pathdata.Points,
1872 path->pathdata.Types, path->pathdata.Count, FALSE);
1877 EndPath(graphics->hdc);
1878 FillPath(graphics->hdc);
1883 RestoreDC(graphics->hdc, save_state);
1888 GpStatus WINGDIPAPI GdipFillPie(GpGraphics *graphics, GpBrush *brush, REAL x,
1889 REAL y, REAL width, REAL height, REAL startAngle, REAL sweepAngle)
1893 if(!graphics || !brush)
1894 return InvalidParameter;
1896 save_state = SaveDC(graphics->hdc);
1897 EndPath(graphics->hdc);
1898 SelectObject(graphics->hdc, brush->gdibrush);
1899 SelectObject(graphics->hdc, GetStockObject(NULL_PEN));
1901 draw_pie(graphics, x, y, width, height, startAngle, sweepAngle);
1903 RestoreDC(graphics->hdc, save_state);
1908 GpStatus WINGDIPAPI GdipFillPieI(GpGraphics *graphics, GpBrush *brush, INT x,
1909 INT y, INT width, INT height, REAL startAngle, REAL sweepAngle)
1911 return GdipFillPie(graphics,brush,(REAL)x,(REAL)y,(REAL)width,(REAL)height,startAngle,sweepAngle);
1914 GpStatus WINGDIPAPI GdipFillPolygon(GpGraphics *graphics, GpBrush *brush,
1915 GDIPCONST GpPointF *points, INT count, GpFillMode fillMode)
1918 GpPointF *ptf = NULL;
1920 GpStatus retval = Ok;
1922 if(!graphics || !brush || !points || !count)
1923 return InvalidParameter;
1925 ptf = GdipAlloc(count * sizeof(GpPointF));
1926 pti = GdipAlloc(count * sizeof(POINT));
1928 retval = OutOfMemory;
1932 memcpy(ptf, points, count * sizeof(GpPointF));
1934 save_state = SaveDC(graphics->hdc);
1935 EndPath(graphics->hdc);
1936 SelectObject(graphics->hdc, brush->gdibrush);
1937 SelectObject(graphics->hdc, GetStockObject(NULL_PEN));
1938 SetPolyFillMode(graphics->hdc, (fillMode == FillModeAlternate ? ALTERNATE
1941 transform_and_round_points(graphics, pti, ptf, count);
1942 Polygon(graphics->hdc, pti, count);
1944 RestoreDC(graphics->hdc, save_state);
1953 GpStatus WINGDIPAPI GdipFillPolygonI(GpGraphics *graphics, GpBrush *brush,
1954 GDIPCONST GpPoint *points, INT count, GpFillMode fillMode)
1957 GpPointF *ptf = NULL;
1959 GpStatus retval = Ok;
1961 if(!graphics || !brush || !points || !count)
1962 return InvalidParameter;
1964 ptf = GdipAlloc(count * sizeof(GpPointF));
1965 pti = GdipAlloc(count * sizeof(POINT));
1967 retval = OutOfMemory;
1971 for(i = 0; i < count; i ++){
1972 ptf[i].X = (REAL) points[i].X;
1973 ptf[i].Y = (REAL) points[i].Y;
1976 save_state = SaveDC(graphics->hdc);
1977 EndPath(graphics->hdc);
1978 SelectObject(graphics->hdc, brush->gdibrush);
1979 SelectObject(graphics->hdc, GetStockObject(NULL_PEN));
1980 SetPolyFillMode(graphics->hdc, (fillMode == FillModeAlternate ? ALTERNATE
1983 transform_and_round_points(graphics, pti, ptf, count);
1984 Polygon(graphics->hdc, pti, count);
1986 RestoreDC(graphics->hdc, save_state);
1995 GpStatus WINGDIPAPI GdipFillRectangle(GpGraphics *graphics, GpBrush *brush,
1996 REAL x, REAL y, REAL width, REAL height)
2002 if(!graphics || !brush)
2003 return InvalidParameter;
2007 ptf[1].X = x + width;
2009 ptf[2].X = x + width;
2010 ptf[2].Y = y + height;
2012 ptf[3].Y = y + height;
2014 save_state = SaveDC(graphics->hdc);
2015 EndPath(graphics->hdc);
2016 SelectObject(graphics->hdc, brush->gdibrush);
2017 SelectObject(graphics->hdc, GetStockObject(NULL_PEN));
2019 transform_and_round_points(graphics, pti, ptf, 4);
2021 Polygon(graphics->hdc, pti, 4);
2023 RestoreDC(graphics->hdc, save_state);
2028 GpStatus WINGDIPAPI GdipFillRectangleI(GpGraphics *graphics, GpBrush *brush,
2029 INT x, INT y, INT width, INT height)
2035 if(!graphics || !brush)
2036 return InvalidParameter;
2040 ptf[1].X = x + width;
2042 ptf[2].X = x + width;
2043 ptf[2].Y = y + height;
2045 ptf[3].Y = y + height;
2047 save_state = SaveDC(graphics->hdc);
2048 EndPath(graphics->hdc);
2049 SelectObject(graphics->hdc, brush->gdibrush);
2050 SelectObject(graphics->hdc, GetStockObject(NULL_PEN));
2052 transform_and_round_points(graphics, pti, ptf, 4);
2054 Polygon(graphics->hdc, pti, 4);
2056 RestoreDC(graphics->hdc, save_state);
2061 GpStatus WINGDIPAPI GdipFillRectangles(GpGraphics *graphics, GpBrush *brush, GDIPCONST GpRectF *rects,
2068 return InvalidParameter;
2070 for(i = 0; i < count; i++){
2071 ret = GdipFillRectangle(graphics, brush, rects[i].X, rects[i].Y, rects[i].Width, rects[i].Height);
2072 if(ret != Ok) return ret;
2078 GpStatus WINGDIPAPI GdipFillRectanglesI(GpGraphics *graphics, GpBrush *brush, GDIPCONST GpRect *rects,
2085 if(!rects || count <= 0)
2086 return InvalidParameter;
2088 rectsF = GdipAlloc(sizeof(GpRectF)*count);
2092 for(i = 0; i < count; i++){
2093 rectsF[i].X = (REAL)rects[i].X;
2094 rectsF[i].Y = (REAL)rects[i].Y;
2095 rectsF[i].X = (REAL)rects[i].Width;
2096 rectsF[i].Height = (REAL)rects[i].Height;
2099 ret = GdipFillRectangles(graphics,brush,rectsF,count);
2105 GpStatus WINGDIPAPI GdipFlush(GpGraphics *graphics, GpFlushIntention intention)
2110 return InvalidParameter;
2113 FIXME("not implemented\n");
2115 return NotImplemented;
2118 /* FIXME: Compositing mode is not used anywhere except the getter/setter. */
2119 GpStatus WINGDIPAPI GdipGetCompositingMode(GpGraphics *graphics,
2120 CompositingMode *mode)
2122 if(!graphics || !mode)
2123 return InvalidParameter;
2125 *mode = graphics->compmode;
2130 /* FIXME: Compositing quality is not used anywhere except the getter/setter. */
2131 GpStatus WINGDIPAPI GdipGetCompositingQuality(GpGraphics *graphics,
2132 CompositingQuality *quality)
2134 if(!graphics || !quality)
2135 return InvalidParameter;
2137 *quality = graphics->compqual;
2142 /* FIXME: Interpolation mode is not used anywhere except the getter/setter. */
2143 GpStatus WINGDIPAPI GdipGetInterpolationMode(GpGraphics *graphics,
2144 InterpolationMode *mode)
2146 if(!graphics || !mode)
2147 return InvalidParameter;
2149 *mode = graphics->interpolation;
2154 GpStatus WINGDIPAPI GdipGetPageScale(GpGraphics *graphics, REAL *scale)
2156 if(!graphics || !scale)
2157 return InvalidParameter;
2159 *scale = graphics->scale;
2164 GpStatus WINGDIPAPI GdipGetPageUnit(GpGraphics *graphics, GpUnit *unit)
2166 if(!graphics || !unit)
2167 return InvalidParameter;
2169 *unit = graphics->unit;
2174 /* FIXME: Pixel offset mode is not used anywhere except the getter/setter. */
2175 GpStatus WINGDIPAPI GdipGetPixelOffsetMode(GpGraphics *graphics, PixelOffsetMode
2178 if(!graphics || !mode)
2179 return InvalidParameter;
2181 *mode = graphics->pixeloffset;
2186 /* FIXME: Smoothing mode is not used anywhere except the getter/setter. */
2187 GpStatus WINGDIPAPI GdipGetSmoothingMode(GpGraphics *graphics, SmoothingMode *mode)
2189 if(!graphics || !mode)
2190 return InvalidParameter;
2192 *mode = graphics->smoothing;
2197 /* FIXME: Text rendering hint is not used anywhere except the getter/setter. */
2198 GpStatus WINGDIPAPI GdipGetTextRenderingHint(GpGraphics *graphics,
2199 TextRenderingHint *hint)
2201 if(!graphics || !hint)
2202 return InvalidParameter;
2204 *hint = graphics->texthint;
2209 GpStatus WINGDIPAPI GdipGetWorldTransform(GpGraphics *graphics, GpMatrix *matrix)
2211 if(!graphics || !matrix)
2212 return InvalidParameter;
2214 *matrix = *graphics->worldtrans;
2218 /* Find the smallest rectangle that bounds the text when it is printed in rect
2219 * according to the format options listed in format. If rect has 0 width and
2220 * height, then just find the smallest rectangle that bounds the text when it's
2221 * printed at location (rect->X, rect-Y). */
2222 GpStatus WINGDIPAPI GdipMeasureString(GpGraphics *graphics,
2223 GDIPCONST WCHAR *string, INT length, GDIPCONST GpFont *font,
2224 GDIPCONST RectF *rect, GDIPCONST GpStringFormat *format, RectF *bounds,
2225 INT *codepointsfitted, INT *linesfilled)
2229 INT sum = 0, height = 0, fit, fitcpy, max_width = 0, i, j, lret, nwidth,
2233 if(!graphics || !string || !font || !rect)
2234 return InvalidParameter;
2236 if(codepointsfitted || linesfilled){
2237 FIXME("not implemented for given parameters\n");
2238 return NotImplemented;
2242 TRACE("may be ignoring some format flags: attr %x\n", format->attr);
2244 if(length == -1) length = lstrlenW(string);
2246 stringdup = GdipAlloc(length * sizeof(WCHAR));
2247 if(!stringdup) return OutOfMemory;
2249 oldfont = SelectObject(graphics->hdc, CreateFontIndirectW(&font->lfw));
2250 nwidth = roundr(rect->Width);
2251 nheight = roundr(rect->Height);
2253 if((nwidth == 0) && (nheight == 0))
2254 nwidth = nheight = INT_MAX;
2256 for(i = 0, j = 0; i < length; i++){
2257 if(!isprintW(string[i]) && (string[i] != '\n'))
2260 stringdup[j] = string[i];
2267 while(sum < length){
2268 GetTextExtentExPointW(graphics->hdc, stringdup + sum, length - sum,
2269 nwidth, &fit, NULL, &size);
2275 for(lret = 0; lret < fit; lret++)
2276 if(*(stringdup + sum + lret) == '\n')
2279 /* Line break code (may look strange, but it imitates windows). */
2281 fit = lret; /* this is not an off-by-one error */
2282 else if(fit < (length - sum)){
2283 if(*(stringdup + sum + fit) == ' ')
2284 while(*(stringdup + sum + fit) == ' ')
2287 while(*(stringdup + sum + fit - 1) != ' '){
2290 if(*(stringdup + sum + fit) == '\t')
2300 GetTextExtentExPointW(graphics->hdc, stringdup + sum, fit,
2301 nwidth, &j, NULL, &size);
2303 sum += fit + (lret < fitcpy ? 1 : 0);
2305 max_width = max(max_width, size.cx);
2307 if(height > nheight)
2310 /* Stop if this was a linewrap (but not if it was a linebreak). */
2311 if((lret == fitcpy) && format && (format->attr & StringFormatFlagsNoWrap))
2315 bounds->X = rect->X;
2316 bounds->Y = rect->Y;
2317 bounds->Width = (REAL)max_width;
2318 bounds->Height = (REAL) min(height, nheight);
2320 GdipFree(stringdup);
2321 DeleteObject(SelectObject(graphics->hdc, oldfont));
2326 GpStatus WINGDIPAPI GdipRestoreGraphics(GpGraphics *graphics, GraphicsState state)
2331 return InvalidParameter;
2334 FIXME("graphics state not implemented\n");
2336 return NotImplemented;
2339 GpStatus WINGDIPAPI GdipRotateWorldTransform(GpGraphics *graphics, REAL angle,
2340 GpMatrixOrder order)
2343 return InvalidParameter;
2345 return GdipRotateMatrix(graphics->worldtrans, angle, order);
2348 GpStatus WINGDIPAPI GdipSaveGraphics(GpGraphics *graphics, GraphicsState *state)
2352 if(!graphics || !state)
2353 return InvalidParameter;
2356 FIXME("graphics state not implemented\n");
2358 return NotImplemented;
2361 GpStatus WINGDIPAPI GdipScaleWorldTransform(GpGraphics *graphics, REAL sx,
2362 REAL sy, GpMatrixOrder order)
2365 return InvalidParameter;
2367 return GdipScaleMatrix(graphics->worldtrans, sx, sy, order);
2370 GpStatus WINGDIPAPI GdipSetCompositingMode(GpGraphics *graphics,
2371 CompositingMode mode)
2374 return InvalidParameter;
2376 graphics->compmode = mode;
2381 GpStatus WINGDIPAPI GdipSetCompositingQuality(GpGraphics *graphics,
2382 CompositingQuality quality)
2385 return InvalidParameter;
2387 graphics->compqual = quality;
2392 GpStatus WINGDIPAPI GdipSetInterpolationMode(GpGraphics *graphics,
2393 InterpolationMode mode)
2396 return InvalidParameter;
2398 graphics->interpolation = mode;
2403 GpStatus WINGDIPAPI GdipSetPageScale(GpGraphics *graphics, REAL scale)
2405 if(!graphics || (scale <= 0.0))
2406 return InvalidParameter;
2408 graphics->scale = scale;
2413 GpStatus WINGDIPAPI GdipSetPageUnit(GpGraphics *graphics, GpUnit unit)
2415 if(!graphics || (unit == UnitWorld))
2416 return InvalidParameter;
2418 graphics->unit = unit;
2423 GpStatus WINGDIPAPI GdipSetPixelOffsetMode(GpGraphics *graphics, PixelOffsetMode
2427 return InvalidParameter;
2429 graphics->pixeloffset = mode;
2434 GpStatus WINGDIPAPI GdipSetSmoothingMode(GpGraphics *graphics, SmoothingMode mode)
2437 return InvalidParameter;
2439 graphics->smoothing = mode;
2444 GpStatus WINGDIPAPI GdipSetTextRenderingHint(GpGraphics *graphics,
2445 TextRenderingHint hint)
2448 return InvalidParameter;
2450 graphics->texthint = hint;
2455 GpStatus WINGDIPAPI GdipSetWorldTransform(GpGraphics *graphics, GpMatrix *matrix)
2457 if(!graphics || !matrix)
2458 return InvalidParameter;
2460 GdipDeleteMatrix(graphics->worldtrans);
2461 return GdipCloneMatrix(matrix, &graphics->worldtrans);
2464 GpStatus WINGDIPAPI GdipTranslateWorldTransform(GpGraphics *graphics, REAL dx,
2465 REAL dy, GpMatrixOrder order)
2468 return InvalidParameter;
2470 return GdipTranslateMatrix(graphics->worldtrans, dx, dy, order);
2473 GpStatus WINGDIPAPI GdipSetClipRectI(GpGraphics *graphics, INT x, INT y,
2474 INT width, INT height,
2475 CombineMode combineMode)
2480 FIXME("not implemented\n");
2482 return NotImplemented;
2485 GpStatus WINGDIPAPI GdipSetClipRegion(GpGraphics *graphics, GpRegion *region,
2486 CombineMode combineMode)
2491 FIXME("not implemented\n");
2493 return NotImplemented;
2496 GpStatus WINGDIPAPI GdipSetMetafileDownLevelRasterizationLimit(GpGraphics *graphics,
2502 FIXME("not implemented\n");
2504 return NotImplemented;
2507 GpStatus WINGDIPAPI GdipDrawPolygon(GpGraphics *graphics,GpPen *pen,GDIPCONST GpPointF *points,
2513 if(!graphics || !pen || count<=0)
2514 return InvalidParameter;
2516 pti = GdipAlloc(sizeof(POINT) * count);
2518 save_state = prepare_dc(graphics, pen);
2519 SelectObject(graphics->hdc, GetStockObject(NULL_BRUSH));
2521 transform_and_round_points(graphics, pti, (GpPointF*)points, count);
2522 Polygon(graphics->hdc, pti, count);
2524 restore_dc(graphics, save_state);
2530 GpStatus WINGDIPAPI GdipDrawPolygonI(GpGraphics *graphics,GpPen *pen,GDIPCONST GpPoint *points,
2537 if(count<=0) return InvalidParameter;
2538 ptf = GdipAlloc(sizeof(GpPointF) * count);
2540 for(i = 0;i < count; i++){
2541 ptf[i].X = (REAL)points[i].X;
2542 ptf[i].Y = (REAL)points[i].Y;
2545 ret = GdipDrawPolygon(graphics,pen,ptf,count);
2551 GpStatus WINGDIPAPI GdipGetDpiX(GpGraphics *graphics, REAL* dpi)
2553 if(!graphics || !dpi)
2554 return InvalidParameter;
2556 *dpi = (REAL)GetDeviceCaps(graphics->hdc, LOGPIXELSX);
2561 GpStatus WINGDIPAPI GdipGetDpiY(GpGraphics *graphics, REAL* dpi)
2563 if(!graphics || !dpi)
2564 return InvalidParameter;
2566 *dpi = (REAL)GetDeviceCaps(graphics->hdc, LOGPIXELSY);
2571 GpStatus WINGDIPAPI GdipMultiplyWorldTransform(GpGraphics *graphics, GDIPCONST GpMatrix *matrix,
2572 GpMatrixOrder order)
2577 if(!graphics || !matrix)
2578 return InvalidParameter;
2580 m = *(graphics->worldtrans);
2582 ret = GdipMultiplyMatrix(&m, (GpMatrix*)matrix, order);
2584 *(graphics->worldtrans) = m;
2589 GpStatus WINGDIPAPI GdipGetDC(GpGraphics *graphics, HDC *hdc)
2591 FIXME("(%p, %p): stub\n", graphics, hdc);
2594 return NotImplemented;
2597 GpStatus WINGDIPAPI GdipReleaseDC(GpGraphics *graphics, HDC hdc)
2599 FIXME("(%p, %p): stub\n", graphics, hdc);
2601 return NotImplemented;
2604 GpStatus WINGDIPAPI GdipGetClip(GpGraphics *graphics, GpRegion *region)
2606 FIXME("(%p, %p): stub\n", graphics, region);
2608 return NotImplemented;