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
32 #include "gdiplus_private.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
37 /******************************************************************************
38 * GdipCloneBrush [GDIPLUS.@]
40 GpStatus WINGDIPAPI GdipCloneBrush(GpBrush *brush, GpBrush **clone)
42 TRACE("(%p, %p)\n", brush, clone);
45 return InvalidParameter;
48 case BrushTypeSolidColor:
49 *clone = GdipAlloc(sizeof(GpSolidFill));
50 if (!*clone) return OutOfMemory;
52 memcpy(*clone, brush, sizeof(GpSolidFill));
54 (*clone)->gdibrush = CreateBrushIndirect(&(*clone)->lb);
56 case BrushTypePathGradient:{
57 GpPathGradient *src, *dest;
60 *clone = GdipAlloc(sizeof(GpPathGradient));
61 if (!*clone) return OutOfMemory;
63 src = (GpPathGradient*) brush,
64 dest = (GpPathGradient*) *clone;
65 count = src->pathdata.Count;
67 memcpy(dest, src, sizeof(GpPathGradient));
69 dest->pathdata.Count = count;
70 dest->pathdata.Points = GdipAlloc(count * sizeof(PointF));
71 dest->pathdata.Types = GdipAlloc(count);
73 if(!dest->pathdata.Points || !dest->pathdata.Types){
74 GdipFree(dest->pathdata.Points);
75 GdipFree(dest->pathdata.Types);
80 memcpy(dest->pathdata.Points, src->pathdata.Points, count * sizeof(PointF));
81 memcpy(dest->pathdata.Types, src->pathdata.Types, count);
84 count = src->blendcount;
85 dest->blendcount = count;
86 dest->blendfac = GdipAlloc(count * sizeof(REAL));
87 dest->blendpos = GdipAlloc(count * sizeof(REAL));
89 if(!dest->blendfac || !dest->blendpos){
90 GdipFree(dest->pathdata.Points);
91 GdipFree(dest->pathdata.Types);
92 GdipFree(dest->blendfac);
93 GdipFree(dest->blendpos);
98 memcpy(dest->blendfac, src->blendfac, count * sizeof(REAL));
99 memcpy(dest->blendpos, src->blendpos, count * sizeof(REAL));
103 case BrushTypeLinearGradient:
104 *clone = GdipAlloc(sizeof(GpLineGradient));
105 if(!*clone) return OutOfMemory;
107 memcpy(*clone, brush, sizeof(GpLineGradient));
109 (*clone)->gdibrush = CreateSolidBrush((*clone)->lb.lbColor);
111 case BrushTypeTextureFill:
112 *clone = GdipAlloc(sizeof(GpTexture));
113 if(!*clone) return OutOfMemory;
115 memcpy(*clone, brush, sizeof(GpTexture));
117 (*clone)->gdibrush = CreateBrushIndirect(&(*clone)->lb);
120 ERR("not implemented for brush type %d\n", brush->bt);
121 return NotImplemented;
127 /******************************************************************************
128 * GdipCreateLineBrush [GDIPLUS.@]
130 GpStatus WINGDIPAPI GdipCreateLineBrush(GDIPCONST GpPointF* startpoint,
131 GDIPCONST GpPointF* endpoint, ARGB startcolor, ARGB endcolor,
132 GpWrapMode wrap, GpLineGradient **line)
134 COLORREF col = ARGB2COLORREF(startcolor);
136 TRACE("(%p, %p, %x, %x, %d, %p)\n", startpoint, endpoint,
137 startcolor, endcolor, wrap, line);
139 if(!line || !startpoint || !endpoint || wrap == WrapModeClamp)
140 return InvalidParameter;
142 *line = GdipAlloc(sizeof(GpLineGradient));
143 if(!*line) return OutOfMemory;
145 (*line)->brush.lb.lbStyle = BS_SOLID;
146 (*line)->brush.lb.lbColor = col;
147 (*line)->brush.lb.lbHatch = 0;
148 (*line)->brush.gdibrush = CreateSolidBrush(col);
149 (*line)->brush.bt = BrushTypeLinearGradient;
151 (*line)->startpoint.X = startpoint->X;
152 (*line)->startpoint.Y = startpoint->Y;
153 (*line)->endpoint.X = endpoint->X;
154 (*line)->endpoint.Y = endpoint->Y;
155 (*line)->startcolor = startcolor;
156 (*line)->endcolor = endcolor;
157 (*line)->wrap = wrap;
158 (*line)->gamma = FALSE;
163 GpStatus WINGDIPAPI GdipCreateLineBrushI(GDIPCONST GpPoint* startpoint,
164 GDIPCONST GpPoint* endpoint, ARGB startcolor, ARGB endcolor,
165 GpWrapMode wrap, GpLineGradient **line)
170 TRACE("(%p, %p, %x, %x, %d, %p)\n", startpoint, endpoint,
171 startcolor, endcolor, wrap, line);
173 if(!startpoint || !endpoint)
174 return InvalidParameter;
176 stF.X = (REAL)startpoint->X;
177 stF.Y = (REAL)startpoint->Y;
178 endF.X = (REAL)endpoint->X;
179 endF.X = (REAL)endpoint->Y;
181 return GdipCreateLineBrush(&stF, &endF, startcolor, endcolor, wrap, line);
184 GpStatus WINGDIPAPI GdipCreateLineBrushFromRect(GDIPCONST GpRectF* rect,
185 ARGB startcolor, ARGB endcolor, LinearGradientMode mode, GpWrapMode wrap,
186 GpLineGradient **line)
190 TRACE("(%p, %x, %x, %d, %d, %p)\n", rect, startcolor, endcolor, mode,
194 return InvalidParameter;
198 end.X = rect->X + rect->Width;
199 end.Y = rect->Y + rect->Height;
201 return GdipCreateLineBrush(&start, &end, startcolor, endcolor, wrap, line);
204 GpStatus WINGDIPAPI GdipCreateLineBrushFromRectI(GDIPCONST GpRect* rect,
205 ARGB startcolor, ARGB endcolor, LinearGradientMode mode, GpWrapMode wrap,
206 GpLineGradient **line)
210 TRACE("(%p, %x, %x, %d, %d, %p)\n", rect, startcolor, endcolor, mode,
213 rectF.X = (REAL) rect->X;
214 rectF.Y = (REAL) rect->Y;
215 rectF.Width = (REAL) rect->Width;
216 rectF.Height = (REAL) rect->Height;
218 return GdipCreateLineBrushFromRect(&rectF, startcolor, endcolor, mode, wrap, line);
221 /******************************************************************************
222 * GdipCreateLineBrushFromRectWithAngle [GDIPLUS.@]
224 * FIXME: angle value completely ignored. Don't know how to use it since native
225 * always set Brush rectangle to rect (independetly of this angle).
226 * Maybe it's used only on drawing.
228 GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngle(GDIPCONST GpRectF* rect,
229 ARGB startcolor, ARGB endcolor, REAL angle, BOOL isAngleScalable, GpWrapMode wrap,
230 GpLineGradient **line)
232 TRACE("(%p, %x, %x, %.2f, %d, %d, %p)\n", rect, startcolor, endcolor, angle, isAngleScalable,
235 return GdipCreateLineBrushFromRect(rect, startcolor, endcolor, LinearGradientModeForwardDiagonal,
239 GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngleI(GDIPCONST GpRect* rect,
240 ARGB startcolor, ARGB endcolor, REAL angle, BOOL isAngleScalable, GpWrapMode wrap,
241 GpLineGradient **line)
243 TRACE("(%p, %x, %x, %.2f, %d, %d, %p)\n", rect, startcolor, endcolor, angle, isAngleScalable,
246 return GdipCreateLineBrushFromRectI(rect, startcolor, endcolor, LinearGradientModeForwardDiagonal,
250 GpStatus WINGDIPAPI GdipCreatePathGradient(GDIPCONST GpPointF* points,
251 INT count, GpWrapMode wrap, GpPathGradient **grad)
253 COLORREF col = ARGB2COLORREF(0xffffffff);
255 TRACE("(%p, %d, %d, %p)\n", points, count, wrap, grad);
258 return InvalidParameter;
263 *grad = GdipAlloc(sizeof(GpPathGradient));
264 if (!*grad) return OutOfMemory;
266 (*grad)->blendfac = GdipAlloc(sizeof(REAL));
267 if(!(*grad)->blendfac){
271 (*grad)->blendfac[0] = 1.0;
272 (*grad)->blendpos = NULL;
273 (*grad)->blendcount = 1;
275 (*grad)->pathdata.Count = count;
276 (*grad)->pathdata.Points = GdipAlloc(count * sizeof(PointF));
277 (*grad)->pathdata.Types = GdipAlloc(count);
279 if(!(*grad)->pathdata.Points || !(*grad)->pathdata.Types){
280 GdipFree((*grad)->pathdata.Points);
281 GdipFree((*grad)->pathdata.Types);
286 memcpy((*grad)->pathdata.Points, points, count * sizeof(PointF));
287 memset((*grad)->pathdata.Types, PathPointTypeLine, count);
289 (*grad)->brush.lb.lbStyle = BS_SOLID;
290 (*grad)->brush.lb.lbColor = col;
291 (*grad)->brush.lb.lbHatch = 0;
293 (*grad)->brush.gdibrush = CreateSolidBrush(col);
294 (*grad)->brush.bt = BrushTypePathGradient;
295 (*grad)->centercolor = 0xffffffff;
296 (*grad)->wrap = wrap;
297 (*grad)->gamma = FALSE;
298 (*grad)->center.X = 0.0;
299 (*grad)->center.Y = 0.0;
300 (*grad)->focus.X = 0.0;
301 (*grad)->focus.Y = 0.0;
306 GpStatus WINGDIPAPI GdipCreatePathGradientI(GDIPCONST GpPoint* points,
307 INT count, GpWrapMode wrap, GpPathGradient **grad)
313 TRACE("(%p, %d, %d, %p)\n", points, count, wrap, grad);
316 return InvalidParameter;
321 pointsF = GdipAlloc(sizeof(GpPointF) * count);
325 for(i = 0; i < count; i++){
326 pointsF[i].X = (REAL)points[i].X;
327 pointsF[i].Y = (REAL)points[i].Y;
330 ret = GdipCreatePathGradient(pointsF, count, wrap, grad);
336 /******************************************************************************
337 * GdipCreatePathGradientFromPath [GDIPLUS.@]
339 * FIXME: path gradient brushes not truly supported (drawn as solid brushes)
341 GpStatus WINGDIPAPI GdipCreatePathGradientFromPath(GDIPCONST GpPath* path,
342 GpPathGradient **grad)
344 COLORREF col = ARGB2COLORREF(0xffffffff);
346 TRACE("(%p, %p)\n", path, grad);
349 return InvalidParameter;
351 *grad = GdipAlloc(sizeof(GpPathGradient));
352 if (!*grad) return OutOfMemory;
354 (*grad)->blendfac = GdipAlloc(sizeof(REAL));
355 if(!(*grad)->blendfac){
359 (*grad)->blendfac[0] = 1.0;
360 (*grad)->blendpos = NULL;
361 (*grad)->blendcount = 1;
363 (*grad)->pathdata.Count = path->pathdata.Count;
364 (*grad)->pathdata.Points = GdipAlloc(path->pathdata.Count * sizeof(PointF));
365 (*grad)->pathdata.Types = GdipAlloc(path->pathdata.Count);
367 if(!(*grad)->pathdata.Points || !(*grad)->pathdata.Types){
368 GdipFree((*grad)->pathdata.Points);
369 GdipFree((*grad)->pathdata.Types);
374 memcpy((*grad)->pathdata.Points, path->pathdata.Points,
375 path->pathdata.Count * sizeof(PointF));
376 memcpy((*grad)->pathdata.Types, path->pathdata.Types, path->pathdata.Count);
378 (*grad)->brush.lb.lbStyle = BS_SOLID;
379 (*grad)->brush.lb.lbColor = col;
380 (*grad)->brush.lb.lbHatch = 0;
382 (*grad)->brush.gdibrush = CreateSolidBrush(col);
383 (*grad)->brush.bt = BrushTypePathGradient;
384 (*grad)->centercolor = 0xffffffff;
385 (*grad)->wrap = WrapModeClamp;
386 (*grad)->gamma = FALSE;
387 /* FIXME: this should be set to the "centroid" of the path by default */
388 (*grad)->center.X = 0.0;
389 (*grad)->center.Y = 0.0;
390 (*grad)->focus.X = 0.0;
391 (*grad)->focus.Y = 0.0;
396 /******************************************************************************
397 * GdipCreateSolidFill [GDIPLUS.@]
399 GpStatus WINGDIPAPI GdipCreateSolidFill(ARGB color, GpSolidFill **sf)
401 COLORREF col = ARGB2COLORREF(color);
403 TRACE("(%x, %p)\n", color, sf);
405 if(!sf) return InvalidParameter;
407 *sf = GdipAlloc(sizeof(GpSolidFill));
408 if (!*sf) return OutOfMemory;
410 (*sf)->brush.lb.lbStyle = BS_SOLID;
411 (*sf)->brush.lb.lbColor = col;
412 (*sf)->brush.lb.lbHatch = 0;
414 (*sf)->brush.gdibrush = CreateSolidBrush(col);
415 (*sf)->brush.bt = BrushTypeSolidColor;
416 (*sf)->color = color;
421 /******************************************************************************
422 * GdipCreateTexture [GDIPLUS.@]
425 * image [I] image to use
426 * wrapmode [I] optional
427 * texture [O] pointer to the resulting texturebrush
431 * FAILURE: element of GpStatus
433 GpStatus WINGDIPAPI GdipCreateTexture(GpImage *image, GpWrapMode wrapmode,
437 GpImageAttributes attributes;
440 TRACE("%p, %d %p\n", image, wrapmode, texture);
442 if (!(image && texture))
443 return InvalidParameter;
445 stat = GdipGetImageWidth(image, &width);
446 if (stat != Ok) return stat;
447 stat = GdipGetImageHeight(image, &height);
448 if (stat != Ok) return stat;
449 attributes.wrap = wrapmode;
451 return GdipCreateTextureIA(image, &attributes, 0, 0, width, height,
455 /******************************************************************************
456 * GdipCreateTexture2 [GDIPLUS.@]
458 GpStatus WINGDIPAPI GdipCreateTexture2(GpImage *image, GpWrapMode wrapmode,
459 REAL x, REAL y, REAL width, REAL height, GpTexture **texture)
461 GpImageAttributes attributes;
463 TRACE("%p %d %f %f %f %f %p\n", image, wrapmode,
464 x, y, width, height, texture);
466 attributes.wrap = wrapmode;
467 return GdipCreateTextureIA(image, &attributes, x, y, width, height,
471 /******************************************************************************
472 * GdipCreateTextureIA [GDIPLUS.@]
474 * FIXME: imageattr ignored
476 GpStatus WINGDIPAPI GdipCreateTextureIA(GpImage *image,
477 GDIPCONST GpImageAttributes *imageattr, REAL x, REAL y, REAL width,
478 REAL height, GpTexture **texture)
484 BITMAPINFOHEADER *bmih;
485 INT n_x, n_y, n_width, n_height, abs_height, stride, image_stride, i, bytespp;
487 BYTE *dibits, *buff, *textbits;
490 TRACE("(%p, %p, %.2f, %.2f, %.2f, %.2f, %p)\n", image, imageattr, x, y, width, height,
493 if(!image || !texture || x < 0.0 || y < 0.0 || width < 0.0 || height < 0.0)
494 return InvalidParameter;
496 if(image->type != ImageTypeBitmap){
497 FIXME("not implemented for image type %d\n", image->type);
498 return NotImplemented;
503 n_width = roundr(width);
504 n_height = roundr(height);
506 if(n_x + n_width > ((GpBitmap*)image)->width ||
507 n_y + n_height > ((GpBitmap*)image)->height)
508 return InvalidParameter;
510 IPicture_get_Handle(image->picture, &hbm);
511 if(!hbm) return GenericError;
512 IPicture_get_CurDC(image->picture, &hdc);
513 bm_is_selected = (hdc != 0);
515 pbmi = GdipAlloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
518 pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
519 pbmi->bmiHeader.biBitCount = 0;
522 hdc = CreateCompatibleDC(0);
523 old = SelectObject(hdc, (HBITMAP)hbm);
527 GetDIBits(hdc, (HBITMAP)hbm, 0, 0, NULL, pbmi, DIB_RGB_COLORS);
529 bytespp = pbmi->bmiHeader.biBitCount / 8;
530 abs_height = abs(pbmi->bmiHeader.biHeight);
532 if(n_x > pbmi->bmiHeader.biWidth || n_x + n_width > pbmi->bmiHeader.biWidth ||
533 n_y > abs_height || n_y + n_height > abs_height){
535 return InvalidParameter;
538 dibits = GdipAlloc(pbmi->bmiHeader.biSizeImage);
540 if(dibits) /* this is not a good place to error out */
541 GetDIBits(hdc, (HBITMAP)hbm, 0, abs_height, dibits, pbmi, DIB_RGB_COLORS);
544 SelectObject(hdc, old);
553 image_stride = (pbmi->bmiHeader.biWidth * bytespp + 3) & ~3;
554 stride = (n_width * bytespp + 3) & ~3;
555 buff = GdipAlloc(sizeof(BITMAPINFOHEADER) + stride * n_height);
562 bmih = (BITMAPINFOHEADER*)buff;
563 textbits = (BYTE*) (bmih + 1);
564 bmih->biSize = sizeof(BITMAPINFOHEADER);
565 bmih->biWidth = n_width;
566 bmih->biHeight = n_height;
567 bmih->biCompression = BI_RGB;
568 bmih->biSizeImage = stride * n_height;
569 bmih->biBitCount = pbmi->bmiHeader.biBitCount;
573 /* image is flipped */
574 if(pbmi->bmiHeader.biHeight > 0){
575 dibits += pbmi->bmiHeader.biSizeImage;
577 textbits += stride * (n_height - 1);
583 for(i = 0; i < n_height; i++)
584 memcpy(&textbits[i * stride],
585 &dibits[n_x * bytespp + (n_y + i) * image_stride],
588 *texture = GdipAlloc(sizeof(GpTexture));
595 if((status = GdipCreateMatrix(&(*texture)->transform)) != Ok){
602 (*texture)->brush.lb.lbStyle = BS_DIBPATTERNPT;
603 (*texture)->brush.lb.lbColor = DIB_RGB_COLORS;
604 (*texture)->brush.lb.lbHatch = (ULONG_PTR)buff;
606 (*texture)->brush.gdibrush = CreateBrushIndirect(&(*texture)->brush.lb);
607 (*texture)->brush.bt = BrushTypeTextureFill;
608 (*texture)->wrap = imageattr->wrap;
616 /******************************************************************************
617 * GdipCreateTextureIAI [GDIPLUS.@]
619 GpStatus WINGDIPAPI GdipCreateTextureIAI(GpImage *image, GDIPCONST GpImageAttributes *imageattr,
620 INT x, INT y, INT width, INT height, GpTexture **texture)
622 TRACE("(%p, %p, %d, %d, %d, %d, %p)\n", image, imageattr, x, y, width, height,
625 return GdipCreateTextureIA(image,imageattr,(REAL)x,(REAL)y,(REAL)width,(REAL)height,texture);
628 GpStatus WINGDIPAPI GdipCreateTexture2I(GpImage *image, GpWrapMode wrapmode,
629 INT x, INT y, INT width, INT height, GpTexture **texture)
631 GpImageAttributes imageattr;
633 TRACE("%p %d %d %d %d %d %p\n", image, wrapmode, x, y, width, height,
636 imageattr.wrap = wrapmode;
638 return GdipCreateTextureIA(image, &imageattr, x, y, width, height, texture);
641 GpStatus WINGDIPAPI GdipGetBrushType(GpBrush *brush, GpBrushType *type)
643 TRACE("(%p, %p)\n", brush, type);
645 if(!brush || !type) return InvalidParameter;
652 GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush *brush)
654 TRACE("(%p)\n", brush);
656 if(!brush) return InvalidParameter;
660 case BrushTypePathGradient:
661 GdipFree(((GpPathGradient*) brush)->pathdata.Points);
662 GdipFree(((GpPathGradient*) brush)->pathdata.Types);
663 GdipFree(((GpPathGradient*) brush)->blendfac);
664 GdipFree(((GpPathGradient*) brush)->blendpos);
666 case BrushTypeSolidColor:
667 case BrushTypeLinearGradient:
669 case BrushTypeTextureFill:
670 GdipDeleteMatrix(((GpTexture*)brush)->transform);
676 DeleteObject(brush->gdibrush);
682 GpStatus WINGDIPAPI GdipGetLineGammaCorrection(GpLineGradient *line,
685 TRACE("(%p, %p)\n", line, usinggamma);
687 if(!line || !usinggamma)
688 return InvalidParameter;
690 *usinggamma = line->gamma;
695 GpStatus WINGDIPAPI GdipGetLineWrapMode(GpLineGradient *brush, GpWrapMode *wrapmode)
697 TRACE("(%p, %p)\n", brush, wrapmode);
699 if(!brush || !wrapmode)
700 return InvalidParameter;
702 *wrapmode = brush->wrap;
707 GpStatus WINGDIPAPI GdipGetPathGradientBlend(GpPathGradient *brush, REAL *blend,
708 REAL *positions, INT count)
710 TRACE("(%p, %p, %p, %d)\n", brush, blend, positions, count);
712 if(!brush || !blend || !positions || count <= 0)
713 return InvalidParameter;
715 if(count < brush->blendcount)
716 return InsufficientBuffer;
718 memcpy(blend, brush->blendfac, count*sizeof(REAL));
719 if(brush->blendcount > 1){
720 memcpy(positions, brush->blendpos, count*sizeof(REAL));
726 GpStatus WINGDIPAPI GdipGetPathGradientBlendCount(GpPathGradient *brush, INT *count)
728 TRACE("(%p, %p)\n", brush, count);
731 return InvalidParameter;
733 *count = brush->blendcount;
738 GpStatus WINGDIPAPI GdipGetPathGradientCenterPoint(GpPathGradient *grad,
741 TRACE("(%p, %p)\n", grad, point);
744 return InvalidParameter;
746 point->X = grad->center.X;
747 point->Y = grad->center.Y;
752 GpStatus WINGDIPAPI GdipGetPathGradientCenterPointI(GpPathGradient *grad,
758 TRACE("(%p, %p)\n", grad, point);
761 return InvalidParameter;
763 ret = GdipGetPathGradientCenterPoint(grad,&ptf);
766 point->X = roundr(ptf.X);
767 point->Y = roundr(ptf.Y);
773 GpStatus WINGDIPAPI GdipGetPathGradientFocusScales(GpPathGradient *grad,
776 TRACE("(%p, %p, %p)\n", grad, x, y);
778 if(!grad || !x || !y)
779 return InvalidParameter;
787 GpStatus WINGDIPAPI GdipGetPathGradientGammaCorrection(GpPathGradient *grad,
790 TRACE("(%p, %p)\n", grad, gamma);
793 return InvalidParameter;
795 *gamma = grad->gamma;
800 GpStatus WINGDIPAPI GdipGetPathGradientPointCount(GpPathGradient *grad,
803 TRACE("(%p, %p)\n", grad, count);
806 return InvalidParameter;
808 *count = grad->pathdata.Count;
813 GpStatus WINGDIPAPI GdipGetPathGradientRect(GpPathGradient *brush, GpRectF *rect)
819 TRACE("(%p, %p)\n", brush, rect);
822 return InvalidParameter;
824 stat = GdipCreatePath2(brush->pathdata.Points, brush->pathdata.Types,
825 brush->pathdata.Count, FillModeAlternate, &path);
826 if(stat != Ok) return stat;
828 stat = GdipGetPathWorldBounds(path, &r, NULL, NULL);
830 GdipDeletePath(path);
834 memcpy(rect, &r, sizeof(GpRectF));
836 GdipDeletePath(path);
841 GpStatus WINGDIPAPI GdipGetPathGradientRectI(GpPathGradient *brush, GpRect *rect)
846 TRACE("(%p, %p)\n", brush, rect);
849 return InvalidParameter;
851 stat = GdipGetPathGradientRect(brush, &rectf);
852 if(stat != Ok) return stat;
854 rect->X = roundr(rectf.X);
855 rect->Y = roundr(rectf.Y);
856 rect->Width = roundr(rectf.Width);
857 rect->Height = roundr(rectf.Height);
862 GpStatus WINGDIPAPI GdipGetPathGradientSurroundColorsWithCount(GpPathGradient
863 *grad, ARGB *argb, INT *count)
867 if(!grad || !argb || !count || (*count < grad->pathdata.Count))
868 return InvalidParameter;
871 FIXME("not implemented\n");
873 return NotImplemented;
876 GpStatus WINGDIPAPI GdipGetPathGradientWrapMode(GpPathGradient *brush,
877 GpWrapMode *wrapmode)
879 TRACE("(%p, %p)\n", brush, wrapmode);
881 if(!brush || !wrapmode)
882 return InvalidParameter;
884 *wrapmode = brush->wrap;
889 GpStatus WINGDIPAPI GdipGetSolidFillColor(GpSolidFill *sf, ARGB *argb)
891 TRACE("(%p, %p)\n", sf, argb);
894 return InvalidParameter;
901 /******************************************************************************
902 * GdipGetTextureTransform [GDIPLUS.@]
904 GpStatus WINGDIPAPI GdipGetTextureTransform(GpTexture *brush, GpMatrix *matrix)
906 TRACE("(%p, %p)\n", brush, matrix);
908 if(!brush || !matrix)
909 return InvalidParameter;
911 memcpy(matrix, brush->transform, sizeof(GpMatrix));
916 /******************************************************************************
917 * GdipGetTextureWrapMode [GDIPLUS.@]
919 GpStatus WINGDIPAPI GdipGetTextureWrapMode(GpTexture *brush, GpWrapMode *wrapmode)
921 TRACE("(%p, %p)\n", brush, wrapmode);
923 if(!brush || !wrapmode)
924 return InvalidParameter;
926 *wrapmode = brush->wrap;
931 /******************************************************************************
932 * GdipResetTextureTransform [GDIPLUS.@]
934 GpStatus WINGDIPAPI GdipResetTextureTransform(GpTexture* brush)
936 TRACE("(%p)\n", brush);
939 return InvalidParameter;
941 return GdipSetMatrixElements(brush->transform, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
944 GpStatus WINGDIPAPI GdipSetLineBlend(GpLineGradient *brush,
945 GDIPCONST REAL *blend, GDIPCONST REAL* positions, INT count)
949 if(!brush || !blend || !positions || count <= 0)
950 return InvalidParameter;
953 FIXME("not implemented\n");
958 GpStatus WINGDIPAPI GdipSetLineGammaCorrection(GpLineGradient *line,
961 TRACE("(%p, %d)\n", line, usegamma);
964 return InvalidParameter;
966 line->gamma = usegamma;
971 GpStatus WINGDIPAPI GdipSetLineSigmaBlend(GpLineGradient *line, REAL focus,
976 if(!line || focus < 0.0 || focus > 1.0 || scale < 0.0 || scale > 1.0)
977 return InvalidParameter;
980 FIXME("not implemented\n");
982 return NotImplemented;
985 GpStatus WINGDIPAPI GdipSetLineWrapMode(GpLineGradient *line,
988 TRACE("(%p, %d)\n", line, wrap);
990 if(!line || wrap == WrapModeClamp)
991 return InvalidParameter;
998 GpStatus WINGDIPAPI GdipSetPathGradientBlend(GpPathGradient *brush, GDIPCONST REAL *blend,
999 GDIPCONST REAL *pos, INT count)
1004 FIXME("not implemented\n");
1006 return NotImplemented;
1009 GpStatus WINGDIPAPI GdipSetPathGradientCenterColor(GpPathGradient *grad,
1012 TRACE("(%p, %x)\n", grad, argb);
1015 return InvalidParameter;
1017 grad->centercolor = argb;
1018 grad->brush.lb.lbColor = ARGB2COLORREF(argb);
1020 DeleteObject(grad->brush.gdibrush);
1021 grad->brush.gdibrush = CreateSolidBrush(grad->brush.lb.lbColor);
1026 GpStatus WINGDIPAPI GdipSetPathGradientCenterPoint(GpPathGradient *grad,
1029 TRACE("(%p, %p)\n", grad, point);
1032 return InvalidParameter;
1034 grad->center.X = point->X;
1035 grad->center.Y = point->Y;
1040 GpStatus WINGDIPAPI GdipSetPathGradientCenterPointI(GpPathGradient *grad,
1045 TRACE("(%p, %p)\n", grad, point);
1048 return InvalidParameter;
1050 ptf.X = (REAL)point->X;
1051 ptf.Y = (REAL)point->Y;
1053 return GdipSetPathGradientCenterPoint(grad,&ptf);
1056 GpStatus WINGDIPAPI GdipSetPathGradientFocusScales(GpPathGradient *grad,
1059 TRACE("(%p, %.2f, %.2f)\n", grad, x, y);
1062 return InvalidParameter;
1070 GpStatus WINGDIPAPI GdipSetPathGradientGammaCorrection(GpPathGradient *grad,
1073 TRACE("(%p, %d)\n", grad, gamma);
1076 return InvalidParameter;
1078 grad->gamma = gamma;
1083 GpStatus WINGDIPAPI GdipSetPathGradientSigmaBlend(GpPathGradient *grad,
1084 REAL focus, REAL scale)
1088 if(!grad || focus < 0.0 || focus > 1.0 || scale < 0.0 || scale > 1.0)
1089 return InvalidParameter;
1092 FIXME("not implemented\n");
1094 return NotImplemented;
1097 GpStatus WINGDIPAPI GdipSetPathGradientSurroundColorsWithCount(GpPathGradient
1098 *grad, ARGB *argb, INT *count)
1102 if(!grad || !argb || !count || (*count <= 0) ||
1103 (*count > grad->pathdata.Count))
1104 return InvalidParameter;
1107 FIXME("not implemented\n");
1109 return NotImplemented;
1112 GpStatus WINGDIPAPI GdipSetPathGradientWrapMode(GpPathGradient *grad,
1115 TRACE("(%p, %d)\n", grad, wrap);
1118 return InvalidParameter;
1125 GpStatus WINGDIPAPI GdipSetSolidFillColor(GpSolidFill *sf, ARGB argb)
1127 TRACE("(%p, %x)\n", sf, argb);
1130 return InvalidParameter;
1133 sf->brush.lb.lbColor = ARGB2COLORREF(argb);
1135 DeleteObject(sf->brush.gdibrush);
1136 sf->brush.gdibrush = CreateSolidBrush(sf->brush.lb.lbColor);
1141 /******************************************************************************
1142 * GdipSetTextureTransform [GDIPLUS.@]
1144 GpStatus WINGDIPAPI GdipSetTextureTransform(GpTexture *texture,
1145 GDIPCONST GpMatrix *matrix)
1147 TRACE("(%p, %p)\n", texture, matrix);
1149 if(!texture || !matrix)
1150 return InvalidParameter;
1152 memcpy(texture->transform, matrix, sizeof(GpMatrix));
1157 /******************************************************************************
1158 * GdipSetTextureWrapMode [GDIPLUS.@]
1160 * WrapMode not used, only stored
1162 GpStatus WINGDIPAPI GdipSetTextureWrapMode(GpTexture *brush, GpWrapMode wrapmode)
1164 TRACE("(%p, %d)\n", brush, wrapmode);
1167 return InvalidParameter;
1169 brush->wrap = wrapmode;
1174 GpStatus WINGDIPAPI GdipSetLineColors(GpLineGradient *brush, ARGB color1,
1177 TRACE("(%p, %x, %x)\n", brush, color1, color2);
1180 return InvalidParameter;
1182 brush->startcolor = color1;
1183 brush->endcolor = color2;
1188 GpStatus WINGDIPAPI GdipGetLineColors(GpLineGradient *brush, ARGB *colors)
1190 TRACE("(%p, %p)\n", brush, colors);
1192 if(!brush || !colors)
1193 return InvalidParameter;
1195 colors[0] = brush->startcolor;
1196 colors[1] = brush->endcolor;
1201 GpStatus WINGDIPAPI GdipSetLineLinearBlend(GpLineGradient *brush, REAL focus,
1207 FIXME("not implemented\n");
1209 return NotImplemented;
1212 GpStatus WINGDIPAPI GdipSetLinePresetBlend(GpLineGradient *brush,
1213 GDIPCONST ARGB *blend, GDIPCONST REAL* positions, INT count)
1218 FIXME("not implemented\n");
1220 return NotImplemented;
1223 GpStatus WINGDIPAPI GdipSetLineTransform(GpLineGradient *brush,
1224 GDIPCONST GpMatrix *matrix)
1229 FIXME("not implemented\n");
1231 return NotImplemented;
1234 GpStatus WINGDIPAPI GdipTranslateLineTransform(GpLineGradient* brush,
1235 REAL dx, REAL dy, GpMatrixOrder order)
1237 FIXME("stub: %p %f %f %d\n", brush, dx, dy, order);
1239 return NotImplemented;
1242 GpStatus WINGDIPAPI GdipGetLineRect(GpLineGradient *brush, GpRectF *rect)
1244 TRACE("(%p, %p)\n", brush, rect);
1247 return InvalidParameter;
1249 rect->X = (brush->startpoint.X < brush->endpoint.X ? brush->startpoint.X: brush->endpoint.X);
1250 rect->Y = (brush->startpoint.Y < brush->endpoint.Y ? brush->startpoint.Y: brush->endpoint.Y);
1252 rect->Width = fabs(brush->startpoint.X - brush->endpoint.X);
1253 rect->Height = fabs(brush->startpoint.Y - brush->endpoint.Y);
1258 GpStatus WINGDIPAPI GdipGetLineRectI(GpLineGradient *brush, GpRect *rect)
1263 TRACE("(%p, %p)\n", brush, rect);
1266 return InvalidParameter;
1268 ret = GdipGetLineRect(brush, &rectF);
1271 rect->X = roundr(rectF.X);
1272 rect->Y = roundr(rectF.Y);
1273 rect->Width = roundr(rectF.Width);
1274 rect->Height = roundr(rectF.Height);