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:
50 *clone = GdipAlloc(sizeof(GpSolidFill));
51 if (!*clone) return OutOfMemory;
52 memcpy(*clone, brush, sizeof(GpSolidFill));
55 case BrushTypeHatchFill:
57 GpHatch *hatch = (GpHatch*)brush;
59 return GdipCreateHatchBrush(hatch->hatchstyle, hatch->forecol, hatch->backcol, (GpHatch**)clone);
61 case BrushTypePathGradient:{
62 GpPathGradient *src, *dest;
66 *clone = GdipAlloc(sizeof(GpPathGradient));
67 if (!*clone) return OutOfMemory;
69 src = (GpPathGradient*) brush,
70 dest = (GpPathGradient*) *clone;
72 memcpy(dest, src, sizeof(GpPathGradient));
74 stat = GdipClonePath(src->path, &dest->path);
81 stat = GdipCloneMatrix(src->transform, &dest->transform);
84 GdipDeletePath(dest->path);
90 count = src->blendcount;
91 dest->blendcount = count;
92 dest->blendfac = GdipAlloc(count * sizeof(REAL));
93 dest->blendpos = GdipAlloc(count * sizeof(REAL));
94 dest->surroundcolors = GdipAlloc(dest->surroundcolorcount * sizeof(ARGB));
95 pcount = dest->pblendcount;
98 dest->pblendcolor = GdipAlloc(pcount * sizeof(ARGB));
99 dest->pblendpos = GdipAlloc(pcount * sizeof(REAL));
102 if(!dest->blendfac || !dest->blendpos || !dest->surroundcolors ||
103 (pcount && (!dest->pblendcolor || !dest->pblendpos))){
104 GdipDeletePath(dest->path);
105 GdipDeleteMatrix(dest->transform);
106 GdipFree(dest->blendfac);
107 GdipFree(dest->blendpos);
108 GdipFree(dest->surroundcolors);
109 GdipFree(dest->pblendcolor);
110 GdipFree(dest->pblendpos);
115 memcpy(dest->blendfac, src->blendfac, count * sizeof(REAL));
116 memcpy(dest->blendpos, src->blendpos, count * sizeof(REAL));
117 memcpy(dest->surroundcolors, src->surroundcolors, dest->surroundcolorcount * sizeof(ARGB));
121 memcpy(dest->pblendcolor, src->pblendcolor, pcount * sizeof(ARGB));
122 memcpy(dest->pblendpos, src->pblendpos, pcount * sizeof(REAL));
127 case BrushTypeLinearGradient:{
128 GpLineGradient *dest, *src;
131 dest = GdipAlloc(sizeof(GpLineGradient));
132 if(!dest) return OutOfMemory;
134 src = (GpLineGradient*)brush;
136 memcpy(dest, src, sizeof(GpLineGradient));
138 count = dest->blendcount;
139 dest->blendfac = GdipAlloc(count * sizeof(REAL));
140 dest->blendpos = GdipAlloc(count * sizeof(REAL));
141 pcount = dest->pblendcount;
144 dest->pblendcolor = GdipAlloc(pcount * sizeof(ARGB));
145 dest->pblendpos = GdipAlloc(pcount * sizeof(REAL));
148 if (!dest->blendfac || !dest->blendpos ||
149 (pcount && (!dest->pblendcolor || !dest->pblendpos)))
151 GdipFree(dest->blendfac);
152 GdipFree(dest->blendpos);
153 GdipFree(dest->pblendcolor);
154 GdipFree(dest->pblendpos);
159 memcpy(dest->blendfac, src->blendfac, count * sizeof(REAL));
160 memcpy(dest->blendpos, src->blendpos, count * sizeof(REAL));
164 memcpy(dest->pblendcolor, src->pblendcolor, pcount * sizeof(ARGB));
165 memcpy(dest->pblendpos, src->pblendpos, pcount * sizeof(REAL));
168 *clone = &dest->brush;
171 case BrushTypeTextureFill:
174 GpTexture *texture = (GpTexture*)brush;
175 GpTexture *new_texture;
178 stat = GdipGetImageWidth(texture->image, &width);
179 if (stat != Ok) return stat;
180 stat = GdipGetImageHeight(texture->image, &height);
181 if (stat != Ok) return stat;
183 stat = GdipCreateTextureIA(texture->image, texture->imageattributes, 0, 0, width, height, &new_texture);
187 memcpy(new_texture->transform, texture->transform, sizeof(GpMatrix));
188 *clone = (GpBrush*)new_texture;
196 ERR("not implemented for brush type %d\n", brush->bt);
197 return NotImplemented;
200 TRACE("<-- %p\n", *clone);
204 static const char HatchBrushes[][8] = {
205 { 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00 }, /* HatchStyleHorizontal */
206 { 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08 }, /* HatchStyleVertical */
207 { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }, /* HatchStyleForwardDiagonal */
208 { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }, /* HatchStyleBackwardDiagonal */
209 { 0x08, 0x08, 0x08, 0xff, 0x08, 0x08, 0x08, 0x08 }, /* HatchStyleCross */
210 { 0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81 }, /* HatchStyleDiagonalCross */
211 { 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x80 }, /* HatchStyle05Percent */
212 { 0x00, 0x02, 0x00, 0x88, 0x00, 0x20, 0x00, 0x88 }, /* HatchStyle10Percent */
213 { 0x00, 0x22, 0x00, 0xcc, 0x00, 0x22, 0x00, 0xcc }, /* HatchStyle20Percent */
214 { 0x00, 0xcc, 0x00, 0xcc, 0x00, 0xcc, 0x00, 0xcc }, /* HatchStyle25Percent */
215 { 0x00, 0xcc, 0x04, 0xcc, 0x00, 0xcc, 0x40, 0xcc }, /* HatchStyle30Percent */
216 { 0x44, 0xcc, 0x22, 0xcc, 0x44, 0xcc, 0x22, 0xcc }, /* HatchStyle40Percent */
217 { 0x55, 0xcc, 0x55, 0xcc, 0x55, 0xcc, 0x55, 0xcc }, /* HatchStyle50Percent */
218 { 0x55, 0xcd, 0x55, 0xee, 0x55, 0xdc, 0x55, 0xee }, /* HatchStyle60Percent */
219 { 0x55, 0xdd, 0x55, 0xff, 0x55, 0xdd, 0x55, 0xff }, /* HatchStyle70Percent */
220 { 0x55, 0xff, 0x55, 0xff, 0x55, 0xff, 0x55, 0xff }, /* HatchStyle75Percent */
221 { 0x55, 0xff, 0x59, 0xff, 0x55, 0xff, 0x99, 0xff }, /* HatchStyle80Percent */
222 { 0x77, 0xff, 0xdd, 0xff, 0x77, 0xff, 0xfd, 0xff }, /* HatchStyle90Percent */
223 { 0x11, 0x22, 0x44, 0x88, 0x11, 0x22, 0x44, 0x88 }, /* HatchStyleLightDownwardDiagonal */
224 { 0x88, 0x44, 0x22, 0x11, 0x88, 0x44, 0x22, 0x11 }, /* HatchStyleLightUpwardDiagonal */
225 { 0x99, 0x33, 0x66, 0xcc, 0x99, 0x33, 0x66, 0xcc }, /* HatchStyleDarkDownwardDiagonal */
226 { 0xcc, 0x66, 0x33, 0x99, 0xcc, 0x66, 0x33, 0x99 }, /* HatchStyleDarkUpwardDiagonal */
227 { 0xc1, 0x83, 0x07, 0x0e, 0x1c, 0x38, 0x70, 0xe0 }, /* HatchStyleWideDownwardDiagonal */
228 { 0xe0, 0x70, 0x38, 0x1c, 0x0e, 0x07, 0x83, 0xc1 }, /* HatchStyleWideUpwardDiagonal */
229 { 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88 }, /* HatchStyleLightVertical */
230 { 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff }, /* HatchStyleLightHorizontal */
231 { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa }, /* HatchStyleNarrowVertical */
232 { 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff }, /* HatchStyleNarrowHorizontal */
233 { 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc }, /* HatchStyleDarkVertical */
234 { 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff }, /* HatchStyleDarkHorizontal */
237 GpStatus get_hatch_data(HatchStyle hatchstyle, const char **result)
239 if (hatchstyle < sizeof(HatchBrushes) / sizeof(HatchBrushes[0]))
241 *result = HatchBrushes[hatchstyle];
245 return NotImplemented;
248 /******************************************************************************
249 * GdipCreateHatchBrush [GDIPLUS.@]
251 GpStatus WINGDIPAPI GdipCreateHatchBrush(HatchStyle hatchstyle, ARGB forecol, ARGB backcol, GpHatch **brush)
253 TRACE("(%d, %d, %d, %p)\n", hatchstyle, forecol, backcol, brush);
255 if(!brush) return InvalidParameter;
257 *brush = GdipAlloc(sizeof(GpHatch));
258 if (!*brush) return OutOfMemory;
260 (*brush)->brush.bt = BrushTypeHatchFill;
261 (*brush)->forecol = forecol;
262 (*brush)->backcol = backcol;
263 (*brush)->hatchstyle = hatchstyle;
264 TRACE("<-- %p\n", *brush);
269 /******************************************************************************
270 * GdipCreateLineBrush [GDIPLUS.@]
272 GpStatus WINGDIPAPI GdipCreateLineBrush(GDIPCONST GpPointF* startpoint,
273 GDIPCONST GpPointF* endpoint, ARGB startcolor, ARGB endcolor,
274 GpWrapMode wrap, GpLineGradient **line)
276 TRACE("(%s, %s, %x, %x, %d, %p)\n", debugstr_pointf(startpoint),
277 debugstr_pointf(endpoint), startcolor, endcolor, wrap, line);
279 if(!line || !startpoint || !endpoint || wrap == WrapModeClamp)
280 return InvalidParameter;
282 if (startpoint->X == endpoint->X && startpoint->Y == endpoint->Y)
285 *line = GdipAlloc(sizeof(GpLineGradient));
286 if(!*line) return OutOfMemory;
288 (*line)->brush.bt = BrushTypeLinearGradient;
290 (*line)->startpoint.X = startpoint->X;
291 (*line)->startpoint.Y = startpoint->Y;
292 (*line)->endpoint.X = endpoint->X;
293 (*line)->endpoint.Y = endpoint->Y;
294 (*line)->startcolor = startcolor;
295 (*line)->endcolor = endcolor;
296 (*line)->wrap = wrap;
297 (*line)->gamma = FALSE;
299 (*line)->rect.X = (startpoint->X < endpoint->X ? startpoint->X: endpoint->X);
300 (*line)->rect.Y = (startpoint->Y < endpoint->Y ? startpoint->Y: endpoint->Y);
301 (*line)->rect.Width = fabs(startpoint->X - endpoint->X);
302 (*line)->rect.Height = fabs(startpoint->Y - endpoint->Y);
304 if ((*line)->rect.Width == 0)
306 (*line)->rect.X -= (*line)->rect.Height / 2.0f;
307 (*line)->rect.Width = (*line)->rect.Height;
309 else if ((*line)->rect.Height == 0)
311 (*line)->rect.Y -= (*line)->rect.Width / 2.0f;
312 (*line)->rect.Height = (*line)->rect.Width;
315 (*line)->blendcount = 1;
316 (*line)->blendfac = GdipAlloc(sizeof(REAL));
317 (*line)->blendpos = GdipAlloc(sizeof(REAL));
319 if (!(*line)->blendfac || !(*line)->blendpos)
321 GdipFree((*line)->blendfac);
322 GdipFree((*line)->blendpos);
328 (*line)->blendfac[0] = 1.0f;
329 (*line)->blendpos[0] = 1.0f;
331 (*line)->pblendcolor = NULL;
332 (*line)->pblendpos = NULL;
333 (*line)->pblendcount = 0;
335 TRACE("<-- %p\n", *line);
340 GpStatus WINGDIPAPI GdipCreateLineBrushI(GDIPCONST GpPoint* startpoint,
341 GDIPCONST GpPoint* endpoint, ARGB startcolor, ARGB endcolor,
342 GpWrapMode wrap, GpLineGradient **line)
347 TRACE("(%p, %p, %x, %x, %d, %p)\n", startpoint, endpoint,
348 startcolor, endcolor, wrap, line);
350 if(!startpoint || !endpoint)
351 return InvalidParameter;
353 stF.X = (REAL)startpoint->X;
354 stF.Y = (REAL)startpoint->Y;
355 endF.X = (REAL)endpoint->X;
356 endF.Y = (REAL)endpoint->Y;
358 return GdipCreateLineBrush(&stF, &endF, startcolor, endcolor, wrap, line);
361 GpStatus WINGDIPAPI GdipCreateLineBrushFromRect(GDIPCONST GpRectF* rect,
362 ARGB startcolor, ARGB endcolor, LinearGradientMode mode, GpWrapMode wrap,
363 GpLineGradient **line)
368 TRACE("(%p, %x, %x, %d, %d, %p)\n", rect, startcolor, endcolor, mode,
372 return InvalidParameter;
376 case LinearGradientModeHorizontal:
379 end.X = rect->X + rect->Width;
382 case LinearGradientModeVertical:
386 end.Y = rect->Y + rect->Height;
388 case LinearGradientModeForwardDiagonal:
391 end.X = rect->X + rect->Width;
392 end.Y = rect->Y + rect->Height;
394 case LinearGradientModeBackwardDiagonal:
395 start.X = rect->X + rect->Width;
398 end.Y = rect->Y + rect->Height;
401 return InvalidParameter;
404 stat = GdipCreateLineBrush(&start, &end, startcolor, endcolor, wrap, line);
407 (*line)->rect = *rect;
412 GpStatus WINGDIPAPI GdipCreateLineBrushFromRectI(GDIPCONST GpRect* rect,
413 ARGB startcolor, ARGB endcolor, LinearGradientMode mode, GpWrapMode wrap,
414 GpLineGradient **line)
418 TRACE("(%p, %x, %x, %d, %d, %p)\n", rect, startcolor, endcolor, mode,
421 rectF.X = (REAL) rect->X;
422 rectF.Y = (REAL) rect->Y;
423 rectF.Width = (REAL) rect->Width;
424 rectF.Height = (REAL) rect->Height;
426 return GdipCreateLineBrushFromRect(&rectF, startcolor, endcolor, mode, wrap, line);
429 /******************************************************************************
430 * GdipCreateLineBrushFromRectWithAngle [GDIPLUS.@]
432 GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngle(GDIPCONST GpRectF* rect,
433 ARGB startcolor, ARGB endcolor, REAL angle, BOOL isAngleScalable, GpWrapMode wrap,
434 GpLineGradient **line)
437 LinearGradientMode mode;
438 REAL width, height, exofs, eyofs;
439 REAL sin_angle, cos_angle, sin_cos_angle;
441 TRACE("(%p, %x, %x, %.2f, %d, %d, %p)\n", rect, startcolor, endcolor, angle, isAngleScalable,
444 sin_angle = sinf(deg2rad(angle));
445 cos_angle = cosf(deg2rad(angle));
446 sin_cos_angle = sin_angle * cos_angle;
450 width = height = 1.0;
455 height = rect->Height;
458 if (sin_cos_angle >= 0)
459 mode = LinearGradientModeForwardDiagonal;
461 mode = LinearGradientModeBackwardDiagonal;
463 stat = GdipCreateLineBrushFromRect(rect, startcolor, endcolor, mode, wrap, line);
467 if (sin_cos_angle >= 0)
469 exofs = width * sin_cos_angle + height * cos_angle * cos_angle;
470 eyofs = width * sin_angle * sin_angle + height * sin_cos_angle;
474 exofs = width * sin_angle * sin_angle + height * sin_cos_angle;
475 eyofs = -width * sin_cos_angle + height * sin_angle * sin_angle;
480 exofs = exofs * rect->Width;
481 eyofs = eyofs * rect->Height;
486 (*line)->endpoint.X = rect->X + exofs;
487 (*line)->endpoint.Y = rect->Y + eyofs;
491 (*line)->endpoint.X = (*line)->startpoint.X;
492 (*line)->endpoint.Y = (*line)->startpoint.Y;
493 (*line)->startpoint.X = rect->X + exofs;
494 (*line)->startpoint.Y = rect->Y + eyofs;
501 GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngleI(GDIPCONST GpRect* rect,
502 ARGB startcolor, ARGB endcolor, REAL angle, BOOL isAngleScalable, GpWrapMode wrap,
503 GpLineGradient **line)
505 TRACE("(%p, %x, %x, %.2f, %d, %d, %p)\n", rect, startcolor, endcolor, angle, isAngleScalable,
508 return GdipCreateLineBrushFromRectI(rect, startcolor, endcolor, LinearGradientModeForwardDiagonal,
512 static GpStatus create_path_gradient(GpPath *path, ARGB centercolor, GpPathGradient **grad)
518 return InvalidParameter;
520 if (path->pathdata.Count < 2)
523 GdipGetPathWorldBounds(path, &bounds, NULL, NULL);
525 *grad = GdipAlloc(sizeof(GpPathGradient));
531 stat = GdipCreateMatrix(&(*grad)->transform);
538 (*grad)->blendfac = GdipAlloc(sizeof(REAL));
539 (*grad)->blendpos = GdipAlloc(sizeof(REAL));
540 (*grad)->surroundcolors = GdipAlloc(sizeof(ARGB));
541 if(!(*grad)->blendfac || !(*grad)->blendpos || !(*grad)->surroundcolors){
542 GdipDeleteMatrix((*grad)->transform);
543 GdipFree((*grad)->blendfac);
544 GdipFree((*grad)->blendpos);
545 GdipFree((*grad)->surroundcolors);
550 (*grad)->blendfac[0] = 1.0;
551 (*grad)->blendpos[0] = 1.0;
552 (*grad)->blendcount = 1;
554 (*grad)->path = path;
556 (*grad)->brush.bt = BrushTypePathGradient;
557 (*grad)->centercolor = centercolor;
558 (*grad)->wrap = WrapModeClamp;
559 (*grad)->gamma = FALSE;
560 /* FIXME: this should be set to the "centroid" of the path by default */
561 (*grad)->center.X = bounds.X + bounds.Width / 2;
562 (*grad)->center.Y = bounds.Y + bounds.Height / 2;
563 (*grad)->focus.X = 0.0;
564 (*grad)->focus.Y = 0.0;
565 (*grad)->surroundcolors[0] = 0xffffffff;
566 (*grad)->surroundcolorcount = 1;
568 TRACE("<-- %p\n", *grad);
573 GpStatus WINGDIPAPI GdipCreatePathGradient(GDIPCONST GpPointF* points,
574 INT count, GpWrapMode wrap, GpPathGradient **grad)
579 TRACE("(%p, %d, %d, %p)\n", points, count, wrap, grad);
582 return InvalidParameter;
587 stat = GdipCreatePath(FillModeAlternate, &path);
591 stat = GdipAddPathLine2(path, points, count);
594 stat = create_path_gradient(path, 0xff000000, grad);
597 GdipDeletePath(path);
601 (*grad)->wrap = wrap;
606 GpStatus WINGDIPAPI GdipCreatePathGradientI(GDIPCONST GpPoint* points,
607 INT count, GpWrapMode wrap, GpPathGradient **grad)
612 TRACE("(%p, %d, %d, %p)\n", points, count, wrap, grad);
615 return InvalidParameter;
620 stat = GdipCreatePath(FillModeAlternate, &path);
624 stat = GdipAddPathLine2I(path, points, count);
627 stat = create_path_gradient(path, 0xff000000, grad);
630 GdipDeletePath(path);
634 (*grad)->wrap = wrap;
639 /******************************************************************************
640 * GdipCreatePathGradientFromPath [GDIPLUS.@]
642 GpStatus WINGDIPAPI GdipCreatePathGradientFromPath(GDIPCONST GpPath* path,
643 GpPathGradient **grad)
648 TRACE("(%p, %p)\n", path, grad);
651 return InvalidParameter;
653 stat = GdipClonePath((GpPath*)path, &new_path);
657 stat = create_path_gradient(new_path, 0xffffffff, grad);
660 GdipDeletePath(new_path);
666 /******************************************************************************
667 * GdipCreateSolidFill [GDIPLUS.@]
669 GpStatus WINGDIPAPI GdipCreateSolidFill(ARGB color, GpSolidFill **sf)
671 TRACE("(%x, %p)\n", color, sf);
673 if(!sf) return InvalidParameter;
675 *sf = GdipAlloc(sizeof(GpSolidFill));
676 if (!*sf) return OutOfMemory;
678 (*sf)->brush.bt = BrushTypeSolidColor;
679 (*sf)->color = color;
681 TRACE("<-- %p\n", *sf);
686 /******************************************************************************
687 * GdipCreateTexture [GDIPLUS.@]
690 * image [I] image to use
691 * wrapmode [I] optional
692 * texture [O] pointer to the resulting texturebrush
696 * FAILURE: element of GpStatus
698 GpStatus WINGDIPAPI GdipCreateTexture(GpImage *image, GpWrapMode wrapmode,
702 GpImageAttributes *attributes;
705 TRACE("%p, %d %p\n", image, wrapmode, texture);
707 if (!(image && texture))
708 return InvalidParameter;
710 stat = GdipGetImageWidth(image, &width);
711 if (stat != Ok) return stat;
712 stat = GdipGetImageHeight(image, &height);
713 if (stat != Ok) return stat;
715 stat = GdipCreateImageAttributes(&attributes);
719 attributes->wrap = wrapmode;
721 stat = GdipCreateTextureIA(image, attributes, 0, 0, width, height,
724 GdipDisposeImageAttributes(attributes);
730 /******************************************************************************
731 * GdipCreateTexture2 [GDIPLUS.@]
733 GpStatus WINGDIPAPI GdipCreateTexture2(GpImage *image, GpWrapMode wrapmode,
734 REAL x, REAL y, REAL width, REAL height, GpTexture **texture)
736 GpImageAttributes *attributes;
739 TRACE("%p %d %f %f %f %f %p\n", image, wrapmode,
740 x, y, width, height, texture);
742 stat = GdipCreateImageAttributes(&attributes);
746 attributes->wrap = wrapmode;
748 stat = GdipCreateTextureIA(image, attributes, x, y, width, height,
751 GdipDisposeImageAttributes(attributes);
757 /******************************************************************************
758 * GdipCreateTextureIA [GDIPLUS.@]
760 * FIXME: imageattr ignored
762 GpStatus WINGDIPAPI GdipCreateTextureIA(GpImage *image,
763 GDIPCONST GpImageAttributes *imageattr, REAL x, REAL y, REAL width,
764 REAL height, GpTexture **texture)
767 GpImage *new_image=NULL;
769 TRACE("(%p, %p, %.2f, %.2f, %.2f, %.2f, %p)\n", image, imageattr, x, y, width, height,
772 if(!image || !texture || x < 0.0 || y < 0.0 || width < 0.0 || height < 0.0)
773 return InvalidParameter;
777 if(image->type != ImageTypeBitmap){
778 FIXME("not implemented for image type %d\n", image->type);
779 return NotImplemented;
782 status = GdipCloneBitmapArea(x, y, width, height, PixelFormatDontCare, (GpBitmap*)image, (GpBitmap**)&new_image);
786 *texture = GdipAlloc(sizeof(GpTexture));
788 status = OutOfMemory;
792 if((status = GdipCreateMatrix(&(*texture)->transform)) != Ok){
798 status = GdipCloneImageAttributes(imageattr, &(*texture)->imageattributes);
802 status = GdipCreateImageAttributes(&(*texture)->imageattributes);
804 (*texture)->imageattributes->wrap = WrapModeTile;
808 (*texture)->brush.bt = BrushTypeTextureFill;
809 (*texture)->image = new_image;
815 TRACE("<-- %p\n", *texture);
821 GdipDeleteMatrix((*texture)->transform);
822 GdipDisposeImageAttributes((*texture)->imageattributes);
826 GdipDisposeImage(new_image);
827 TRACE("<-- error %u\n", status);
833 /******************************************************************************
834 * GdipCreateTextureIAI [GDIPLUS.@]
836 GpStatus WINGDIPAPI GdipCreateTextureIAI(GpImage *image, GDIPCONST GpImageAttributes *imageattr,
837 INT x, INT y, INT width, INT height, GpTexture **texture)
839 TRACE("(%p, %p, %d, %d, %d, %d, %p)\n", image, imageattr, x, y, width, height,
842 return GdipCreateTextureIA(image,imageattr,(REAL)x,(REAL)y,(REAL)width,(REAL)height,texture);
845 GpStatus WINGDIPAPI GdipCreateTexture2I(GpImage *image, GpWrapMode wrapmode,
846 INT x, INT y, INT width, INT height, GpTexture **texture)
848 GpImageAttributes *imageattr;
851 TRACE("%p %d %d %d %d %d %p\n", image, wrapmode, x, y, width, height,
854 stat = GdipCreateImageAttributes(&imageattr);
858 imageattr->wrap = wrapmode;
860 stat = GdipCreateTextureIA(image, imageattr, x, y, width, height, texture);
866 GpStatus WINGDIPAPI GdipGetBrushType(GpBrush *brush, GpBrushType *type)
868 TRACE("(%p, %p)\n", brush, type);
870 if(!brush || !type) return InvalidParameter;
877 GpStatus WINGDIPAPI GdipGetHatchBackgroundColor(GpHatch *brush, ARGB *backcol)
879 TRACE("(%p, %p)\n", brush, backcol);
881 if(!brush || !backcol) return InvalidParameter;
883 *backcol = brush->backcol;
888 GpStatus WINGDIPAPI GdipGetHatchForegroundColor(GpHatch *brush, ARGB *forecol)
890 TRACE("(%p, %p)\n", brush, forecol);
892 if(!brush || !forecol) return InvalidParameter;
894 *forecol = brush->forecol;
899 GpStatus WINGDIPAPI GdipGetHatchStyle(GpHatch *brush, HatchStyle *hatchstyle)
901 TRACE("(%p, %p)\n", brush, hatchstyle);
903 if(!brush || !hatchstyle) return InvalidParameter;
905 *hatchstyle = brush->hatchstyle;
910 GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush *brush)
912 TRACE("(%p)\n", brush);
914 if(!brush) return InvalidParameter;
918 case BrushTypePathGradient:
919 GdipDeletePath(((GpPathGradient*) brush)->path);
920 GdipDeleteMatrix(((GpPathGradient*) brush)->transform);
921 GdipFree(((GpPathGradient*) brush)->blendfac);
922 GdipFree(((GpPathGradient*) brush)->blendpos);
923 GdipFree(((GpPathGradient*) brush)->surroundcolors);
924 GdipFree(((GpPathGradient*) brush)->pblendcolor);
925 GdipFree(((GpPathGradient*) brush)->pblendpos);
927 case BrushTypeLinearGradient:
928 GdipFree(((GpLineGradient*)brush)->blendfac);
929 GdipFree(((GpLineGradient*)brush)->blendpos);
930 GdipFree(((GpLineGradient*)brush)->pblendcolor);
931 GdipFree(((GpLineGradient*)brush)->pblendpos);
933 case BrushTypeTextureFill:
934 GdipDeleteMatrix(((GpTexture*)brush)->transform);
935 GdipDisposeImage(((GpTexture*)brush)->image);
936 GdipDisposeImageAttributes(((GpTexture*)brush)->imageattributes);
937 GdipFree(((GpTexture*)brush)->bitmap_bits);
948 GpStatus WINGDIPAPI GdipGetLineGammaCorrection(GpLineGradient *line,
951 TRACE("(%p, %p)\n", line, usinggamma);
953 if(!line || !usinggamma)
954 return InvalidParameter;
956 *usinggamma = line->gamma;
961 GpStatus WINGDIPAPI GdipGetLineWrapMode(GpLineGradient *brush, GpWrapMode *wrapmode)
963 TRACE("(%p, %p)\n", brush, wrapmode);
965 if(!brush || !wrapmode)
966 return InvalidParameter;
968 *wrapmode = brush->wrap;
973 GpStatus WINGDIPAPI GdipGetPathGradientBlend(GpPathGradient *brush, REAL *blend,
974 REAL *positions, INT count)
976 TRACE("(%p, %p, %p, %d)\n", brush, blend, positions, count);
978 if(!brush || !blend || !positions || count <= 0)
979 return InvalidParameter;
981 if(count < brush->blendcount)
982 return InsufficientBuffer;
984 memcpy(blend, brush->blendfac, count*sizeof(REAL));
985 if(brush->blendcount > 1){
986 memcpy(positions, brush->blendpos, count*sizeof(REAL));
992 GpStatus WINGDIPAPI GdipGetPathGradientBlendCount(GpPathGradient *brush, INT *count)
994 TRACE("(%p, %p)\n", brush, count);
997 return InvalidParameter;
999 *count = brush->blendcount;
1004 GpStatus WINGDIPAPI GdipGetPathGradientCenterPoint(GpPathGradient *grad,
1007 TRACE("(%p, %p)\n", grad, point);
1010 return InvalidParameter;
1012 point->X = grad->center.X;
1013 point->Y = grad->center.Y;
1018 GpStatus WINGDIPAPI GdipGetPathGradientCenterPointI(GpPathGradient *grad,
1024 TRACE("(%p, %p)\n", grad, point);
1027 return InvalidParameter;
1029 ret = GdipGetPathGradientCenterPoint(grad,&ptf);
1032 point->X = roundr(ptf.X);
1033 point->Y = roundr(ptf.Y);
1039 GpStatus WINGDIPAPI GdipGetPathGradientCenterColor(GpPathGradient *grad,
1042 TRACE("(%p,%p)\n", grad, colors);
1044 if (!grad || !colors)
1045 return InvalidParameter;
1047 *colors = grad->centercolor;
1052 GpStatus WINGDIPAPI GdipGetPathGradientFocusScales(GpPathGradient *grad,
1055 TRACE("(%p, %p, %p)\n", grad, x, y);
1057 if(!grad || !x || !y)
1058 return InvalidParameter;
1066 GpStatus WINGDIPAPI GdipGetPathGradientGammaCorrection(GpPathGradient *grad,
1069 TRACE("(%p, %p)\n", grad, gamma);
1072 return InvalidParameter;
1074 *gamma = grad->gamma;
1079 GpStatus WINGDIPAPI GdipGetPathGradientPath(GpPathGradient *grad, GpPath *path)
1083 TRACE("(%p, %p)\n", grad, path);
1086 FIXME("not implemented\n");
1088 return NotImplemented;
1091 GpStatus WINGDIPAPI GdipGetPathGradientPointCount(GpPathGradient *grad,
1094 TRACE("(%p, %p)\n", grad, count);
1097 return InvalidParameter;
1099 *count = grad->path->pathdata.Count;
1104 GpStatus WINGDIPAPI GdipGetPathGradientRect(GpPathGradient *brush, GpRectF *rect)
1108 TRACE("(%p, %p)\n", brush, rect);
1111 return InvalidParameter;
1113 stat = GdipGetPathWorldBounds(brush->path, rect, NULL, NULL);
1118 GpStatus WINGDIPAPI GdipGetPathGradientRectI(GpPathGradient *brush, GpRect *rect)
1123 TRACE("(%p, %p)\n", brush, rect);
1126 return InvalidParameter;
1128 stat = GdipGetPathGradientRect(brush, &rectf);
1129 if(stat != Ok) return stat;
1131 rect->X = roundr(rectf.X);
1132 rect->Y = roundr(rectf.Y);
1133 rect->Width = roundr(rectf.Width);
1134 rect->Height = roundr(rectf.Height);
1139 GpStatus WINGDIPAPI GdipGetPathGradientSurroundColorsWithCount(GpPathGradient
1140 *grad, ARGB *argb, INT *count)
1144 TRACE("(%p,%p,%p)\n", grad, argb, count);
1146 if(!grad || !argb || !count || (*count < grad->path->pathdata.Count))
1147 return InvalidParameter;
1149 for (i=0; i<grad->path->pathdata.Count; i++)
1151 if (i < grad->surroundcolorcount)
1152 argb[i] = grad->surroundcolors[i];
1154 argb[i] = grad->surroundcolors[grad->surroundcolorcount-1];
1157 *count = grad->surroundcolorcount;
1162 GpStatus WINGDIPAPI GdipGetPathGradientSurroundColorCount(GpPathGradient *brush, INT *count)
1164 TRACE("(%p, %p)\n", brush, count);
1166 if (!brush || !count)
1167 return InvalidParameter;
1169 /* Yes, this actually returns the number of points in the path (which is the
1170 * required size of a buffer to get the surround colors), rather than the
1171 * number of surround colors. The real count is returned when getting the
1173 *count = brush->path->pathdata.Count;
1178 GpStatus WINGDIPAPI GdipGetPathGradientWrapMode(GpPathGradient *brush,
1179 GpWrapMode *wrapmode)
1181 TRACE("(%p, %p)\n", brush, wrapmode);
1183 if(!brush || !wrapmode)
1184 return InvalidParameter;
1186 *wrapmode = brush->wrap;
1191 GpStatus WINGDIPAPI GdipGetSolidFillColor(GpSolidFill *sf, ARGB *argb)
1193 TRACE("(%p, %p)\n", sf, argb);
1196 return InvalidParameter;
1203 /******************************************************************************
1204 * GdipGetTextureImage [GDIPLUS.@]
1206 GpStatus WINGDIPAPI GdipGetTextureImage(GpTexture *brush, GpImage **image)
1208 TRACE("(%p, %p)\n", brush, image);
1210 if(!brush || !image)
1211 return InvalidParameter;
1213 return GdipCloneImage(brush->image, image);
1216 /******************************************************************************
1217 * GdipGetTextureTransform [GDIPLUS.@]
1219 GpStatus WINGDIPAPI GdipGetTextureTransform(GpTexture *brush, GpMatrix *matrix)
1221 TRACE("(%p, %p)\n", brush, matrix);
1223 if(!brush || !matrix)
1224 return InvalidParameter;
1226 memcpy(matrix, brush->transform, sizeof(GpMatrix));
1231 /******************************************************************************
1232 * GdipGetTextureWrapMode [GDIPLUS.@]
1234 GpStatus WINGDIPAPI GdipGetTextureWrapMode(GpTexture *brush, GpWrapMode *wrapmode)
1236 TRACE("(%p, %p)\n", brush, wrapmode);
1238 if(!brush || !wrapmode)
1239 return InvalidParameter;
1241 *wrapmode = brush->imageattributes->wrap;
1246 /******************************************************************************
1247 * GdipMultiplyTextureTransform [GDIPLUS.@]
1249 GpStatus WINGDIPAPI GdipMultiplyTextureTransform(GpTexture* brush,
1250 GDIPCONST GpMatrix *matrix, GpMatrixOrder order)
1252 TRACE("(%p, %p, %d)\n", brush, matrix, order);
1254 if(!brush || !matrix)
1255 return InvalidParameter;
1257 return GdipMultiplyMatrix(brush->transform, matrix, order);
1260 /******************************************************************************
1261 * GdipResetTextureTransform [GDIPLUS.@]
1263 GpStatus WINGDIPAPI GdipResetTextureTransform(GpTexture* brush)
1265 TRACE("(%p)\n", brush);
1268 return InvalidParameter;
1270 return GdipSetMatrixElements(brush->transform, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
1273 /******************************************************************************
1274 * GdipScaleTextureTransform [GDIPLUS.@]
1276 GpStatus WINGDIPAPI GdipScaleTextureTransform(GpTexture* brush,
1277 REAL sx, REAL sy, GpMatrixOrder order)
1279 TRACE("(%p, %.2f, %.2f, %d)\n", brush, sx, sy, order);
1282 return InvalidParameter;
1284 return GdipScaleMatrix(brush->transform, sx, sy, order);
1287 GpStatus WINGDIPAPI GdipSetLineBlend(GpLineGradient *brush,
1288 GDIPCONST REAL *factors, GDIPCONST REAL* positions, INT count)
1290 REAL *new_blendfac, *new_blendpos;
1292 TRACE("(%p, %p, %p, %i)\n", brush, factors, positions, count);
1294 if(!brush || !factors || !positions || count <= 0 ||
1295 (count >= 2 && (positions[0] != 0.0f || positions[count-1] != 1.0f)))
1296 return InvalidParameter;
1298 new_blendfac = GdipAlloc(count * sizeof(REAL));
1299 new_blendpos = GdipAlloc(count * sizeof(REAL));
1301 if (!new_blendfac || !new_blendpos)
1303 GdipFree(new_blendfac);
1304 GdipFree(new_blendpos);
1308 memcpy(new_blendfac, factors, count * sizeof(REAL));
1309 memcpy(new_blendpos, positions, count * sizeof(REAL));
1311 GdipFree(brush->blendfac);
1312 GdipFree(brush->blendpos);
1314 brush->blendcount = count;
1315 brush->blendfac = new_blendfac;
1316 brush->blendpos = new_blendpos;
1321 GpStatus WINGDIPAPI GdipGetLineBlend(GpLineGradient *brush, REAL *factors,
1322 REAL *positions, INT count)
1324 TRACE("(%p, %p, %p, %i)\n", brush, factors, positions, count);
1326 if (!brush || !factors || !positions || count <= 0)
1327 return InvalidParameter;
1329 if (count < brush->blendcount)
1330 return InsufficientBuffer;
1332 memcpy(factors, brush->blendfac, brush->blendcount * sizeof(REAL));
1333 memcpy(positions, brush->blendpos, brush->blendcount * sizeof(REAL));
1338 GpStatus WINGDIPAPI GdipGetLineBlendCount(GpLineGradient *brush, INT *count)
1340 TRACE("(%p, %p)\n", brush, count);
1342 if (!brush || !count)
1343 return InvalidParameter;
1345 *count = brush->blendcount;
1350 GpStatus WINGDIPAPI GdipSetLineGammaCorrection(GpLineGradient *line,
1353 TRACE("(%p, %d)\n", line, usegamma);
1356 return InvalidParameter;
1358 line->gamma = usegamma;
1363 GpStatus WINGDIPAPI GdipSetLineSigmaBlend(GpLineGradient *line, REAL focus,
1370 const int precision = 16;
1371 REAL erf_range; /* we use values erf(-erf_range) through erf(+erf_range) */
1375 TRACE("(%p, %0.2f, %0.2f)\n", line, focus, scale);
1377 if(!line || focus < 0.0 || focus > 1.0 || scale < 0.0 || scale > 1.0)
1378 return InvalidParameter;
1380 /* we want 2 standard deviations */
1381 erf_range = 2.0 / sqrt(2);
1383 /* calculate the constants we need to normalize the error function to be
1384 between 0.0 and scale over the range we need */
1385 min_erf = erf(-erf_range);
1386 scale_erf = scale / (-2.0 * min_erf);
1392 for (i=1; i<precision; i++)
1394 positions[i] = focus * i / precision;
1395 factors[i] = scale_erf * (erf(2 * erf_range * i / precision - erf_range) - min_erf);
1397 num_points += precision;
1400 positions[num_points] = focus;
1401 factors[num_points] = scale;
1406 for (i=1; i<precision; i++)
1408 positions[i+num_points-1] = (focus + ((1.0-focus) * i / precision));
1409 factors[i+num_points-1] = scale_erf * (erf(erf_range - 2 * erf_range * i / precision) - min_erf);
1411 num_points += precision;
1412 positions[num_points-1] = 1.0;
1413 factors[num_points-1] = 0.0;
1416 return GdipSetLineBlend(line, factors, positions, num_points);
1419 GpStatus WINGDIPAPI GdipSetLineWrapMode(GpLineGradient *line,
1422 TRACE("(%p, %d)\n", line, wrap);
1424 if(!line || wrap == WrapModeClamp)
1425 return InvalidParameter;
1432 GpStatus WINGDIPAPI GdipSetPathGradientBlend(GpPathGradient *brush, GDIPCONST REAL *blend,
1433 GDIPCONST REAL *pos, INT count)
1437 TRACE("(%p,%p,%p,%i)\n", brush, blend, pos, count);
1440 FIXME("not implemented\n");
1442 return NotImplemented;
1445 GpStatus WINGDIPAPI GdipSetPathGradientLinearBlend(GpPathGradient *brush,
1446 REAL focus, REAL scale)
1450 TRACE("(%p,%0.2f,%0.2f)\n", brush, focus, scale);
1453 FIXME("not implemented\n");
1455 return NotImplemented;
1458 GpStatus WINGDIPAPI GdipSetPathGradientPresetBlend(GpPathGradient *brush,
1459 GDIPCONST ARGB *blend, GDIPCONST REAL *pos, INT count)
1463 TRACE("(%p,%p,%p,%i)\n", brush, blend, pos, count);
1465 if (!brush || !blend || !pos || count < 2 ||
1466 pos[0] != 0.0f || pos[count-1] != 1.0f)
1468 return InvalidParameter;
1471 new_color = GdipAlloc(count * sizeof(ARGB));
1472 new_pos = GdipAlloc(count * sizeof(REAL));
1473 if (!new_color || !new_pos)
1475 GdipFree(new_color);
1480 memcpy(new_color, blend, sizeof(ARGB) * count);
1481 memcpy(new_pos, pos, sizeof(REAL) * count);
1483 GdipFree(brush->pblendcolor);
1484 GdipFree(brush->pblendpos);
1486 brush->pblendcolor = new_color;
1487 brush->pblendpos = new_pos;
1488 brush->pblendcount = count;
1493 GpStatus WINGDIPAPI GdipGetPathGradientPresetBlend(GpPathGradient *brush,
1494 ARGB *blend, REAL *pos, INT count)
1496 TRACE("(%p,%p,%p,%i)\n", brush, blend, pos, count);
1501 if (!brush || !blend || !pos || count < 2)
1502 return InvalidParameter;
1504 if (brush->pblendcount == 0)
1505 return GenericError;
1507 if (count != brush->pblendcount)
1509 /* Native lines up the ends of each array, and copies the destination size. */
1510 FIXME("Braindead behavior on wrong-sized buffer not implemented.\n");
1511 return InvalidParameter;
1514 memcpy(blend, brush->pblendcolor, sizeof(ARGB) * brush->pblendcount);
1515 memcpy(pos, brush->pblendpos, sizeof(REAL) * brush->pblendcount);
1520 GpStatus WINGDIPAPI GdipGetPathGradientPresetBlendCount(GpPathGradient *brush,
1523 FIXME("(%p,%p): stub\n", brush, count);
1525 if (!brush || !count)
1526 return InvalidParameter;
1528 *count = brush->pblendcount;
1533 GpStatus WINGDIPAPI GdipSetPathGradientCenterColor(GpPathGradient *grad,
1536 TRACE("(%p, %x)\n", grad, argb);
1539 return InvalidParameter;
1541 grad->centercolor = argb;
1545 GpStatus WINGDIPAPI GdipSetPathGradientCenterPoint(GpPathGradient *grad,
1548 TRACE("(%p, %s)\n", grad, debugstr_pointf(point));
1551 return InvalidParameter;
1553 grad->center.X = point->X;
1554 grad->center.Y = point->Y;
1559 GpStatus WINGDIPAPI GdipSetPathGradientCenterPointI(GpPathGradient *grad,
1564 TRACE("(%p, %p)\n", grad, point);
1567 return InvalidParameter;
1569 ptf.X = (REAL)point->X;
1570 ptf.Y = (REAL)point->Y;
1572 return GdipSetPathGradientCenterPoint(grad,&ptf);
1575 GpStatus WINGDIPAPI GdipSetPathGradientFocusScales(GpPathGradient *grad,
1578 TRACE("(%p, %.2f, %.2f)\n", grad, x, y);
1581 return InvalidParameter;
1589 GpStatus WINGDIPAPI GdipSetPathGradientGammaCorrection(GpPathGradient *grad,
1592 TRACE("(%p, %d)\n", grad, gamma);
1595 return InvalidParameter;
1597 grad->gamma = gamma;
1602 GpStatus WINGDIPAPI GdipSetPathGradientSigmaBlend(GpPathGradient *grad,
1603 REAL focus, REAL scale)
1607 TRACE("(%p,%0.2f,%0.2f)\n", grad, focus, scale);
1609 if(!grad || focus < 0.0 || focus > 1.0 || scale < 0.0 || scale > 1.0)
1610 return InvalidParameter;
1613 FIXME("not implemented\n");
1615 return NotImplemented;
1618 GpStatus WINGDIPAPI GdipSetPathGradientSurroundColorsWithCount(GpPathGradient
1619 *grad, GDIPCONST ARGB *argb, INT *count)
1621 ARGB *new_surroundcolors;
1623 TRACE("(%p,%p,%p)\n", grad, argb, count);
1625 if(!grad || !argb || !count || (*count <= 0) ||
1626 (*count > grad->path->pathdata.Count))
1627 return InvalidParameter;
1629 new_surroundcolors = GdipAlloc(*count * sizeof(ARGB));
1630 if (!new_surroundcolors)
1633 memcpy(new_surroundcolors, argb, *count * sizeof(ARGB));
1635 GdipFree(grad->surroundcolors);
1637 grad->surroundcolors = new_surroundcolors;
1638 grad->surroundcolorcount = *count;
1643 GpStatus WINGDIPAPI GdipSetPathGradientWrapMode(GpPathGradient *grad,
1646 TRACE("(%p, %d)\n", grad, wrap);
1649 return InvalidParameter;
1656 GpStatus WINGDIPAPI GdipSetPathGradientTransform(GpPathGradient *grad,
1659 TRACE("(%p,%p)\n", grad, matrix);
1661 if (!grad || !matrix)
1662 return InvalidParameter;
1664 memcpy(grad->transform, matrix, sizeof(GpMatrix));
1669 GpStatus WINGDIPAPI GdipGetPathGradientTransform(GpPathGradient *grad,
1672 TRACE("(%p,%p)\n", grad, matrix);
1674 if (!grad || !matrix)
1675 return InvalidParameter;
1677 memcpy(matrix, grad->transform, sizeof(GpMatrix));
1682 GpStatus WINGDIPAPI GdipMultiplyPathGradientTransform(GpPathGradient *grad,
1683 GDIPCONST GpMatrix *matrix, GpMatrixOrder order)
1685 TRACE("(%p,%p,%i)\n", grad, matrix, order);
1688 return InvalidParameter;
1690 return GdipMultiplyMatrix(grad->transform, matrix, order);
1693 GpStatus WINGDIPAPI GdipResetPathGradientTransform(GpPathGradient *grad)
1695 TRACE("(%p)\n", grad);
1698 return InvalidParameter;
1700 return GdipSetMatrixElements(grad->transform, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
1703 GpStatus WINGDIPAPI GdipRotatePathGradientTransform(GpPathGradient *grad,
1704 REAL angle, GpMatrixOrder order)
1706 TRACE("(%p,%0.2f,%i)\n", grad, angle, order);
1709 return InvalidParameter;
1711 return GdipRotateMatrix(grad->transform, angle, order);
1714 GpStatus WINGDIPAPI GdipScalePathGradientTransform(GpPathGradient *grad,
1715 REAL sx, REAL sy, GpMatrixOrder order)
1717 TRACE("(%p,%0.2f,%0.2f,%i)\n", grad, sx, sy, order);
1720 return InvalidParameter;
1722 return GdipScaleMatrix(grad->transform, sx, sy, order);
1725 GpStatus WINGDIPAPI GdipTranslatePathGradientTransform(GpPathGradient *grad,
1726 REAL dx, REAL dy, GpMatrixOrder order)
1728 TRACE("(%p,%0.2f,%0.2f,%i)\n", grad, dx, dy, order);
1731 return InvalidParameter;
1733 return GdipTranslateMatrix(grad->transform, dx, dy, order);
1736 GpStatus WINGDIPAPI GdipSetSolidFillColor(GpSolidFill *sf, ARGB argb)
1738 TRACE("(%p, %x)\n", sf, argb);
1741 return InvalidParameter;
1747 /******************************************************************************
1748 * GdipSetTextureTransform [GDIPLUS.@]
1750 GpStatus WINGDIPAPI GdipSetTextureTransform(GpTexture *texture,
1751 GDIPCONST GpMatrix *matrix)
1753 TRACE("(%p, %p)\n", texture, matrix);
1755 if(!texture || !matrix)
1756 return InvalidParameter;
1758 memcpy(texture->transform, matrix, sizeof(GpMatrix));
1763 /******************************************************************************
1764 * GdipSetTextureWrapMode [GDIPLUS.@]
1766 * WrapMode not used, only stored
1768 GpStatus WINGDIPAPI GdipSetTextureWrapMode(GpTexture *brush, GpWrapMode wrapmode)
1770 TRACE("(%p, %d)\n", brush, wrapmode);
1773 return InvalidParameter;
1775 brush->imageattributes->wrap = wrapmode;
1780 GpStatus WINGDIPAPI GdipSetLineColors(GpLineGradient *brush, ARGB color1,
1783 TRACE("(%p, %x, %x)\n", brush, color1, color2);
1786 return InvalidParameter;
1788 brush->startcolor = color1;
1789 brush->endcolor = color2;
1794 GpStatus WINGDIPAPI GdipGetLineColors(GpLineGradient *brush, ARGB *colors)
1796 TRACE("(%p, %p)\n", brush, colors);
1798 if(!brush || !colors)
1799 return InvalidParameter;
1801 colors[0] = brush->startcolor;
1802 colors[1] = brush->endcolor;
1807 /******************************************************************************
1808 * GdipRotateTextureTransform [GDIPLUS.@]
1810 GpStatus WINGDIPAPI GdipRotateTextureTransform(GpTexture* brush, REAL angle,
1811 GpMatrixOrder order)
1813 TRACE("(%p, %.2f, %d)\n", brush, angle, order);
1816 return InvalidParameter;
1818 return GdipRotateMatrix(brush->transform, angle, order);
1821 GpStatus WINGDIPAPI GdipSetLineLinearBlend(GpLineGradient *brush, REAL focus,
1828 TRACE("(%p,%.2f,%.2f)\n", brush, focus, scale);
1830 if (!brush) return InvalidParameter;
1834 factors[num_points] = 0.0;
1835 positions[num_points] = 0.0;
1839 factors[num_points] = scale;
1840 positions[num_points] = focus;
1845 factors[num_points] = 0.0;
1846 positions[num_points] = 1.0;
1850 return GdipSetLineBlend(brush, factors, positions, num_points);
1853 GpStatus WINGDIPAPI GdipSetLinePresetBlend(GpLineGradient *brush,
1854 GDIPCONST ARGB *blend, GDIPCONST REAL* positions, INT count)
1858 TRACE("(%p,%p,%p,%i)\n", brush, blend, positions, count);
1860 if (!brush || !blend || !positions || count < 2 ||
1861 positions[0] != 0.0f || positions[count-1] != 1.0f)
1863 return InvalidParameter;
1866 new_color = GdipAlloc(count * sizeof(ARGB));
1867 new_pos = GdipAlloc(count * sizeof(REAL));
1868 if (!new_color || !new_pos)
1870 GdipFree(new_color);
1875 memcpy(new_color, blend, sizeof(ARGB) * count);
1876 memcpy(new_pos, positions, sizeof(REAL) * count);
1878 GdipFree(brush->pblendcolor);
1879 GdipFree(brush->pblendpos);
1881 brush->pblendcolor = new_color;
1882 brush->pblendpos = new_pos;
1883 brush->pblendcount = count;
1888 GpStatus WINGDIPAPI GdipGetLinePresetBlend(GpLineGradient *brush,
1889 ARGB *blend, REAL* positions, INT count)
1891 if (!brush || !blend || !positions || count < 2)
1892 return InvalidParameter;
1894 if (brush->pblendcount == 0)
1895 return GenericError;
1897 if (count < brush->pblendcount)
1898 return InsufficientBuffer;
1900 memcpy(blend, brush->pblendcolor, sizeof(ARGB) * brush->pblendcount);
1901 memcpy(positions, brush->pblendpos, sizeof(REAL) * brush->pblendcount);
1906 GpStatus WINGDIPAPI GdipGetLinePresetBlendCount(GpLineGradient *brush,
1909 if (!brush || !count)
1910 return InvalidParameter;
1912 *count = brush->pblendcount;
1917 GpStatus WINGDIPAPI GdipResetLineTransform(GpLineGradient *brush)
1921 TRACE("(%p)\n", brush);
1924 FIXME("not implemented\n");
1926 return NotImplemented;
1929 GpStatus WINGDIPAPI GdipSetLineTransform(GpLineGradient *brush,
1930 GDIPCONST GpMatrix *matrix)
1934 TRACE("(%p,%p)\n", brush, matrix);
1937 FIXME("not implemented\n");
1939 return NotImplemented;
1942 GpStatus WINGDIPAPI GdipGetLineTransform(GpLineGradient *brush, GpMatrix *matrix)
1946 TRACE("(%p,%p)\n", brush, matrix);
1949 FIXME("not implemented\n");
1951 return NotImplemented;
1954 GpStatus WINGDIPAPI GdipScaleLineTransform(GpLineGradient *brush, REAL sx, REAL sy,
1955 GpMatrixOrder order)
1959 TRACE("(%p,%0.2f,%0.2f,%u)\n", brush, sx, sy, order);
1962 FIXME("not implemented\n");
1964 return NotImplemented;
1967 GpStatus WINGDIPAPI GdipMultiplyLineTransform(GpLineGradient *brush,
1968 GDIPCONST GpMatrix *matrix, GpMatrixOrder order)
1972 TRACE("(%p,%p,%u)\n", brush, matrix, order);
1975 FIXME("not implemented\n");
1977 return NotImplemented;
1980 GpStatus WINGDIPAPI GdipTranslateLineTransform(GpLineGradient* brush,
1981 REAL dx, REAL dy, GpMatrixOrder order)
1985 TRACE("(%p,%f,%f,%d)\n", brush, dx, dy, order);
1988 FIXME("not implemented\n");
1993 /******************************************************************************
1994 * GdipTranslateTextureTransform [GDIPLUS.@]
1996 GpStatus WINGDIPAPI GdipTranslateTextureTransform(GpTexture* brush, REAL dx, REAL dy,
1997 GpMatrixOrder order)
1999 TRACE("(%p, %.2f, %.2f, %d)\n", brush, dx, dy, order);
2002 return InvalidParameter;
2004 return GdipTranslateMatrix(brush->transform, dx, dy, order);
2007 GpStatus WINGDIPAPI GdipGetLineRect(GpLineGradient *brush, GpRectF *rect)
2009 TRACE("(%p, %p)\n", brush, rect);
2012 return InvalidParameter;
2014 *rect = brush->rect;
2019 GpStatus WINGDIPAPI GdipGetLineRectI(GpLineGradient *brush, GpRect *rect)
2024 TRACE("(%p, %p)\n", brush, rect);
2027 return InvalidParameter;
2029 ret = GdipGetLineRect(brush, &rectF);
2032 rect->X = roundr(rectF.X);
2033 rect->Y = roundr(rectF.Y);
2034 rect->Width = roundr(rectF.Width);
2035 rect->Height = roundr(rectF.Height);
2041 GpStatus WINGDIPAPI GdipRotateLineTransform(GpLineGradient* brush,
2042 REAL angle, GpMatrixOrder order)
2046 TRACE("(%p,%0.2f,%u)\n", brush, angle, order);
2049 return InvalidParameter;
2052 FIXME("(%p, %.2f, %d) stub\n", brush, angle, order);
2054 return NotImplemented;