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 /******************************************************************************
223 * GdipCreateHatchBrush [GDIPLUS.@]
225 GpStatus WINGDIPAPI GdipCreateHatchBrush(HatchStyle hatchstyle, ARGB forecol, ARGB backcol, GpHatch **brush)
227 COLORREF fgcol = ARGB2COLORREF(forecol);
230 TRACE("(%d, %d, %d, %p)\n", hatchstyle, forecol, backcol, brush);
232 if(!brush) return InvalidParameter;
234 *brush = GdipAlloc(sizeof(GpHatch));
235 if (!*brush) return OutOfMemory;
237 if (hatchstyle < sizeof(HatchBrushes) / sizeof(HatchBrushes[0]))
241 BITMAPINFOHEADER bmih;
245 hdc = CreateCompatibleDC(0);
249 bmih.biSize = sizeof(bmih);
253 bmih.biBitCount = 32;
254 bmih.biCompression = BI_RGB;
255 bmih.biSizeImage = 0;
257 hbmp = CreateDIBSection(hdc, (BITMAPINFO*)&bmih, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
263 if ((HatchBrushes[hatchstyle][y] & (0x80 >> x)) != 0)
264 bits[y*8+x] = forecol;
266 bits[y*8+x] = backcol;
278 (*brush)->brush.lb.lbStyle = BS_PATTERN;
279 (*brush)->brush.lb.lbColor = 0;
280 (*brush)->brush.lb.lbHatch = (ULONG_PTR)hbmp;
281 (*brush)->brush.gdibrush = CreateBrushIndirect(&(*brush)->brush.lb);
288 FIXME("Unimplemented hatch style %d\n", hatchstyle);
290 (*brush)->brush.lb.lbStyle = BS_SOLID;
291 (*brush)->brush.lb.lbColor = fgcol;
292 (*brush)->brush.lb.lbHatch = 0;
293 (*brush)->brush.gdibrush = CreateBrushIndirect(&(*brush)->brush.lb);
298 (*brush)->brush.bt = BrushTypeHatchFill;
299 (*brush)->forecol = forecol;
300 (*brush)->backcol = backcol;
301 (*brush)->hatchstyle = hatchstyle;
302 TRACE("<-- %p\n", *brush);
313 /******************************************************************************
314 * GdipCreateLineBrush [GDIPLUS.@]
316 GpStatus WINGDIPAPI GdipCreateLineBrush(GDIPCONST GpPointF* startpoint,
317 GDIPCONST GpPointF* endpoint, ARGB startcolor, ARGB endcolor,
318 GpWrapMode wrap, GpLineGradient **line)
320 COLORREF col = ARGB2COLORREF(startcolor);
322 TRACE("(%s, %s, %x, %x, %d, %p)\n", debugstr_pointf(startpoint),
323 debugstr_pointf(endpoint), startcolor, endcolor, wrap, line);
325 if(!line || !startpoint || !endpoint || wrap == WrapModeClamp)
326 return InvalidParameter;
328 *line = GdipAlloc(sizeof(GpLineGradient));
329 if(!*line) return OutOfMemory;
331 (*line)->brush.lb.lbStyle = BS_SOLID;
332 (*line)->brush.lb.lbColor = col;
333 (*line)->brush.lb.lbHatch = 0;
334 (*line)->brush.gdibrush = CreateSolidBrush(col);
335 (*line)->brush.bt = BrushTypeLinearGradient;
337 (*line)->startpoint.X = startpoint->X;
338 (*line)->startpoint.Y = startpoint->Y;
339 (*line)->endpoint.X = endpoint->X;
340 (*line)->endpoint.Y = endpoint->Y;
341 (*line)->startcolor = startcolor;
342 (*line)->endcolor = endcolor;
343 (*line)->wrap = wrap;
344 (*line)->gamma = FALSE;
346 (*line)->rect.X = (startpoint->X < endpoint->X ? startpoint->X: endpoint->X);
347 (*line)->rect.Y = (startpoint->Y < endpoint->Y ? startpoint->Y: endpoint->Y);
348 (*line)->rect.Width = fabs(startpoint->X - endpoint->X);
349 (*line)->rect.Height = fabs(startpoint->Y - endpoint->Y);
351 if ((*line)->rect.Width == 0)
353 (*line)->rect.X -= (*line)->rect.Height / 2.0f;
354 (*line)->rect.Width = (*line)->rect.Height;
356 else if ((*line)->rect.Height == 0)
358 (*line)->rect.Y -= (*line)->rect.Width / 2.0f;
359 (*line)->rect.Height = (*line)->rect.Width;
362 (*line)->blendcount = 1;
363 (*line)->blendfac = GdipAlloc(sizeof(REAL));
364 (*line)->blendpos = GdipAlloc(sizeof(REAL));
366 if (!(*line)->blendfac || !(*line)->blendpos)
368 GdipFree((*line)->blendfac);
369 GdipFree((*line)->blendpos);
370 DeleteObject((*line)->brush.gdibrush);
376 (*line)->blendfac[0] = 1.0f;
377 (*line)->blendpos[0] = 1.0f;
379 (*line)->pblendcolor = NULL;
380 (*line)->pblendpos = NULL;
381 (*line)->pblendcount = 0;
383 TRACE("<-- %p\n", *line);
388 GpStatus WINGDIPAPI GdipCreateLineBrushI(GDIPCONST GpPoint* startpoint,
389 GDIPCONST GpPoint* endpoint, ARGB startcolor, ARGB endcolor,
390 GpWrapMode wrap, GpLineGradient **line)
395 TRACE("(%p, %p, %x, %x, %d, %p)\n", startpoint, endpoint,
396 startcolor, endcolor, wrap, line);
398 if(!startpoint || !endpoint)
399 return InvalidParameter;
401 stF.X = (REAL)startpoint->X;
402 stF.Y = (REAL)startpoint->Y;
403 endF.X = (REAL)endpoint->X;
404 endF.X = (REAL)endpoint->Y;
406 return GdipCreateLineBrush(&stF, &endF, startcolor, endcolor, wrap, line);
409 GpStatus WINGDIPAPI GdipCreateLineBrushFromRect(GDIPCONST GpRectF* rect,
410 ARGB startcolor, ARGB endcolor, LinearGradientMode mode, GpWrapMode wrap,
411 GpLineGradient **line)
416 TRACE("(%p, %x, %x, %d, %d, %p)\n", rect, startcolor, endcolor, mode,
420 return InvalidParameter;
424 case LinearGradientModeHorizontal:
427 end.X = rect->X + rect->Width;
430 case LinearGradientModeVertical:
434 end.Y = rect->Y + rect->Height;
436 case LinearGradientModeForwardDiagonal:
439 end.X = rect->X + rect->Width;
440 end.Y = rect->Y + rect->Height;
442 case LinearGradientModeBackwardDiagonal:
443 start.X = rect->X + rect->Width;
446 end.Y = rect->Y + rect->Height;
449 return InvalidParameter;
452 stat = GdipCreateLineBrush(&start, &end, startcolor, endcolor, wrap, line);
455 (*line)->rect = *rect;
460 GpStatus WINGDIPAPI GdipCreateLineBrushFromRectI(GDIPCONST GpRect* rect,
461 ARGB startcolor, ARGB endcolor, LinearGradientMode mode, GpWrapMode wrap,
462 GpLineGradient **line)
466 TRACE("(%p, %x, %x, %d, %d, %p)\n", rect, startcolor, endcolor, mode,
469 rectF.X = (REAL) rect->X;
470 rectF.Y = (REAL) rect->Y;
471 rectF.Width = (REAL) rect->Width;
472 rectF.Height = (REAL) rect->Height;
474 return GdipCreateLineBrushFromRect(&rectF, startcolor, endcolor, mode, wrap, line);
477 /******************************************************************************
478 * GdipCreateLineBrushFromRectWithAngle [GDIPLUS.@]
480 GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngle(GDIPCONST GpRectF* rect,
481 ARGB startcolor, ARGB endcolor, REAL angle, BOOL isAngleScalable, GpWrapMode wrap,
482 GpLineGradient **line)
485 LinearGradientMode mode;
486 REAL width, height, exofs, eyofs;
487 REAL sin_angle, cos_angle, sin_cos_angle;
489 TRACE("(%p, %x, %x, %.2f, %d, %d, %p)\n", rect, startcolor, endcolor, angle, isAngleScalable,
492 sin_angle = sinf(deg2rad(angle));
493 cos_angle = cosf(deg2rad(angle));
494 sin_cos_angle = sin_angle * cos_angle;
498 width = height = 1.0;
503 height = rect->Height;
506 if (sin_cos_angle >= 0)
507 mode = LinearGradientModeForwardDiagonal;
509 mode = LinearGradientModeBackwardDiagonal;
511 stat = GdipCreateLineBrushFromRect(rect, startcolor, endcolor, mode, wrap, line);
515 if (sin_cos_angle >= 0)
517 exofs = width * sin_cos_angle + height * cos_angle * cos_angle;
518 eyofs = width * sin_angle * sin_angle + height * sin_cos_angle;
522 exofs = width * sin_angle * sin_angle + height * sin_cos_angle;
523 eyofs = -width * sin_cos_angle + height * sin_angle * sin_angle;
528 exofs = exofs * rect->Width;
529 eyofs = eyofs * rect->Height;
534 (*line)->endpoint.X = rect->X + exofs;
535 (*line)->endpoint.Y = rect->Y + eyofs;
539 (*line)->endpoint.X = (*line)->startpoint.X;
540 (*line)->endpoint.Y = (*line)->startpoint.Y;
541 (*line)->startpoint.X = rect->X + exofs;
542 (*line)->startpoint.Y = rect->Y + eyofs;
549 GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngleI(GDIPCONST GpRect* rect,
550 ARGB startcolor, ARGB endcolor, REAL angle, BOOL isAngleScalable, GpWrapMode wrap,
551 GpLineGradient **line)
553 TRACE("(%p, %x, %x, %.2f, %d, %d, %p)\n", rect, startcolor, endcolor, angle, isAngleScalable,
556 return GdipCreateLineBrushFromRectI(rect, startcolor, endcolor, LinearGradientModeForwardDiagonal,
560 GpStatus WINGDIPAPI GdipCreatePathGradient(GDIPCONST GpPointF* points,
561 INT count, GpWrapMode wrap, GpPathGradient **grad)
563 COLORREF col = ARGB2COLORREF(0xffffffff);
565 TRACE("(%p, %d, %d, %p)\n", points, count, wrap, grad);
568 return InvalidParameter;
573 *grad = GdipAlloc(sizeof(GpPathGradient));
574 if (!*grad) return OutOfMemory;
576 (*grad)->blendfac = GdipAlloc(sizeof(REAL));
577 if(!(*grad)->blendfac){
581 (*grad)->blendfac[0] = 1.0;
582 (*grad)->blendpos = NULL;
583 (*grad)->blendcount = 1;
585 (*grad)->pathdata.Count = count;
586 (*grad)->pathdata.Points = GdipAlloc(count * sizeof(PointF));
587 (*grad)->pathdata.Types = GdipAlloc(count);
589 if(!(*grad)->pathdata.Points || !(*grad)->pathdata.Types){
590 GdipFree((*grad)->pathdata.Points);
591 GdipFree((*grad)->pathdata.Types);
596 memcpy((*grad)->pathdata.Points, points, count * sizeof(PointF));
597 memset((*grad)->pathdata.Types, PathPointTypeLine, count);
599 (*grad)->brush.lb.lbStyle = BS_SOLID;
600 (*grad)->brush.lb.lbColor = col;
601 (*grad)->brush.lb.lbHatch = 0;
603 (*grad)->brush.gdibrush = CreateSolidBrush(col);
604 (*grad)->brush.bt = BrushTypePathGradient;
605 (*grad)->centercolor = 0xffffffff;
606 (*grad)->wrap = wrap;
607 (*grad)->gamma = FALSE;
608 (*grad)->center.X = 0.0;
609 (*grad)->center.Y = 0.0;
610 (*grad)->focus.X = 0.0;
611 (*grad)->focus.Y = 0.0;
613 TRACE("<-- %p\n", *grad);
618 GpStatus WINGDIPAPI GdipCreatePathGradientI(GDIPCONST GpPoint* points,
619 INT count, GpWrapMode wrap, GpPathGradient **grad)
625 TRACE("(%p, %d, %d, %p)\n", points, count, wrap, grad);
628 return InvalidParameter;
633 pointsF = GdipAlloc(sizeof(GpPointF) * count);
637 for(i = 0; i < count; i++){
638 pointsF[i].X = (REAL)points[i].X;
639 pointsF[i].Y = (REAL)points[i].Y;
642 ret = GdipCreatePathGradient(pointsF, count, wrap, grad);
648 /******************************************************************************
649 * GdipCreatePathGradientFromPath [GDIPLUS.@]
651 * FIXME: path gradient brushes not truly supported (drawn as solid brushes)
653 GpStatus WINGDIPAPI GdipCreatePathGradientFromPath(GDIPCONST GpPath* path,
654 GpPathGradient **grad)
656 COLORREF col = ARGB2COLORREF(0xffffffff);
658 TRACE("(%p, %p)\n", path, grad);
661 return InvalidParameter;
663 *grad = GdipAlloc(sizeof(GpPathGradient));
664 if (!*grad) return OutOfMemory;
666 (*grad)->blendfac = GdipAlloc(sizeof(REAL));
667 if(!(*grad)->blendfac){
671 (*grad)->blendfac[0] = 1.0;
672 (*grad)->blendpos = NULL;
673 (*grad)->blendcount = 1;
675 (*grad)->pathdata.Count = path->pathdata.Count;
676 (*grad)->pathdata.Points = GdipAlloc(path->pathdata.Count * sizeof(PointF));
677 (*grad)->pathdata.Types = GdipAlloc(path->pathdata.Count);
679 if(!(*grad)->pathdata.Points || !(*grad)->pathdata.Types){
680 GdipFree((*grad)->pathdata.Points);
681 GdipFree((*grad)->pathdata.Types);
686 memcpy((*grad)->pathdata.Points, path->pathdata.Points,
687 path->pathdata.Count * sizeof(PointF));
688 memcpy((*grad)->pathdata.Types, path->pathdata.Types, path->pathdata.Count);
690 (*grad)->brush.lb.lbStyle = BS_SOLID;
691 (*grad)->brush.lb.lbColor = col;
692 (*grad)->brush.lb.lbHatch = 0;
694 (*grad)->brush.gdibrush = CreateSolidBrush(col);
695 (*grad)->brush.bt = BrushTypePathGradient;
696 (*grad)->centercolor = 0xffffffff;
697 (*grad)->wrap = WrapModeClamp;
698 (*grad)->gamma = FALSE;
699 /* FIXME: this should be set to the "centroid" of the path by default */
700 (*grad)->center.X = 0.0;
701 (*grad)->center.Y = 0.0;
702 (*grad)->focus.X = 0.0;
703 (*grad)->focus.Y = 0.0;
705 TRACE("<-- %p\n", *grad);
710 /******************************************************************************
711 * GdipCreateSolidFill [GDIPLUS.@]
713 GpStatus WINGDIPAPI GdipCreateSolidFill(ARGB color, GpSolidFill **sf)
715 COLORREF col = ARGB2COLORREF(color);
717 TRACE("(%x, %p)\n", color, sf);
719 if(!sf) return InvalidParameter;
721 *sf = GdipAlloc(sizeof(GpSolidFill));
722 if (!*sf) return OutOfMemory;
724 (*sf)->brush.lb.lbStyle = BS_SOLID;
725 (*sf)->brush.lb.lbColor = col;
726 (*sf)->brush.lb.lbHatch = 0;
728 (*sf)->brush.gdibrush = CreateSolidBrush(col);
729 (*sf)->brush.bt = BrushTypeSolidColor;
730 (*sf)->color = color;
731 (*sf)->bmp = ARGB2BMP(color);
733 TRACE("<-- %p\n", *sf);
738 /******************************************************************************
739 * GdipCreateTexture [GDIPLUS.@]
742 * image [I] image to use
743 * wrapmode [I] optional
744 * texture [O] pointer to the resulting texturebrush
748 * FAILURE: element of GpStatus
750 GpStatus WINGDIPAPI GdipCreateTexture(GpImage *image, GpWrapMode wrapmode,
754 GpImageAttributes attributes;
757 TRACE("%p, %d %p\n", image, wrapmode, texture);
759 if (!(image && texture))
760 return InvalidParameter;
762 stat = GdipGetImageWidth(image, &width);
763 if (stat != Ok) return stat;
764 stat = GdipGetImageHeight(image, &height);
765 if (stat != Ok) return stat;
766 attributes.wrap = wrapmode;
768 return GdipCreateTextureIA(image, &attributes, 0, 0, width, height,
772 /******************************************************************************
773 * GdipCreateTexture2 [GDIPLUS.@]
775 GpStatus WINGDIPAPI GdipCreateTexture2(GpImage *image, GpWrapMode wrapmode,
776 REAL x, REAL y, REAL width, REAL height, GpTexture **texture)
778 GpImageAttributes attributes;
780 TRACE("%p %d %f %f %f %f %p\n", image, wrapmode,
781 x, y, width, height, texture);
783 attributes.wrap = wrapmode;
784 return GdipCreateTextureIA(image, &attributes, x, y, width, height,
788 /******************************************************************************
789 * GdipCreateTextureIA [GDIPLUS.@]
791 * FIXME: imageattr ignored
793 GpStatus WINGDIPAPI GdipCreateTextureIA(GpImage *image,
794 GDIPCONST GpImageAttributes *imageattr, REAL x, REAL y, REAL width,
795 REAL height, GpTexture **texture)
799 GpImage *new_image=NULL;
801 TRACE("(%p, %p, %.2f, %.2f, %.2f, %.2f, %p)\n", image, imageattr, x, y, width, height,
804 if(!image || !texture || x < 0.0 || y < 0.0 || width < 0.0 || height < 0.0)
805 return InvalidParameter;
809 if(image->type != ImageTypeBitmap){
810 FIXME("not implemented for image type %d\n", image->type);
811 return NotImplemented;
814 status = GdipCloneBitmapArea(x, y, width, height, PixelFormatDontCare, (GpBitmap*)image, (GpBitmap**)&new_image);
818 hbm = ((GpBitmap*)new_image)->hbitmap;
821 status = GenericError;
825 *texture = GdipAlloc(sizeof(GpTexture));
827 status = OutOfMemory;
831 if((status = GdipCreateMatrix(&(*texture)->transform)) != Ok){
835 (*texture)->brush.lb.lbStyle = BS_PATTERN;
836 (*texture)->brush.lb.lbColor = 0;
837 (*texture)->brush.lb.lbHatch = (ULONG_PTR)hbm;
839 (*texture)->brush.gdibrush = CreateBrushIndirect(&(*texture)->brush.lb);
840 (*texture)->brush.bt = BrushTypeTextureFill;
842 (*texture)->wrap = imageattr->wrap;
844 (*texture)->wrap = WrapModeTile;
845 (*texture)->image = new_image;
850 TRACE("<-- %p\n", *texture);
856 GdipDeleteMatrix((*texture)->transform);
860 GdipDisposeImage(new_image);
861 TRACE("<-- error %u\n", status);
867 /******************************************************************************
868 * GdipCreateTextureIAI [GDIPLUS.@]
870 GpStatus WINGDIPAPI GdipCreateTextureIAI(GpImage *image, GDIPCONST GpImageAttributes *imageattr,
871 INT x, INT y, INT width, INT height, GpTexture **texture)
873 TRACE("(%p, %p, %d, %d, %d, %d, %p)\n", image, imageattr, x, y, width, height,
876 return GdipCreateTextureIA(image,imageattr,(REAL)x,(REAL)y,(REAL)width,(REAL)height,texture);
879 GpStatus WINGDIPAPI GdipCreateTexture2I(GpImage *image, GpWrapMode wrapmode,
880 INT x, INT y, INT width, INT height, GpTexture **texture)
882 GpImageAttributes imageattr;
884 TRACE("%p %d %d %d %d %d %p\n", image, wrapmode, x, y, width, height,
887 imageattr.wrap = wrapmode;
889 return GdipCreateTextureIA(image, &imageattr, x, y, width, height, texture);
892 GpStatus WINGDIPAPI GdipGetBrushType(GpBrush *brush, GpBrushType *type)
894 TRACE("(%p, %p)\n", brush, type);
896 if(!brush || !type) return InvalidParameter;
903 GpStatus WINGDIPAPI GdipGetHatchBackgroundColor(GpHatch *brush, ARGB *backcol)
905 TRACE("(%p, %p)\n", brush, backcol);
907 if(!brush || !backcol) return InvalidParameter;
909 *backcol = brush->backcol;
914 GpStatus WINGDIPAPI GdipGetHatchForegroundColor(GpHatch *brush, ARGB *forecol)
916 TRACE("(%p, %p)\n", brush, forecol);
918 if(!brush || !forecol) return InvalidParameter;
920 *forecol = brush->forecol;
925 GpStatus WINGDIPAPI GdipGetHatchStyle(GpHatch *brush, HatchStyle *hatchstyle)
927 TRACE("(%p, %p)\n", brush, hatchstyle);
929 if(!brush || !hatchstyle) return InvalidParameter;
931 *hatchstyle = brush->hatchstyle;
936 GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush *brush)
938 TRACE("(%p)\n", brush);
940 if(!brush) return InvalidParameter;
944 case BrushTypePathGradient:
945 GdipFree(((GpPathGradient*) brush)->pathdata.Points);
946 GdipFree(((GpPathGradient*) brush)->pathdata.Types);
947 GdipFree(((GpPathGradient*) brush)->blendfac);
948 GdipFree(((GpPathGradient*) brush)->blendpos);
950 case BrushTypeSolidColor:
951 if (((GpSolidFill*)brush)->bmp)
952 DeleteObject(((GpSolidFill*)brush)->bmp);
954 case BrushTypeLinearGradient:
955 GdipFree(((GpLineGradient*)brush)->blendfac);
956 GdipFree(((GpLineGradient*)brush)->blendpos);
957 GdipFree(((GpLineGradient*)brush)->pblendcolor);
958 GdipFree(((GpLineGradient*)brush)->pblendpos);
960 case BrushTypeTextureFill:
961 GdipDeleteMatrix(((GpTexture*)brush)->transform);
962 GdipDisposeImage(((GpTexture*)brush)->image);
968 DeleteObject(brush->gdibrush);
974 GpStatus WINGDIPAPI GdipGetLineGammaCorrection(GpLineGradient *line,
977 TRACE("(%p, %p)\n", line, usinggamma);
979 if(!line || !usinggamma)
980 return InvalidParameter;
982 *usinggamma = line->gamma;
987 GpStatus WINGDIPAPI GdipGetLineWrapMode(GpLineGradient *brush, GpWrapMode *wrapmode)
989 TRACE("(%p, %p)\n", brush, wrapmode);
991 if(!brush || !wrapmode)
992 return InvalidParameter;
994 *wrapmode = brush->wrap;
999 GpStatus WINGDIPAPI GdipGetPathGradientBlend(GpPathGradient *brush, REAL *blend,
1000 REAL *positions, INT count)
1002 TRACE("(%p, %p, %p, %d)\n", brush, blend, positions, count);
1004 if(!brush || !blend || !positions || count <= 0)
1005 return InvalidParameter;
1007 if(count < brush->blendcount)
1008 return InsufficientBuffer;
1010 memcpy(blend, brush->blendfac, count*sizeof(REAL));
1011 if(brush->blendcount > 1){
1012 memcpy(positions, brush->blendpos, count*sizeof(REAL));
1018 GpStatus WINGDIPAPI GdipGetPathGradientBlendCount(GpPathGradient *brush, INT *count)
1020 TRACE("(%p, %p)\n", brush, count);
1022 if(!brush || !count)
1023 return InvalidParameter;
1025 *count = brush->blendcount;
1030 GpStatus WINGDIPAPI GdipGetPathGradientCenterPoint(GpPathGradient *grad,
1033 TRACE("(%p, %p)\n", grad, point);
1036 return InvalidParameter;
1038 point->X = grad->center.X;
1039 point->Y = grad->center.Y;
1044 GpStatus WINGDIPAPI GdipGetPathGradientCenterPointI(GpPathGradient *grad,
1050 TRACE("(%p, %p)\n", grad, point);
1053 return InvalidParameter;
1055 ret = GdipGetPathGradientCenterPoint(grad,&ptf);
1058 point->X = roundr(ptf.X);
1059 point->Y = roundr(ptf.Y);
1065 GpStatus WINGDIPAPI GdipGetPathGradientFocusScales(GpPathGradient *grad,
1068 TRACE("(%p, %p, %p)\n", grad, x, y);
1070 if(!grad || !x || !y)
1071 return InvalidParameter;
1079 GpStatus WINGDIPAPI GdipGetPathGradientGammaCorrection(GpPathGradient *grad,
1082 TRACE("(%p, %p)\n", grad, gamma);
1085 return InvalidParameter;
1087 *gamma = grad->gamma;
1092 GpStatus WINGDIPAPI GdipGetPathGradientPointCount(GpPathGradient *grad,
1095 TRACE("(%p, %p)\n", grad, count);
1098 return InvalidParameter;
1100 *count = grad->pathdata.Count;
1105 GpStatus WINGDIPAPI GdipGetPathGradientRect(GpPathGradient *brush, GpRectF *rect)
1111 TRACE("(%p, %p)\n", brush, rect);
1114 return InvalidParameter;
1116 stat = GdipCreatePath2(brush->pathdata.Points, brush->pathdata.Types,
1117 brush->pathdata.Count, FillModeAlternate, &path);
1118 if(stat != Ok) return stat;
1120 stat = GdipGetPathWorldBounds(path, &r, NULL, NULL);
1122 GdipDeletePath(path);
1126 memcpy(rect, &r, sizeof(GpRectF));
1128 GdipDeletePath(path);
1133 GpStatus WINGDIPAPI GdipGetPathGradientRectI(GpPathGradient *brush, GpRect *rect)
1138 TRACE("(%p, %p)\n", brush, rect);
1141 return InvalidParameter;
1143 stat = GdipGetPathGradientRect(brush, &rectf);
1144 if(stat != Ok) return stat;
1146 rect->X = roundr(rectf.X);
1147 rect->Y = roundr(rectf.Y);
1148 rect->Width = roundr(rectf.Width);
1149 rect->Height = roundr(rectf.Height);
1154 GpStatus WINGDIPAPI GdipGetPathGradientSurroundColorsWithCount(GpPathGradient
1155 *grad, ARGB *argb, INT *count)
1159 TRACE("(%p,%p,%p)\n", grad, argb, count);
1161 if(!grad || !argb || !count || (*count < grad->pathdata.Count))
1162 return InvalidParameter;
1165 FIXME("not implemented\n");
1167 return NotImplemented;
1170 GpStatus WINGDIPAPI GdipGetPathGradientSurroundColorCount(GpPathGradient *brush, INT *count)
1172 TRACE("(%p, %p)\n", brush, count);
1174 if (!brush || !count)
1175 return InvalidParameter;
1177 return NotImplemented;
1180 GpStatus WINGDIPAPI GdipGetPathGradientWrapMode(GpPathGradient *brush,
1181 GpWrapMode *wrapmode)
1183 TRACE("(%p, %p)\n", brush, wrapmode);
1185 if(!brush || !wrapmode)
1186 return InvalidParameter;
1188 *wrapmode = brush->wrap;
1193 GpStatus WINGDIPAPI GdipGetSolidFillColor(GpSolidFill *sf, ARGB *argb)
1195 TRACE("(%p, %p)\n", sf, argb);
1198 return InvalidParameter;
1205 /******************************************************************************
1206 * GdipGetTextureImage [GDIPLUS.@]
1208 GpStatus WINGDIPAPI GdipGetTextureImage(GpTexture *brush, GpImage **image)
1210 TRACE("(%p, %p)\n", brush, image);
1212 if(!brush || !image)
1213 return InvalidParameter;
1215 return GdipCloneImage(brush->image, image);
1218 /******************************************************************************
1219 * GdipGetTextureTransform [GDIPLUS.@]
1221 GpStatus WINGDIPAPI GdipGetTextureTransform(GpTexture *brush, GpMatrix *matrix)
1223 TRACE("(%p, %p)\n", brush, matrix);
1225 if(!brush || !matrix)
1226 return InvalidParameter;
1228 memcpy(matrix, brush->transform, sizeof(GpMatrix));
1233 /******************************************************************************
1234 * GdipGetTextureWrapMode [GDIPLUS.@]
1236 GpStatus WINGDIPAPI GdipGetTextureWrapMode(GpTexture *brush, GpWrapMode *wrapmode)
1238 TRACE("(%p, %p)\n", brush, wrapmode);
1240 if(!brush || !wrapmode)
1241 return InvalidParameter;
1243 *wrapmode = brush->wrap;
1248 /******************************************************************************
1249 * GdipMultiplyTextureTransform [GDIPLUS.@]
1251 GpStatus WINGDIPAPI GdipMultiplyTextureTransform(GpTexture* brush,
1252 GDIPCONST GpMatrix *matrix, GpMatrixOrder order)
1254 TRACE("(%p, %p, %d)\n", brush, matrix, order);
1256 if(!brush || !matrix)
1257 return InvalidParameter;
1259 return GdipMultiplyMatrix(brush->transform, matrix, order);
1262 /******************************************************************************
1263 * GdipResetTextureTransform [GDIPLUS.@]
1265 GpStatus WINGDIPAPI GdipResetTextureTransform(GpTexture* brush)
1267 TRACE("(%p)\n", brush);
1270 return InvalidParameter;
1272 return GdipSetMatrixElements(brush->transform, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
1275 /******************************************************************************
1276 * GdipScaleTextureTransform [GDIPLUS.@]
1278 GpStatus WINGDIPAPI GdipScaleTextureTransform(GpTexture* brush,
1279 REAL sx, REAL sy, GpMatrixOrder order)
1281 TRACE("(%p, %.2f, %.2f, %d)\n", brush, sx, sy, order);
1284 return InvalidParameter;
1286 return GdipScaleMatrix(brush->transform, sx, sy, order);
1289 GpStatus WINGDIPAPI GdipSetLineBlend(GpLineGradient *brush,
1290 GDIPCONST REAL *factors, GDIPCONST REAL* positions, INT count)
1292 REAL *new_blendfac, *new_blendpos;
1294 TRACE("(%p, %p, %p, %i)\n", brush, factors, positions, count);
1296 if(!brush || !factors || !positions || count <= 0 ||
1297 (count >= 2 && (positions[0] != 0.0f || positions[count-1] != 1.0f)))
1298 return InvalidParameter;
1300 new_blendfac = GdipAlloc(count * sizeof(REAL));
1301 new_blendpos = GdipAlloc(count * sizeof(REAL));
1303 if (!new_blendfac || !new_blendpos)
1305 GdipFree(new_blendfac);
1306 GdipFree(new_blendpos);
1310 memcpy(new_blendfac, factors, count * sizeof(REAL));
1311 memcpy(new_blendpos, positions, count * sizeof(REAL));
1313 GdipFree(brush->blendfac);
1314 GdipFree(brush->blendpos);
1316 brush->blendcount = count;
1317 brush->blendfac = new_blendfac;
1318 brush->blendpos = new_blendpos;
1323 GpStatus WINGDIPAPI GdipGetLineBlend(GpLineGradient *brush, REAL *factors,
1324 REAL *positions, INT count)
1326 TRACE("(%p, %p, %p, %i)\n", brush, factors, positions, count);
1328 if (!brush || !factors || !positions || count <= 0)
1329 return InvalidParameter;
1331 if (count < brush->blendcount)
1332 return InsufficientBuffer;
1334 memcpy(factors, brush->blendfac, brush->blendcount * sizeof(REAL));
1335 memcpy(positions, brush->blendpos, brush->blendcount * sizeof(REAL));
1340 GpStatus WINGDIPAPI GdipGetLineBlendCount(GpLineGradient *brush, INT *count)
1342 TRACE("(%p, %p)\n", brush, count);
1344 if (!brush || !count)
1345 return InvalidParameter;
1347 *count = brush->blendcount;
1352 GpStatus WINGDIPAPI GdipSetLineGammaCorrection(GpLineGradient *line,
1355 TRACE("(%p, %d)\n", line, usegamma);
1358 return InvalidParameter;
1360 line->gamma = usegamma;
1365 GpStatus WINGDIPAPI GdipSetLineSigmaBlend(GpLineGradient *line, REAL focus,
1372 const int precision = 16;
1373 REAL erf_range; /* we use values erf(-erf_range) through erf(+erf_range) */
1377 TRACE("(%p, %0.2f, %0.2f)\n", line, focus, scale);
1379 if(!line || focus < 0.0 || focus > 1.0 || scale < 0.0 || scale > 1.0)
1380 return InvalidParameter;
1382 /* we want 2 standard deviations */
1383 erf_range = 2.0 / sqrt(2);
1385 /* calculate the constants we need to normalize the error function to be
1386 between 0.0 and scale over the range we need */
1387 min_erf = erf(-erf_range);
1388 scale_erf = scale / (-2.0 * min_erf);
1394 for (i=1; i<precision; i++)
1396 positions[i] = focus * i / precision;
1397 factors[i] = scale_erf * (erf(2 * erf_range * i / precision - erf_range) - min_erf);
1399 num_points += precision;
1402 positions[num_points] = focus;
1403 factors[num_points] = scale;
1408 for (i=1; i<precision; i++)
1410 positions[i+num_points-1] = (focus + ((1.0-focus) * i / precision));
1411 factors[i+num_points-1] = scale_erf * (erf(erf_range - 2 * erf_range * i / precision) - min_erf);
1413 num_points += precision;
1414 positions[num_points-1] = 1.0;
1415 factors[num_points-1] = 0.0;
1418 return GdipSetLineBlend(line, factors, positions, num_points);
1421 GpStatus WINGDIPAPI GdipSetLineWrapMode(GpLineGradient *line,
1424 TRACE("(%p, %d)\n", line, wrap);
1426 if(!line || wrap == WrapModeClamp)
1427 return InvalidParameter;
1434 GpStatus WINGDIPAPI GdipSetPathGradientBlend(GpPathGradient *brush, GDIPCONST REAL *blend,
1435 GDIPCONST REAL *pos, INT count)
1439 TRACE("(%p,%p,%p,%i)\n", brush, blend, pos, count);
1442 FIXME("not implemented\n");
1444 return NotImplemented;
1447 GpStatus WINGDIPAPI GdipSetPathGradientPresetBlend(GpPathGradient *brush,
1448 GDIPCONST ARGB *blend, GDIPCONST REAL *pos, INT count)
1450 FIXME("(%p,%p,%p,%i): stub\n", brush, blend, pos, count);
1451 return NotImplemented;
1454 GpStatus WINGDIPAPI GdipSetPathGradientCenterColor(GpPathGradient *grad,
1457 TRACE("(%p, %x)\n", grad, argb);
1460 return InvalidParameter;
1462 grad->centercolor = argb;
1463 grad->brush.lb.lbColor = ARGB2COLORREF(argb);
1465 DeleteObject(grad->brush.gdibrush);
1466 grad->brush.gdibrush = CreateSolidBrush(grad->brush.lb.lbColor);
1471 GpStatus WINGDIPAPI GdipSetPathGradientCenterPoint(GpPathGradient *grad,
1474 TRACE("(%p, %s)\n", grad, debugstr_pointf(point));
1477 return InvalidParameter;
1479 grad->center.X = point->X;
1480 grad->center.Y = point->Y;
1485 GpStatus WINGDIPAPI GdipSetPathGradientCenterPointI(GpPathGradient *grad,
1490 TRACE("(%p, %p)\n", grad, point);
1493 return InvalidParameter;
1495 ptf.X = (REAL)point->X;
1496 ptf.Y = (REAL)point->Y;
1498 return GdipSetPathGradientCenterPoint(grad,&ptf);
1501 GpStatus WINGDIPAPI GdipSetPathGradientFocusScales(GpPathGradient *grad,
1504 TRACE("(%p, %.2f, %.2f)\n", grad, x, y);
1507 return InvalidParameter;
1515 GpStatus WINGDIPAPI GdipSetPathGradientGammaCorrection(GpPathGradient *grad,
1518 TRACE("(%p, %d)\n", grad, gamma);
1521 return InvalidParameter;
1523 grad->gamma = gamma;
1528 GpStatus WINGDIPAPI GdipSetPathGradientSigmaBlend(GpPathGradient *grad,
1529 REAL focus, REAL scale)
1533 TRACE("(%p,%0.2f,%0.2f)\n", grad, focus, scale);
1535 if(!grad || focus < 0.0 || focus > 1.0 || scale < 0.0 || scale > 1.0)
1536 return InvalidParameter;
1539 FIXME("not implemented\n");
1541 return NotImplemented;
1544 GpStatus WINGDIPAPI GdipSetPathGradientSurroundColorsWithCount(GpPathGradient
1545 *grad, GDIPCONST ARGB *argb, INT *count)
1549 TRACE("(%p,%p,%p)\n", grad, argb, count);
1551 if(!grad || !argb || !count || (*count <= 0) ||
1552 (*count > grad->pathdata.Count))
1553 return InvalidParameter;
1556 FIXME("not implemented\n");
1558 return NotImplemented;
1561 GpStatus WINGDIPAPI GdipSetPathGradientWrapMode(GpPathGradient *grad,
1564 TRACE("(%p, %d)\n", grad, wrap);
1567 return InvalidParameter;
1574 GpStatus WINGDIPAPI GdipSetSolidFillColor(GpSolidFill *sf, ARGB argb)
1576 TRACE("(%p, %x)\n", sf, argb);
1579 return InvalidParameter;
1582 sf->brush.lb.lbColor = ARGB2COLORREF(argb);
1584 DeleteObject(sf->brush.gdibrush);
1585 sf->brush.gdibrush = CreateSolidBrush(sf->brush.lb.lbColor);
1590 /******************************************************************************
1591 * GdipSetTextureTransform [GDIPLUS.@]
1593 GpStatus WINGDIPAPI GdipSetTextureTransform(GpTexture *texture,
1594 GDIPCONST GpMatrix *matrix)
1596 TRACE("(%p, %p)\n", texture, matrix);
1598 if(!texture || !matrix)
1599 return InvalidParameter;
1601 memcpy(texture->transform, matrix, sizeof(GpMatrix));
1606 /******************************************************************************
1607 * GdipSetTextureWrapMode [GDIPLUS.@]
1609 * WrapMode not used, only stored
1611 GpStatus WINGDIPAPI GdipSetTextureWrapMode(GpTexture *brush, GpWrapMode wrapmode)
1613 TRACE("(%p, %d)\n", brush, wrapmode);
1616 return InvalidParameter;
1618 brush->wrap = wrapmode;
1623 GpStatus WINGDIPAPI GdipSetLineColors(GpLineGradient *brush, ARGB color1,
1626 TRACE("(%p, %x, %x)\n", brush, color1, color2);
1629 return InvalidParameter;
1631 brush->startcolor = color1;
1632 brush->endcolor = color2;
1637 GpStatus WINGDIPAPI GdipGetLineColors(GpLineGradient *brush, ARGB *colors)
1639 TRACE("(%p, %p)\n", brush, colors);
1641 if(!brush || !colors)
1642 return InvalidParameter;
1644 colors[0] = brush->startcolor;
1645 colors[1] = brush->endcolor;
1650 /******************************************************************************
1651 * GdipRotateTextureTransform [GDIPLUS.@]
1653 GpStatus WINGDIPAPI GdipRotateTextureTransform(GpTexture* brush, REAL angle,
1654 GpMatrixOrder order)
1656 TRACE("(%p, %.2f, %d)\n", brush, angle, order);
1659 return InvalidParameter;
1661 return GdipRotateMatrix(brush->transform, angle, order);
1664 GpStatus WINGDIPAPI GdipSetLineLinearBlend(GpLineGradient *brush, REAL focus,
1671 TRACE("(%p,%.2f,%.2f)\n", brush, focus, scale);
1673 if (!brush) return InvalidParameter;
1677 factors[num_points] = 0.0;
1678 positions[num_points] = 0.0;
1682 factors[num_points] = scale;
1683 positions[num_points] = focus;
1688 factors[num_points] = 0.0;
1689 positions[num_points] = 1.0;
1693 return GdipSetLineBlend(brush, factors, positions, num_points);
1696 GpStatus WINGDIPAPI GdipSetLinePresetBlend(GpLineGradient *brush,
1697 GDIPCONST ARGB *blend, GDIPCONST REAL* positions, INT count)
1701 TRACE("(%p,%p,%p,%i)\n", brush, blend, positions, count);
1703 if (!brush || !blend || !positions || count < 2 ||
1704 positions[0] != 0.0f || positions[count-1] != 1.0f)
1706 return InvalidParameter;
1709 new_color = GdipAlloc(count * sizeof(ARGB));
1710 new_pos = GdipAlloc(count * sizeof(REAL));
1711 if (!new_color || !new_pos)
1713 GdipFree(new_color);
1718 memcpy(new_color, blend, sizeof(ARGB) * count);
1719 memcpy(new_pos, positions, sizeof(REAL) * count);
1721 GdipFree(brush->pblendcolor);
1722 GdipFree(brush->pblendpos);
1724 brush->pblendcolor = new_color;
1725 brush->pblendpos = new_pos;
1726 brush->pblendcount = count;
1731 GpStatus WINGDIPAPI GdipGetLinePresetBlend(GpLineGradient *brush,
1732 ARGB *blend, REAL* positions, INT count)
1734 if (!brush || !blend || !positions || count < 2)
1735 return InvalidParameter;
1737 if (brush->pblendcount == 0)
1738 return GenericError;
1740 if (count < brush->pblendcount)
1741 return InsufficientBuffer;
1743 memcpy(blend, brush->pblendcolor, sizeof(ARGB) * brush->pblendcount);
1744 memcpy(positions, brush->pblendpos, sizeof(REAL) * brush->pblendcount);
1749 GpStatus WINGDIPAPI GdipGetLinePresetBlendCount(GpLineGradient *brush,
1752 if (!brush || !count)
1753 return InvalidParameter;
1755 *count = brush->pblendcount;
1760 GpStatus WINGDIPAPI GdipResetLineTransform(GpLineGradient *brush)
1764 TRACE("(%p)\n", brush);
1767 FIXME("not implemented\n");
1769 return NotImplemented;
1772 GpStatus WINGDIPAPI GdipSetLineTransform(GpLineGradient *brush,
1773 GDIPCONST GpMatrix *matrix)
1777 TRACE("(%p,%p)\n", brush, matrix);
1780 FIXME("not implemented\n");
1782 return NotImplemented;
1785 GpStatus WINGDIPAPI GdipScaleLineTransform(GpLineGradient *brush, REAL sx, REAL sy,
1786 GpMatrixOrder order)
1790 TRACE("(%p,%0.2f,%0.2f,%u)\n", brush, sx, sy, order);
1793 FIXME("not implemented\n");
1795 return NotImplemented;
1798 GpStatus WINGDIPAPI GdipTranslateLineTransform(GpLineGradient* brush,
1799 REAL dx, REAL dy, GpMatrixOrder order)
1801 FIXME("stub: %p %f %f %d\n", brush, dx, dy, order);
1803 return NotImplemented;
1806 /******************************************************************************
1807 * GdipTranslateTextureTransform [GDIPLUS.@]
1809 GpStatus WINGDIPAPI GdipTranslateTextureTransform(GpTexture* brush, REAL dx, REAL dy,
1810 GpMatrixOrder order)
1812 TRACE("(%p, %.2f, %.2f, %d)\n", brush, dx, dy, order);
1815 return InvalidParameter;
1817 return GdipTranslateMatrix(brush->transform, dx, dy, order);
1820 GpStatus WINGDIPAPI GdipGetLineRect(GpLineGradient *brush, GpRectF *rect)
1822 TRACE("(%p, %p)\n", brush, rect);
1825 return InvalidParameter;
1827 *rect = brush->rect;
1832 GpStatus WINGDIPAPI GdipGetLineRectI(GpLineGradient *brush, GpRect *rect)
1837 TRACE("(%p, %p)\n", brush, rect);
1840 return InvalidParameter;
1842 ret = GdipGetLineRect(brush, &rectF);
1845 rect->X = roundr(rectF.X);
1846 rect->Y = roundr(rectF.Y);
1847 rect->Width = roundr(rectF.Width);
1848 rect->Height = roundr(rectF.Height);
1854 GpStatus WINGDIPAPI GdipRotateLineTransform(GpLineGradient* brush,
1855 REAL angle, GpMatrixOrder order)
1859 TRACE("(%p,%0.2f,%u)\n", brush, angle, order);
1862 return InvalidParameter;
1865 FIXME("(%p, %.2f, %d) stub\n", brush, angle, order);
1867 return NotImplemented;