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:
51 *clone = GdipAlloc(sizeof(GpSolidFill));
52 if (!*clone) return OutOfMemory;
54 fill = (GpSolidFill*)*clone;
56 memcpy(*clone, brush, sizeof(GpSolidFill));
58 (*clone)->gdibrush = CreateBrushIndirect(&(*clone)->lb);
59 fill->bmp = ARGB2BMP(fill->color);
62 case BrushTypeHatchFill:
64 GpHatch *hatch = (GpHatch*)brush;
66 return GdipCreateHatchBrush(hatch->hatchstyle, hatch->forecol, hatch->backcol, (GpHatch**)clone);
68 case BrushTypePathGradient:{
69 GpPathGradient *src, *dest;
72 *clone = GdipAlloc(sizeof(GpPathGradient));
73 if (!*clone) return OutOfMemory;
75 src = (GpPathGradient*) brush,
76 dest = (GpPathGradient*) *clone;
77 count = src->pathdata.Count;
79 memcpy(dest, src, sizeof(GpPathGradient));
81 dest->pathdata.Count = count;
82 dest->pathdata.Points = GdipAlloc(count * sizeof(PointF));
83 dest->pathdata.Types = GdipAlloc(count);
85 if(!dest->pathdata.Points || !dest->pathdata.Types){
86 GdipFree(dest->pathdata.Points);
87 GdipFree(dest->pathdata.Types);
92 memcpy(dest->pathdata.Points, src->pathdata.Points, count * sizeof(PointF));
93 memcpy(dest->pathdata.Types, src->pathdata.Types, count);
96 count = src->blendcount;
97 dest->blendcount = count;
98 dest->blendfac = GdipAlloc(count * sizeof(REAL));
99 dest->blendpos = GdipAlloc(count * sizeof(REAL));
101 if(!dest->blendfac || !dest->blendpos){
102 GdipFree(dest->pathdata.Points);
103 GdipFree(dest->pathdata.Types);
104 GdipFree(dest->blendfac);
105 GdipFree(dest->blendpos);
110 memcpy(dest->blendfac, src->blendfac, count * sizeof(REAL));
111 memcpy(dest->blendpos, src->blendpos, count * sizeof(REAL));
115 case BrushTypeLinearGradient:{
116 GpLineGradient *dest, *src;
119 dest = GdipAlloc(sizeof(GpLineGradient));
120 if(!dest) return OutOfMemory;
122 src = (GpLineGradient*)brush;
124 memcpy(dest, src, sizeof(GpLineGradient));
126 dest->brush.gdibrush = CreateSolidBrush(dest->brush.lb.lbColor);
128 count = dest->blendcount;
129 dest->blendfac = GdipAlloc(count * sizeof(REAL));
130 dest->blendpos = GdipAlloc(count * sizeof(REAL));
131 pcount = dest->pblendcount;
134 dest->pblendcolor = GdipAlloc(pcount * sizeof(ARGB));
135 dest->pblendpos = GdipAlloc(pcount * sizeof(REAL));
138 if (!dest->blendfac || !dest->blendpos ||
139 (pcount && (!dest->pblendcolor || !dest->pblendpos)))
141 GdipFree(dest->blendfac);
142 GdipFree(dest->blendpos);
143 GdipFree(dest->pblendcolor);
144 GdipFree(dest->pblendpos);
145 DeleteObject(dest->brush.gdibrush);
150 memcpy(dest->blendfac, src->blendfac, count * sizeof(REAL));
151 memcpy(dest->blendpos, src->blendpos, count * sizeof(REAL));
155 memcpy(dest->pblendcolor, src->pblendcolor, pcount * sizeof(ARGB));
156 memcpy(dest->pblendpos, src->pblendpos, pcount * sizeof(REAL));
159 *clone = &dest->brush;
162 case BrushTypeTextureFill:
165 GpTexture *texture = (GpTexture*)brush;
166 GpTexture *new_texture;
168 stat = GdipCreateTexture(texture->image, texture->wrap, &new_texture);
172 memcpy(new_texture->transform, texture->transform, sizeof(GpMatrix));
173 *clone = (GpBrush*)new_texture;
181 ERR("not implemented for brush type %d\n", brush->bt);
182 return NotImplemented;
185 TRACE("<-- %p\n", *clone);
189 static const char HatchBrushes[][8] = {
190 { 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00 }, /* HatchStyleHorizontal */
191 { 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08 }, /* HatchStyleVertical */
192 { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }, /* HatchStyleForwardDiagonal */
193 { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }, /* HatchStyleBackwardDiagonal */
194 { 0x08, 0x08, 0x08, 0xff, 0x08, 0x08, 0x08, 0x08 }, /* HatchStyleCross */
195 { 0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81 }, /* HatchStyleDiagonalCross */
196 { 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x80 }, /* HatchStyle05Percent */
197 { 0x00, 0x02, 0x00, 0x88, 0x00, 0x20, 0x00, 0x88 }, /* HatchStyle10Percent */
198 { 0x00, 0x22, 0x00, 0xcc, 0x00, 0x22, 0x00, 0xcc }, /* HatchStyle20Percent */
199 { 0x00, 0xcc, 0x00, 0xcc, 0x00, 0xcc, 0x00, 0xcc }, /* HatchStyle25Percent */
200 { 0x00, 0xcc, 0x04, 0xcc, 0x00, 0xcc, 0x40, 0xcc }, /* HatchStyle30Percent */
201 { 0x44, 0xcc, 0x22, 0xcc, 0x44, 0xcc, 0x22, 0xcc }, /* HatchStyle40Percent */
202 { 0x55, 0xcc, 0x55, 0xcc, 0x55, 0xcc, 0x55, 0xcc }, /* HatchStyle50Percent */
203 { 0x55, 0xcd, 0x55, 0xee, 0x55, 0xdc, 0x55, 0xee }, /* HatchStyle60Percent */
204 { 0x55, 0xdd, 0x55, 0xff, 0x55, 0xdd, 0x55, 0xff }, /* HatchStyle70Percent */
205 { 0x55, 0xff, 0x55, 0xff, 0x55, 0xff, 0x55, 0xff }, /* HatchStyle75Percent */
206 { 0x55, 0xff, 0x59, 0xff, 0x55, 0xff, 0x99, 0xff }, /* HatchStyle80Percent */
207 { 0x77, 0xff, 0xdd, 0xff, 0x77, 0xff, 0xfd, 0xff }, /* HatchStyle90Percent */
208 { 0x11, 0x22, 0x44, 0x88, 0x11, 0x22, 0x44, 0x88 }, /* HatchStyleLightDownwardDiagonal */
209 { 0x88, 0x44, 0x22, 0x11, 0x88, 0x44, 0x22, 0x11 }, /* HatchStyleLightUpwardDiagonal */
210 { 0x99, 0x33, 0x66, 0xcc, 0x99, 0x33, 0x66, 0xcc }, /* HatchStyleDarkDownwardDiagonal */
211 { 0xcc, 0x66, 0x33, 0x99, 0xcc, 0x66, 0x33, 0x99 }, /* HatchStyleDarkUpwardDiagonal */
212 { 0xc1, 0x83, 0x07, 0x0e, 0x1c, 0x38, 0x70, 0xe0 }, /* HatchStyleWideDownwardDiagonal */
213 { 0xe0, 0x70, 0x38, 0x1c, 0x0e, 0x07, 0x83, 0xc1 }, /* HatchStyleWideUpwardDiagonal */
214 { 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88 }, /* HatchStyleLightVertical */
215 { 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff }, /* HatchStyleLightHorizontal */
216 { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa }, /* HatchStyleNarrowVertical */
217 { 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff }, /* HatchStyleNarrowHorizontal */
218 { 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc }, /* HatchStyleDarkVertical */
219 { 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff }, /* HatchStyleDarkHorizontal */
222 GpStatus get_hatch_data(HatchStyle hatchstyle, const char **result)
224 if (hatchstyle < sizeof(HatchBrushes) / sizeof(HatchBrushes[0]))
226 *result = HatchBrushes[hatchstyle];
230 return NotImplemented;
233 /******************************************************************************
234 * GdipCreateHatchBrush [GDIPLUS.@]
236 GpStatus WINGDIPAPI GdipCreateHatchBrush(HatchStyle hatchstyle, ARGB forecol, ARGB backcol, GpHatch **brush)
238 COLORREF fgcol = ARGB2COLORREF(forecol);
241 TRACE("(%d, %d, %d, %p)\n", hatchstyle, forecol, backcol, brush);
243 if(!brush) return InvalidParameter;
245 *brush = GdipAlloc(sizeof(GpHatch));
246 if (!*brush) return OutOfMemory;
248 if (hatchstyle < sizeof(HatchBrushes) / sizeof(HatchBrushes[0]))
252 BITMAPINFOHEADER bmih;
256 hdc = CreateCompatibleDC(0);
260 bmih.biSize = sizeof(bmih);
264 bmih.biBitCount = 32;
265 bmih.biCompression = BI_RGB;
266 bmih.biSizeImage = 0;
268 hbmp = CreateDIBSection(hdc, (BITMAPINFO*)&bmih, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
274 if ((HatchBrushes[hatchstyle][y] & (0x80 >> x)) != 0)
275 bits[y*8+x] = forecol;
277 bits[y*8+x] = backcol;
289 (*brush)->brush.lb.lbStyle = BS_PATTERN;
290 (*brush)->brush.lb.lbColor = 0;
291 (*brush)->brush.lb.lbHatch = (ULONG_PTR)hbmp;
292 (*brush)->brush.gdibrush = CreateBrushIndirect(&(*brush)->brush.lb);
299 FIXME("Unimplemented hatch style %d\n", hatchstyle);
301 (*brush)->brush.lb.lbStyle = BS_SOLID;
302 (*brush)->brush.lb.lbColor = fgcol;
303 (*brush)->brush.lb.lbHatch = 0;
304 (*brush)->brush.gdibrush = CreateBrushIndirect(&(*brush)->brush.lb);
309 (*brush)->brush.bt = BrushTypeHatchFill;
310 (*brush)->forecol = forecol;
311 (*brush)->backcol = backcol;
312 (*brush)->hatchstyle = hatchstyle;
313 TRACE("<-- %p\n", *brush);
324 /******************************************************************************
325 * GdipCreateLineBrush [GDIPLUS.@]
327 GpStatus WINGDIPAPI GdipCreateLineBrush(GDIPCONST GpPointF* startpoint,
328 GDIPCONST GpPointF* endpoint, ARGB startcolor, ARGB endcolor,
329 GpWrapMode wrap, GpLineGradient **line)
331 COLORREF col = ARGB2COLORREF(startcolor);
333 TRACE("(%s, %s, %x, %x, %d, %p)\n", debugstr_pointf(startpoint),
334 debugstr_pointf(endpoint), startcolor, endcolor, wrap, line);
336 if(!line || !startpoint || !endpoint || wrap == WrapModeClamp)
337 return InvalidParameter;
339 if (startpoint->X == endpoint->X && startpoint->Y == endpoint->Y)
342 *line = GdipAlloc(sizeof(GpLineGradient));
343 if(!*line) return OutOfMemory;
345 (*line)->brush.lb.lbStyle = BS_SOLID;
346 (*line)->brush.lb.lbColor = col;
347 (*line)->brush.lb.lbHatch = 0;
348 (*line)->brush.gdibrush = CreateSolidBrush(col);
349 (*line)->brush.bt = BrushTypeLinearGradient;
351 (*line)->startpoint.X = startpoint->X;
352 (*line)->startpoint.Y = startpoint->Y;
353 (*line)->endpoint.X = endpoint->X;
354 (*line)->endpoint.Y = endpoint->Y;
355 (*line)->startcolor = startcolor;
356 (*line)->endcolor = endcolor;
357 (*line)->wrap = wrap;
358 (*line)->gamma = FALSE;
360 (*line)->rect.X = (startpoint->X < endpoint->X ? startpoint->X: endpoint->X);
361 (*line)->rect.Y = (startpoint->Y < endpoint->Y ? startpoint->Y: endpoint->Y);
362 (*line)->rect.Width = fabs(startpoint->X - endpoint->X);
363 (*line)->rect.Height = fabs(startpoint->Y - endpoint->Y);
365 if ((*line)->rect.Width == 0)
367 (*line)->rect.X -= (*line)->rect.Height / 2.0f;
368 (*line)->rect.Width = (*line)->rect.Height;
370 else if ((*line)->rect.Height == 0)
372 (*line)->rect.Y -= (*line)->rect.Width / 2.0f;
373 (*line)->rect.Height = (*line)->rect.Width;
376 (*line)->blendcount = 1;
377 (*line)->blendfac = GdipAlloc(sizeof(REAL));
378 (*line)->blendpos = GdipAlloc(sizeof(REAL));
380 if (!(*line)->blendfac || !(*line)->blendpos)
382 GdipFree((*line)->blendfac);
383 GdipFree((*line)->blendpos);
384 DeleteObject((*line)->brush.gdibrush);
390 (*line)->blendfac[0] = 1.0f;
391 (*line)->blendpos[0] = 1.0f;
393 (*line)->pblendcolor = NULL;
394 (*line)->pblendpos = NULL;
395 (*line)->pblendcount = 0;
397 TRACE("<-- %p\n", *line);
402 GpStatus WINGDIPAPI GdipCreateLineBrushI(GDIPCONST GpPoint* startpoint,
403 GDIPCONST GpPoint* endpoint, ARGB startcolor, ARGB endcolor,
404 GpWrapMode wrap, GpLineGradient **line)
409 TRACE("(%p, %p, %x, %x, %d, %p)\n", startpoint, endpoint,
410 startcolor, endcolor, wrap, line);
412 if(!startpoint || !endpoint)
413 return InvalidParameter;
415 stF.X = (REAL)startpoint->X;
416 stF.Y = (REAL)startpoint->Y;
417 endF.X = (REAL)endpoint->X;
418 endF.Y = (REAL)endpoint->Y;
420 return GdipCreateLineBrush(&stF, &endF, startcolor, endcolor, wrap, line);
423 GpStatus WINGDIPAPI GdipCreateLineBrushFromRect(GDIPCONST GpRectF* rect,
424 ARGB startcolor, ARGB endcolor, LinearGradientMode mode, GpWrapMode wrap,
425 GpLineGradient **line)
430 TRACE("(%p, %x, %x, %d, %d, %p)\n", rect, startcolor, endcolor, mode,
434 return InvalidParameter;
438 case LinearGradientModeHorizontal:
441 end.X = rect->X + rect->Width;
444 case LinearGradientModeVertical:
448 end.Y = rect->Y + rect->Height;
450 case LinearGradientModeForwardDiagonal:
453 end.X = rect->X + rect->Width;
454 end.Y = rect->Y + rect->Height;
456 case LinearGradientModeBackwardDiagonal:
457 start.X = rect->X + rect->Width;
460 end.Y = rect->Y + rect->Height;
463 return InvalidParameter;
466 stat = GdipCreateLineBrush(&start, &end, startcolor, endcolor, wrap, line);
469 (*line)->rect = *rect;
474 GpStatus WINGDIPAPI GdipCreateLineBrushFromRectI(GDIPCONST GpRect* rect,
475 ARGB startcolor, ARGB endcolor, LinearGradientMode mode, GpWrapMode wrap,
476 GpLineGradient **line)
480 TRACE("(%p, %x, %x, %d, %d, %p)\n", rect, startcolor, endcolor, mode,
483 rectF.X = (REAL) rect->X;
484 rectF.Y = (REAL) rect->Y;
485 rectF.Width = (REAL) rect->Width;
486 rectF.Height = (REAL) rect->Height;
488 return GdipCreateLineBrushFromRect(&rectF, startcolor, endcolor, mode, wrap, line);
491 /******************************************************************************
492 * GdipCreateLineBrushFromRectWithAngle [GDIPLUS.@]
494 GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngle(GDIPCONST GpRectF* rect,
495 ARGB startcolor, ARGB endcolor, REAL angle, BOOL isAngleScalable, GpWrapMode wrap,
496 GpLineGradient **line)
499 LinearGradientMode mode;
500 REAL width, height, exofs, eyofs;
501 REAL sin_angle, cos_angle, sin_cos_angle;
503 TRACE("(%p, %x, %x, %.2f, %d, %d, %p)\n", rect, startcolor, endcolor, angle, isAngleScalable,
506 sin_angle = sinf(deg2rad(angle));
507 cos_angle = cosf(deg2rad(angle));
508 sin_cos_angle = sin_angle * cos_angle;
512 width = height = 1.0;
517 height = rect->Height;
520 if (sin_cos_angle >= 0)
521 mode = LinearGradientModeForwardDiagonal;
523 mode = LinearGradientModeBackwardDiagonal;
525 stat = GdipCreateLineBrushFromRect(rect, startcolor, endcolor, mode, wrap, line);
529 if (sin_cos_angle >= 0)
531 exofs = width * sin_cos_angle + height * cos_angle * cos_angle;
532 eyofs = width * sin_angle * sin_angle + height * sin_cos_angle;
536 exofs = width * sin_angle * sin_angle + height * sin_cos_angle;
537 eyofs = -width * sin_cos_angle + height * sin_angle * sin_angle;
542 exofs = exofs * rect->Width;
543 eyofs = eyofs * rect->Height;
548 (*line)->endpoint.X = rect->X + exofs;
549 (*line)->endpoint.Y = rect->Y + eyofs;
553 (*line)->endpoint.X = (*line)->startpoint.X;
554 (*line)->endpoint.Y = (*line)->startpoint.Y;
555 (*line)->startpoint.X = rect->X + exofs;
556 (*line)->startpoint.Y = rect->Y + eyofs;
563 GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngleI(GDIPCONST GpRect* rect,
564 ARGB startcolor, ARGB endcolor, REAL angle, BOOL isAngleScalable, GpWrapMode wrap,
565 GpLineGradient **line)
567 TRACE("(%p, %x, %x, %.2f, %d, %d, %p)\n", rect, startcolor, endcolor, angle, isAngleScalable,
570 return GdipCreateLineBrushFromRectI(rect, startcolor, endcolor, LinearGradientModeForwardDiagonal,
574 GpStatus WINGDIPAPI GdipCreatePathGradient(GDIPCONST GpPointF* points,
575 INT count, GpWrapMode wrap, GpPathGradient **grad)
577 COLORREF col = ARGB2COLORREF(0xffffffff);
579 TRACE("(%p, %d, %d, %p)\n", points, count, wrap, grad);
582 return InvalidParameter;
587 *grad = GdipAlloc(sizeof(GpPathGradient));
588 if (!*grad) return OutOfMemory;
590 (*grad)->blendfac = GdipAlloc(sizeof(REAL));
591 (*grad)->blendpos = GdipAlloc(sizeof(REAL));
592 if(!(*grad)->blendfac || !(*grad)->blendpos){
593 GdipFree((*grad)->blendfac);
594 GdipFree((*grad)->blendpos);
599 (*grad)->blendfac[0] = 1.0;
600 (*grad)->blendpos[0] = 1.0;
601 (*grad)->blendcount = 1;
603 (*grad)->pathdata.Count = count;
604 (*grad)->pathdata.Points = GdipAlloc(count * sizeof(PointF));
605 (*grad)->pathdata.Types = GdipAlloc(count);
607 if(!(*grad)->pathdata.Points || !(*grad)->pathdata.Types){
608 GdipFree((*grad)->pathdata.Points);
609 GdipFree((*grad)->pathdata.Types);
614 memcpy((*grad)->pathdata.Points, points, count * sizeof(PointF));
615 memset((*grad)->pathdata.Types, PathPointTypeLine, count);
617 (*grad)->brush.lb.lbStyle = BS_SOLID;
618 (*grad)->brush.lb.lbColor = col;
619 (*grad)->brush.lb.lbHatch = 0;
621 (*grad)->brush.gdibrush = CreateSolidBrush(col);
622 (*grad)->brush.bt = BrushTypePathGradient;
623 (*grad)->centercolor = 0xffffffff;
624 (*grad)->wrap = wrap;
625 (*grad)->gamma = FALSE;
626 (*grad)->center.X = 0.0;
627 (*grad)->center.Y = 0.0;
628 (*grad)->focus.X = 0.0;
629 (*grad)->focus.Y = 0.0;
631 TRACE("<-- %p\n", *grad);
636 GpStatus WINGDIPAPI GdipCreatePathGradientI(GDIPCONST GpPoint* points,
637 INT count, GpWrapMode wrap, GpPathGradient **grad)
643 TRACE("(%p, %d, %d, %p)\n", points, count, wrap, grad);
646 return InvalidParameter;
651 pointsF = GdipAlloc(sizeof(GpPointF) * count);
655 for(i = 0; i < count; i++){
656 pointsF[i].X = (REAL)points[i].X;
657 pointsF[i].Y = (REAL)points[i].Y;
660 ret = GdipCreatePathGradient(pointsF, count, wrap, grad);
666 /******************************************************************************
667 * GdipCreatePathGradientFromPath [GDIPLUS.@]
669 * FIXME: path gradient brushes not truly supported (drawn as solid brushes)
671 GpStatus WINGDIPAPI GdipCreatePathGradientFromPath(GDIPCONST GpPath* path,
672 GpPathGradient **grad)
674 COLORREF col = ARGB2COLORREF(0xffffffff);
676 TRACE("(%p, %p)\n", path, grad);
679 return InvalidParameter;
681 *grad = GdipAlloc(sizeof(GpPathGradient));
682 if (!*grad) return OutOfMemory;
684 (*grad)->blendfac = GdipAlloc(sizeof(REAL));
685 (*grad)->blendpos = GdipAlloc(sizeof(REAL));
686 if(!(*grad)->blendfac || !(*grad)->blendpos){
687 GdipFree((*grad)->blendfac);
688 GdipFree((*grad)->blendpos);
693 (*grad)->blendfac[0] = 1.0;
694 (*grad)->blendpos[0] = 1.0;
695 (*grad)->blendcount = 1;
697 (*grad)->pathdata.Count = path->pathdata.Count;
698 (*grad)->pathdata.Points = GdipAlloc(path->pathdata.Count * sizeof(PointF));
699 (*grad)->pathdata.Types = GdipAlloc(path->pathdata.Count);
701 if(!(*grad)->pathdata.Points || !(*grad)->pathdata.Types){
702 GdipFree((*grad)->pathdata.Points);
703 GdipFree((*grad)->pathdata.Types);
708 memcpy((*grad)->pathdata.Points, path->pathdata.Points,
709 path->pathdata.Count * sizeof(PointF));
710 memcpy((*grad)->pathdata.Types, path->pathdata.Types, path->pathdata.Count);
712 (*grad)->brush.lb.lbStyle = BS_SOLID;
713 (*grad)->brush.lb.lbColor = col;
714 (*grad)->brush.lb.lbHatch = 0;
716 (*grad)->brush.gdibrush = CreateSolidBrush(col);
717 (*grad)->brush.bt = BrushTypePathGradient;
718 (*grad)->centercolor = 0xffffffff;
719 (*grad)->wrap = WrapModeClamp;
720 (*grad)->gamma = FALSE;
721 /* FIXME: this should be set to the "centroid" of the path by default */
722 (*grad)->center.X = 0.0;
723 (*grad)->center.Y = 0.0;
724 (*grad)->focus.X = 0.0;
725 (*grad)->focus.Y = 0.0;
727 TRACE("<-- %p\n", *grad);
732 /******************************************************************************
733 * GdipCreateSolidFill [GDIPLUS.@]
735 GpStatus WINGDIPAPI GdipCreateSolidFill(ARGB color, GpSolidFill **sf)
737 COLORREF col = ARGB2COLORREF(color);
739 TRACE("(%x, %p)\n", color, sf);
741 if(!sf) return InvalidParameter;
743 *sf = GdipAlloc(sizeof(GpSolidFill));
744 if (!*sf) return OutOfMemory;
746 (*sf)->brush.lb.lbStyle = BS_SOLID;
747 (*sf)->brush.lb.lbColor = col;
748 (*sf)->brush.lb.lbHatch = 0;
750 (*sf)->brush.gdibrush = CreateSolidBrush(col);
751 (*sf)->brush.bt = BrushTypeSolidColor;
752 (*sf)->color = color;
753 (*sf)->bmp = ARGB2BMP(color);
755 TRACE("<-- %p\n", *sf);
760 /******************************************************************************
761 * GdipCreateTexture [GDIPLUS.@]
764 * image [I] image to use
765 * wrapmode [I] optional
766 * texture [O] pointer to the resulting texturebrush
770 * FAILURE: element of GpStatus
772 GpStatus WINGDIPAPI GdipCreateTexture(GpImage *image, GpWrapMode wrapmode,
776 GpImageAttributes attributes;
779 TRACE("%p, %d %p\n", image, wrapmode, texture);
781 if (!(image && texture))
782 return InvalidParameter;
784 stat = GdipGetImageWidth(image, &width);
785 if (stat != Ok) return stat;
786 stat = GdipGetImageHeight(image, &height);
787 if (stat != Ok) return stat;
788 attributes.wrap = wrapmode;
790 return GdipCreateTextureIA(image, &attributes, 0, 0, width, height,
794 /******************************************************************************
795 * GdipCreateTexture2 [GDIPLUS.@]
797 GpStatus WINGDIPAPI GdipCreateTexture2(GpImage *image, GpWrapMode wrapmode,
798 REAL x, REAL y, REAL width, REAL height, GpTexture **texture)
800 GpImageAttributes attributes;
802 TRACE("%p %d %f %f %f %f %p\n", image, wrapmode,
803 x, y, width, height, texture);
805 attributes.wrap = wrapmode;
806 return GdipCreateTextureIA(image, &attributes, x, y, width, height,
810 /******************************************************************************
811 * GdipCreateTextureIA [GDIPLUS.@]
813 * FIXME: imageattr ignored
815 GpStatus WINGDIPAPI GdipCreateTextureIA(GpImage *image,
816 GDIPCONST GpImageAttributes *imageattr, REAL x, REAL y, REAL width,
817 REAL height, GpTexture **texture)
821 GpImage *new_image=NULL;
823 TRACE("(%p, %p, %.2f, %.2f, %.2f, %.2f, %p)\n", image, imageattr, x, y, width, height,
826 if(!image || !texture || x < 0.0 || y < 0.0 || width < 0.0 || height < 0.0)
827 return InvalidParameter;
831 if(image->type != ImageTypeBitmap){
832 FIXME("not implemented for image type %d\n", image->type);
833 return NotImplemented;
836 status = GdipCloneBitmapArea(x, y, width, height, PixelFormatDontCare, (GpBitmap*)image, (GpBitmap**)&new_image);
840 status = GdipCreateHBITMAPFromBitmap((GpBitmap*)new_image, &hbm, 0);
843 status = GenericError;
847 *texture = GdipAlloc(sizeof(GpTexture));
849 status = OutOfMemory;
853 if((status = GdipCreateMatrix(&(*texture)->transform)) != Ok){
857 (*texture)->brush.lb.lbStyle = BS_PATTERN;
858 (*texture)->brush.lb.lbColor = 0;
859 (*texture)->brush.lb.lbHatch = (ULONG_PTR)hbm;
861 (*texture)->brush.gdibrush = CreateBrushIndirect(&(*texture)->brush.lb);
862 (*texture)->brush.bt = BrushTypeTextureFill;
864 (*texture)->wrap = imageattr->wrap;
866 (*texture)->wrap = WrapModeTile;
867 (*texture)->image = new_image;
872 TRACE("<-- %p\n", *texture);
878 GdipDeleteMatrix((*texture)->transform);
882 GdipDisposeImage(new_image);
883 TRACE("<-- error %u\n", status);
891 /******************************************************************************
892 * GdipCreateTextureIAI [GDIPLUS.@]
894 GpStatus WINGDIPAPI GdipCreateTextureIAI(GpImage *image, GDIPCONST GpImageAttributes *imageattr,
895 INT x, INT y, INT width, INT height, GpTexture **texture)
897 TRACE("(%p, %p, %d, %d, %d, %d, %p)\n", image, imageattr, x, y, width, height,
900 return GdipCreateTextureIA(image,imageattr,(REAL)x,(REAL)y,(REAL)width,(REAL)height,texture);
903 GpStatus WINGDIPAPI GdipCreateTexture2I(GpImage *image, GpWrapMode wrapmode,
904 INT x, INT y, INT width, INT height, GpTexture **texture)
906 GpImageAttributes imageattr;
908 TRACE("%p %d %d %d %d %d %p\n", image, wrapmode, x, y, width, height,
911 imageattr.wrap = wrapmode;
913 return GdipCreateTextureIA(image, &imageattr, x, y, width, height, texture);
916 GpStatus WINGDIPAPI GdipGetBrushType(GpBrush *brush, GpBrushType *type)
918 TRACE("(%p, %p)\n", brush, type);
920 if(!brush || !type) return InvalidParameter;
927 GpStatus WINGDIPAPI GdipGetHatchBackgroundColor(GpHatch *brush, ARGB *backcol)
929 TRACE("(%p, %p)\n", brush, backcol);
931 if(!brush || !backcol) return InvalidParameter;
933 *backcol = brush->backcol;
938 GpStatus WINGDIPAPI GdipGetHatchForegroundColor(GpHatch *brush, ARGB *forecol)
940 TRACE("(%p, %p)\n", brush, forecol);
942 if(!brush || !forecol) return InvalidParameter;
944 *forecol = brush->forecol;
949 GpStatus WINGDIPAPI GdipGetHatchStyle(GpHatch *brush, HatchStyle *hatchstyle)
951 TRACE("(%p, %p)\n", brush, hatchstyle);
953 if(!brush || !hatchstyle) return InvalidParameter;
955 *hatchstyle = brush->hatchstyle;
960 GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush *brush)
962 TRACE("(%p)\n", brush);
964 if(!brush) return InvalidParameter;
968 case BrushTypePathGradient:
969 GdipFree(((GpPathGradient*) brush)->pathdata.Points);
970 GdipFree(((GpPathGradient*) brush)->pathdata.Types);
971 GdipFree(((GpPathGradient*) brush)->blendfac);
972 GdipFree(((GpPathGradient*) brush)->blendpos);
974 case BrushTypeSolidColor:
975 if (((GpSolidFill*)brush)->bmp)
976 DeleteObject(((GpSolidFill*)brush)->bmp);
978 case BrushTypeLinearGradient:
979 GdipFree(((GpLineGradient*)brush)->blendfac);
980 GdipFree(((GpLineGradient*)brush)->blendpos);
981 GdipFree(((GpLineGradient*)brush)->pblendcolor);
982 GdipFree(((GpLineGradient*)brush)->pblendpos);
984 case BrushTypeTextureFill:
985 GdipDeleteMatrix(((GpTexture*)brush)->transform);
986 GdipDisposeImage(((GpTexture*)brush)->image);
992 DeleteObject(brush->gdibrush);
998 GpStatus WINGDIPAPI GdipGetLineGammaCorrection(GpLineGradient *line,
1001 TRACE("(%p, %p)\n", line, usinggamma);
1003 if(!line || !usinggamma)
1004 return InvalidParameter;
1006 *usinggamma = line->gamma;
1011 GpStatus WINGDIPAPI GdipGetLineWrapMode(GpLineGradient *brush, GpWrapMode *wrapmode)
1013 TRACE("(%p, %p)\n", brush, wrapmode);
1015 if(!brush || !wrapmode)
1016 return InvalidParameter;
1018 *wrapmode = brush->wrap;
1023 GpStatus WINGDIPAPI GdipGetPathGradientBlend(GpPathGradient *brush, REAL *blend,
1024 REAL *positions, INT count)
1026 TRACE("(%p, %p, %p, %d)\n", brush, blend, positions, count);
1028 if(!brush || !blend || !positions || count <= 0)
1029 return InvalidParameter;
1031 if(count < brush->blendcount)
1032 return InsufficientBuffer;
1034 memcpy(blend, brush->blendfac, count*sizeof(REAL));
1035 if(brush->blendcount > 1){
1036 memcpy(positions, brush->blendpos, count*sizeof(REAL));
1042 GpStatus WINGDIPAPI GdipGetPathGradientBlendCount(GpPathGradient *brush, INT *count)
1044 TRACE("(%p, %p)\n", brush, count);
1046 if(!brush || !count)
1047 return InvalidParameter;
1049 *count = brush->blendcount;
1054 GpStatus WINGDIPAPI GdipGetPathGradientCenterPoint(GpPathGradient *grad,
1057 TRACE("(%p, %p)\n", grad, point);
1060 return InvalidParameter;
1062 point->X = grad->center.X;
1063 point->Y = grad->center.Y;
1068 GpStatus WINGDIPAPI GdipGetPathGradientCenterPointI(GpPathGradient *grad,
1074 TRACE("(%p, %p)\n", grad, point);
1077 return InvalidParameter;
1079 ret = GdipGetPathGradientCenterPoint(grad,&ptf);
1082 point->X = roundr(ptf.X);
1083 point->Y = roundr(ptf.Y);
1089 GpStatus WINGDIPAPI GdipGetPathGradientCenterColor(GpPathGradient *grad,
1094 TRACE("(%p,%p)\n", grad, colors);
1097 FIXME("not implemented\n");
1099 return NotImplemented;
1102 GpStatus WINGDIPAPI GdipGetPathGradientFocusScales(GpPathGradient *grad,
1105 TRACE("(%p, %p, %p)\n", grad, x, y);
1107 if(!grad || !x || !y)
1108 return InvalidParameter;
1116 GpStatus WINGDIPAPI GdipGetPathGradientGammaCorrection(GpPathGradient *grad,
1119 TRACE("(%p, %p)\n", grad, gamma);
1122 return InvalidParameter;
1124 *gamma = grad->gamma;
1129 GpStatus WINGDIPAPI GdipGetPathGradientPointCount(GpPathGradient *grad,
1132 TRACE("(%p, %p)\n", grad, count);
1135 return InvalidParameter;
1137 *count = grad->pathdata.Count;
1142 GpStatus WINGDIPAPI GdipGetPathGradientRect(GpPathGradient *brush, GpRectF *rect)
1148 TRACE("(%p, %p)\n", brush, rect);
1151 return InvalidParameter;
1153 stat = GdipCreatePath2(brush->pathdata.Points, brush->pathdata.Types,
1154 brush->pathdata.Count, FillModeAlternate, &path);
1155 if(stat != Ok) return stat;
1157 stat = GdipGetPathWorldBounds(path, &r, NULL, NULL);
1159 GdipDeletePath(path);
1163 memcpy(rect, &r, sizeof(GpRectF));
1165 GdipDeletePath(path);
1170 GpStatus WINGDIPAPI GdipGetPathGradientRectI(GpPathGradient *brush, GpRect *rect)
1175 TRACE("(%p, %p)\n", brush, rect);
1178 return InvalidParameter;
1180 stat = GdipGetPathGradientRect(brush, &rectf);
1181 if(stat != Ok) return stat;
1183 rect->X = roundr(rectf.X);
1184 rect->Y = roundr(rectf.Y);
1185 rect->Width = roundr(rectf.Width);
1186 rect->Height = roundr(rectf.Height);
1191 GpStatus WINGDIPAPI GdipGetPathGradientSurroundColorsWithCount(GpPathGradient
1192 *grad, ARGB *argb, INT *count)
1196 TRACE("(%p,%p,%p)\n", grad, argb, count);
1198 if(!grad || !argb || !count || (*count < grad->pathdata.Count))
1199 return InvalidParameter;
1202 FIXME("not implemented\n");
1204 return NotImplemented;
1207 GpStatus WINGDIPAPI GdipGetPathGradientSurroundColorCount(GpPathGradient *brush, INT *count)
1209 TRACE("(%p, %p)\n", brush, count);
1211 if (!brush || !count)
1212 return InvalidParameter;
1214 return NotImplemented;
1217 GpStatus WINGDIPAPI GdipGetPathGradientWrapMode(GpPathGradient *brush,
1218 GpWrapMode *wrapmode)
1220 TRACE("(%p, %p)\n", brush, wrapmode);
1222 if(!brush || !wrapmode)
1223 return InvalidParameter;
1225 *wrapmode = brush->wrap;
1230 GpStatus WINGDIPAPI GdipGetSolidFillColor(GpSolidFill *sf, ARGB *argb)
1232 TRACE("(%p, %p)\n", sf, argb);
1235 return InvalidParameter;
1242 /******************************************************************************
1243 * GdipGetTextureImage [GDIPLUS.@]
1245 GpStatus WINGDIPAPI GdipGetTextureImage(GpTexture *brush, GpImage **image)
1247 TRACE("(%p, %p)\n", brush, image);
1249 if(!brush || !image)
1250 return InvalidParameter;
1252 return GdipCloneImage(brush->image, image);
1255 /******************************************************************************
1256 * GdipGetTextureTransform [GDIPLUS.@]
1258 GpStatus WINGDIPAPI GdipGetTextureTransform(GpTexture *brush, GpMatrix *matrix)
1260 TRACE("(%p, %p)\n", brush, matrix);
1262 if(!brush || !matrix)
1263 return InvalidParameter;
1265 memcpy(matrix, brush->transform, sizeof(GpMatrix));
1270 /******************************************************************************
1271 * GdipGetTextureWrapMode [GDIPLUS.@]
1273 GpStatus WINGDIPAPI GdipGetTextureWrapMode(GpTexture *brush, GpWrapMode *wrapmode)
1275 TRACE("(%p, %p)\n", brush, wrapmode);
1277 if(!brush || !wrapmode)
1278 return InvalidParameter;
1280 *wrapmode = brush->wrap;
1285 /******************************************************************************
1286 * GdipMultiplyTextureTransform [GDIPLUS.@]
1288 GpStatus WINGDIPAPI GdipMultiplyTextureTransform(GpTexture* brush,
1289 GDIPCONST GpMatrix *matrix, GpMatrixOrder order)
1291 TRACE("(%p, %p, %d)\n", brush, matrix, order);
1293 if(!brush || !matrix)
1294 return InvalidParameter;
1296 return GdipMultiplyMatrix(brush->transform, matrix, order);
1299 /******************************************************************************
1300 * GdipResetTextureTransform [GDIPLUS.@]
1302 GpStatus WINGDIPAPI GdipResetTextureTransform(GpTexture* brush)
1304 TRACE("(%p)\n", brush);
1307 return InvalidParameter;
1309 return GdipSetMatrixElements(brush->transform, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
1312 /******************************************************************************
1313 * GdipScaleTextureTransform [GDIPLUS.@]
1315 GpStatus WINGDIPAPI GdipScaleTextureTransform(GpTexture* brush,
1316 REAL sx, REAL sy, GpMatrixOrder order)
1318 TRACE("(%p, %.2f, %.2f, %d)\n", brush, sx, sy, order);
1321 return InvalidParameter;
1323 return GdipScaleMatrix(brush->transform, sx, sy, order);
1326 GpStatus WINGDIPAPI GdipSetLineBlend(GpLineGradient *brush,
1327 GDIPCONST REAL *factors, GDIPCONST REAL* positions, INT count)
1329 REAL *new_blendfac, *new_blendpos;
1331 TRACE("(%p, %p, %p, %i)\n", brush, factors, positions, count);
1333 if(!brush || !factors || !positions || count <= 0 ||
1334 (count >= 2 && (positions[0] != 0.0f || positions[count-1] != 1.0f)))
1335 return InvalidParameter;
1337 new_blendfac = GdipAlloc(count * sizeof(REAL));
1338 new_blendpos = GdipAlloc(count * sizeof(REAL));
1340 if (!new_blendfac || !new_blendpos)
1342 GdipFree(new_blendfac);
1343 GdipFree(new_blendpos);
1347 memcpy(new_blendfac, factors, count * sizeof(REAL));
1348 memcpy(new_blendpos, positions, count * sizeof(REAL));
1350 GdipFree(brush->blendfac);
1351 GdipFree(brush->blendpos);
1353 brush->blendcount = count;
1354 brush->blendfac = new_blendfac;
1355 brush->blendpos = new_blendpos;
1360 GpStatus WINGDIPAPI GdipGetLineBlend(GpLineGradient *brush, REAL *factors,
1361 REAL *positions, INT count)
1363 TRACE("(%p, %p, %p, %i)\n", brush, factors, positions, count);
1365 if (!brush || !factors || !positions || count <= 0)
1366 return InvalidParameter;
1368 if (count < brush->blendcount)
1369 return InsufficientBuffer;
1371 memcpy(factors, brush->blendfac, brush->blendcount * sizeof(REAL));
1372 memcpy(positions, brush->blendpos, brush->blendcount * sizeof(REAL));
1377 GpStatus WINGDIPAPI GdipGetLineBlendCount(GpLineGradient *brush, INT *count)
1379 TRACE("(%p, %p)\n", brush, count);
1381 if (!brush || !count)
1382 return InvalidParameter;
1384 *count = brush->blendcount;
1389 GpStatus WINGDIPAPI GdipSetLineGammaCorrection(GpLineGradient *line,
1392 TRACE("(%p, %d)\n", line, usegamma);
1395 return InvalidParameter;
1397 line->gamma = usegamma;
1402 GpStatus WINGDIPAPI GdipSetLineSigmaBlend(GpLineGradient *line, REAL focus,
1409 const int precision = 16;
1410 REAL erf_range; /* we use values erf(-erf_range) through erf(+erf_range) */
1414 TRACE("(%p, %0.2f, %0.2f)\n", line, focus, scale);
1416 if(!line || focus < 0.0 || focus > 1.0 || scale < 0.0 || scale > 1.0)
1417 return InvalidParameter;
1419 /* we want 2 standard deviations */
1420 erf_range = 2.0 / sqrt(2);
1422 /* calculate the constants we need to normalize the error function to be
1423 between 0.0 and scale over the range we need */
1424 min_erf = erf(-erf_range);
1425 scale_erf = scale / (-2.0 * min_erf);
1431 for (i=1; i<precision; i++)
1433 positions[i] = focus * i / precision;
1434 factors[i] = scale_erf * (erf(2 * erf_range * i / precision - erf_range) - min_erf);
1436 num_points += precision;
1439 positions[num_points] = focus;
1440 factors[num_points] = scale;
1445 for (i=1; i<precision; i++)
1447 positions[i+num_points-1] = (focus + ((1.0-focus) * i / precision));
1448 factors[i+num_points-1] = scale_erf * (erf(erf_range - 2 * erf_range * i / precision) - min_erf);
1450 num_points += precision;
1451 positions[num_points-1] = 1.0;
1452 factors[num_points-1] = 0.0;
1455 return GdipSetLineBlend(line, factors, positions, num_points);
1458 GpStatus WINGDIPAPI GdipSetLineWrapMode(GpLineGradient *line,
1461 TRACE("(%p, %d)\n", line, wrap);
1463 if(!line || wrap == WrapModeClamp)
1464 return InvalidParameter;
1471 GpStatus WINGDIPAPI GdipSetPathGradientBlend(GpPathGradient *brush, GDIPCONST REAL *blend,
1472 GDIPCONST REAL *pos, INT count)
1476 TRACE("(%p,%p,%p,%i)\n", brush, blend, pos, count);
1479 FIXME("not implemented\n");
1481 return NotImplemented;
1484 GpStatus WINGDIPAPI GdipSetPathGradientLinearBlend(GpPathGradient *brush,
1485 REAL focus, REAL scale)
1489 TRACE("(%p,%0.2f,%0.2f)\n", brush, focus, scale);
1492 FIXME("not implemented\n");
1494 return NotImplemented;
1497 GpStatus WINGDIPAPI GdipSetPathGradientPresetBlend(GpPathGradient *brush,
1498 GDIPCONST ARGB *blend, GDIPCONST REAL *pos, INT count)
1500 FIXME("(%p,%p,%p,%i): stub\n", brush, blend, pos, count);
1501 return NotImplemented;
1504 GpStatus WINGDIPAPI GdipGetPathGradientPresetBlend(GpPathGradient *brush,
1505 ARGB *blend, REAL *pos, INT count)
1507 FIXME("(%p,%p,%p,%i): stub\n", brush, blend, pos, count);
1508 return NotImplemented;
1511 GpStatus WINGDIPAPI GdipGetPathGradientPresetBlendCount(GpPathGradient *brush,
1514 FIXME("(%p,%p): stub\n", brush, count);
1515 return NotImplemented;
1518 GpStatus WINGDIPAPI GdipSetPathGradientCenterColor(GpPathGradient *grad,
1521 TRACE("(%p, %x)\n", grad, argb);
1524 return InvalidParameter;
1526 grad->centercolor = argb;
1527 grad->brush.lb.lbColor = ARGB2COLORREF(argb);
1529 DeleteObject(grad->brush.gdibrush);
1530 grad->brush.gdibrush = CreateSolidBrush(grad->brush.lb.lbColor);
1535 GpStatus WINGDIPAPI GdipSetPathGradientCenterPoint(GpPathGradient *grad,
1538 TRACE("(%p, %s)\n", grad, debugstr_pointf(point));
1541 return InvalidParameter;
1543 grad->center.X = point->X;
1544 grad->center.Y = point->Y;
1549 GpStatus WINGDIPAPI GdipSetPathGradientCenterPointI(GpPathGradient *grad,
1554 TRACE("(%p, %p)\n", grad, point);
1557 return InvalidParameter;
1559 ptf.X = (REAL)point->X;
1560 ptf.Y = (REAL)point->Y;
1562 return GdipSetPathGradientCenterPoint(grad,&ptf);
1565 GpStatus WINGDIPAPI GdipSetPathGradientFocusScales(GpPathGradient *grad,
1568 TRACE("(%p, %.2f, %.2f)\n", grad, x, y);
1571 return InvalidParameter;
1579 GpStatus WINGDIPAPI GdipSetPathGradientGammaCorrection(GpPathGradient *grad,
1582 TRACE("(%p, %d)\n", grad, gamma);
1585 return InvalidParameter;
1587 grad->gamma = gamma;
1592 GpStatus WINGDIPAPI GdipSetPathGradientSigmaBlend(GpPathGradient *grad,
1593 REAL focus, REAL scale)
1597 TRACE("(%p,%0.2f,%0.2f)\n", grad, focus, scale);
1599 if(!grad || focus < 0.0 || focus > 1.0 || scale < 0.0 || scale > 1.0)
1600 return InvalidParameter;
1603 FIXME("not implemented\n");
1605 return NotImplemented;
1608 GpStatus WINGDIPAPI GdipSetPathGradientSurroundColorsWithCount(GpPathGradient
1609 *grad, GDIPCONST ARGB *argb, INT *count)
1613 TRACE("(%p,%p,%p)\n", grad, argb, count);
1615 if(!grad || !argb || !count || (*count <= 0) ||
1616 (*count > grad->pathdata.Count))
1617 return InvalidParameter;
1620 FIXME("not implemented\n");
1622 return NotImplemented;
1625 GpStatus WINGDIPAPI GdipSetPathGradientWrapMode(GpPathGradient *grad,
1628 TRACE("(%p, %d)\n", grad, wrap);
1631 return InvalidParameter;
1638 GpStatus WINGDIPAPI GdipSetPathGradientTransform(GpPathGradient *grad,
1643 TRACE("(%p,%p)\n", grad, matrix);
1646 FIXME("not implemented\n");
1648 return NotImplemented;
1651 GpStatus WINGDIPAPI GdipGetPathGradientTransform(GpPathGradient *grad,
1656 TRACE("(%p,%p)\n", grad, matrix);
1659 FIXME("not implemented\n");
1661 return NotImplemented;
1664 GpStatus WINGDIPAPI GdipMultiplyPathGradientTransform(GpPathGradient *grad,
1665 GDIPCONST GpMatrix *matrix, GpMatrixOrder order)
1669 TRACE("(%p,%p,%i)\n", grad, matrix, order);
1672 FIXME("not implemented\n");
1674 return NotImplemented;
1677 GpStatus WINGDIPAPI GdipRotatePathGradientTransform(GpPathGradient *grad,
1678 REAL angle, GpMatrixOrder order)
1682 TRACE("(%p,%0.2f,%i)\n", grad, angle, order);
1685 FIXME("not implemented\n");
1687 return NotImplemented;
1690 GpStatus WINGDIPAPI GdipScalePathGradientTransform(GpPathGradient *grad,
1691 REAL sx, REAL sy, GpMatrixOrder order)
1695 TRACE("(%p,%0.2f,%0.2f,%i)\n", grad, sx, sy, order);
1698 FIXME("not implemented\n");
1700 return NotImplemented;
1703 GpStatus WINGDIPAPI GdipTranslatePathGradientTransform(GpPathGradient *grad,
1704 REAL dx, REAL dy, GpMatrixOrder order)
1708 TRACE("(%p,%0.2f,%0.2f,%i)\n", grad, dx, dy, order);
1711 FIXME("not implemented\n");
1713 return NotImplemented;
1716 GpStatus WINGDIPAPI GdipSetSolidFillColor(GpSolidFill *sf, ARGB argb)
1718 TRACE("(%p, %x)\n", sf, argb);
1721 return InvalidParameter;
1724 sf->brush.lb.lbColor = ARGB2COLORREF(argb);
1726 DeleteObject(sf->brush.gdibrush);
1727 sf->brush.gdibrush = CreateSolidBrush(sf->brush.lb.lbColor);
1732 /******************************************************************************
1733 * GdipSetTextureTransform [GDIPLUS.@]
1735 GpStatus WINGDIPAPI GdipSetTextureTransform(GpTexture *texture,
1736 GDIPCONST GpMatrix *matrix)
1738 TRACE("(%p, %p)\n", texture, matrix);
1740 if(!texture || !matrix)
1741 return InvalidParameter;
1743 memcpy(texture->transform, matrix, sizeof(GpMatrix));
1748 /******************************************************************************
1749 * GdipSetTextureWrapMode [GDIPLUS.@]
1751 * WrapMode not used, only stored
1753 GpStatus WINGDIPAPI GdipSetTextureWrapMode(GpTexture *brush, GpWrapMode wrapmode)
1755 TRACE("(%p, %d)\n", brush, wrapmode);
1758 return InvalidParameter;
1760 brush->wrap = wrapmode;
1765 GpStatus WINGDIPAPI GdipSetLineColors(GpLineGradient *brush, ARGB color1,
1768 TRACE("(%p, %x, %x)\n", brush, color1, color2);
1771 return InvalidParameter;
1773 brush->startcolor = color1;
1774 brush->endcolor = color2;
1779 GpStatus WINGDIPAPI GdipGetLineColors(GpLineGradient *brush, ARGB *colors)
1781 TRACE("(%p, %p)\n", brush, colors);
1783 if(!brush || !colors)
1784 return InvalidParameter;
1786 colors[0] = brush->startcolor;
1787 colors[1] = brush->endcolor;
1792 /******************************************************************************
1793 * GdipRotateTextureTransform [GDIPLUS.@]
1795 GpStatus WINGDIPAPI GdipRotateTextureTransform(GpTexture* brush, REAL angle,
1796 GpMatrixOrder order)
1798 TRACE("(%p, %.2f, %d)\n", brush, angle, order);
1801 return InvalidParameter;
1803 return GdipRotateMatrix(brush->transform, angle, order);
1806 GpStatus WINGDIPAPI GdipSetLineLinearBlend(GpLineGradient *brush, REAL focus,
1813 TRACE("(%p,%.2f,%.2f)\n", brush, focus, scale);
1815 if (!brush) return InvalidParameter;
1819 factors[num_points] = 0.0;
1820 positions[num_points] = 0.0;
1824 factors[num_points] = scale;
1825 positions[num_points] = focus;
1830 factors[num_points] = 0.0;
1831 positions[num_points] = 1.0;
1835 return GdipSetLineBlend(brush, factors, positions, num_points);
1838 GpStatus WINGDIPAPI GdipSetLinePresetBlend(GpLineGradient *brush,
1839 GDIPCONST ARGB *blend, GDIPCONST REAL* positions, INT count)
1843 TRACE("(%p,%p,%p,%i)\n", brush, blend, positions, count);
1845 if (!brush || !blend || !positions || count < 2 ||
1846 positions[0] != 0.0f || positions[count-1] != 1.0f)
1848 return InvalidParameter;
1851 new_color = GdipAlloc(count * sizeof(ARGB));
1852 new_pos = GdipAlloc(count * sizeof(REAL));
1853 if (!new_color || !new_pos)
1855 GdipFree(new_color);
1860 memcpy(new_color, blend, sizeof(ARGB) * count);
1861 memcpy(new_pos, positions, sizeof(REAL) * count);
1863 GdipFree(brush->pblendcolor);
1864 GdipFree(brush->pblendpos);
1866 brush->pblendcolor = new_color;
1867 brush->pblendpos = new_pos;
1868 brush->pblendcount = count;
1873 GpStatus WINGDIPAPI GdipGetLinePresetBlend(GpLineGradient *brush,
1874 ARGB *blend, REAL* positions, INT count)
1876 if (!brush || !blend || !positions || count < 2)
1877 return InvalidParameter;
1879 if (brush->pblendcount == 0)
1880 return GenericError;
1882 if (count < brush->pblendcount)
1883 return InsufficientBuffer;
1885 memcpy(blend, brush->pblendcolor, sizeof(ARGB) * brush->pblendcount);
1886 memcpy(positions, brush->pblendpos, sizeof(REAL) * brush->pblendcount);
1891 GpStatus WINGDIPAPI GdipGetLinePresetBlendCount(GpLineGradient *brush,
1894 if (!brush || !count)
1895 return InvalidParameter;
1897 *count = brush->pblendcount;
1902 GpStatus WINGDIPAPI GdipResetLineTransform(GpLineGradient *brush)
1906 TRACE("(%p)\n", brush);
1909 FIXME("not implemented\n");
1911 return NotImplemented;
1914 GpStatus WINGDIPAPI GdipSetLineTransform(GpLineGradient *brush,
1915 GDIPCONST GpMatrix *matrix)
1919 TRACE("(%p,%p)\n", brush, matrix);
1922 FIXME("not implemented\n");
1924 return NotImplemented;
1927 GpStatus WINGDIPAPI GdipGetLineTransform(GpLineGradient *brush, GpMatrix *matrix)
1931 TRACE("(%p,%p)\n", brush, matrix);
1934 FIXME("not implemented\n");
1936 return NotImplemented;
1939 GpStatus WINGDIPAPI GdipScaleLineTransform(GpLineGradient *brush, REAL sx, REAL sy,
1940 GpMatrixOrder order)
1944 TRACE("(%p,%0.2f,%0.2f,%u)\n", brush, sx, sy, order);
1947 FIXME("not implemented\n");
1949 return NotImplemented;
1952 GpStatus WINGDIPAPI GdipMultiplyLineTransform(GpLineGradient *brush,
1953 GDIPCONST GpMatrix *matrix, GpMatrixOrder order)
1957 TRACE("(%p,%p,%u)\n", brush, matrix, order);
1960 FIXME("not implemented\n");
1962 return NotImplemented;
1965 GpStatus WINGDIPAPI GdipTranslateLineTransform(GpLineGradient* brush,
1966 REAL dx, REAL dy, GpMatrixOrder order)
1968 FIXME("stub: %p %f %f %d\n", brush, dx, dy, order);
1970 return NotImplemented;
1973 /******************************************************************************
1974 * GdipTranslateTextureTransform [GDIPLUS.@]
1976 GpStatus WINGDIPAPI GdipTranslateTextureTransform(GpTexture* brush, REAL dx, REAL dy,
1977 GpMatrixOrder order)
1979 TRACE("(%p, %.2f, %.2f, %d)\n", brush, dx, dy, order);
1982 return InvalidParameter;
1984 return GdipTranslateMatrix(brush->transform, dx, dy, order);
1987 GpStatus WINGDIPAPI GdipGetLineRect(GpLineGradient *brush, GpRectF *rect)
1989 TRACE("(%p, %p)\n", brush, rect);
1992 return InvalidParameter;
1994 *rect = brush->rect;
1999 GpStatus WINGDIPAPI GdipGetLineRectI(GpLineGradient *brush, GpRect *rect)
2004 TRACE("(%p, %p)\n", brush, rect);
2007 return InvalidParameter;
2009 ret = GdipGetLineRect(brush, &rectF);
2012 rect->X = roundr(rectF.X);
2013 rect->Y = roundr(rectF.Y);
2014 rect->Width = roundr(rectF.Width);
2015 rect->Height = roundr(rectF.Height);
2021 GpStatus WINGDIPAPI GdipRotateLineTransform(GpLineGradient* brush,
2022 REAL angle, GpMatrixOrder order)
2026 TRACE("(%p,%0.2f,%u)\n", brush, angle, order);
2029 return InvalidParameter;
2032 FIXME("(%p, %.2f, %d) stub\n", brush, angle, order);
2034 return NotImplemented;