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:
63 *clone = GdipAlloc(sizeof(GpHatch));
64 if (!*clone) return OutOfMemory;
66 memcpy(*clone, brush, sizeof(GpHatch));
68 (*clone)->gdibrush = CreateBrushIndirect(&(*clone)->lb);
70 case BrushTypePathGradient:{
71 GpPathGradient *src, *dest;
74 *clone = GdipAlloc(sizeof(GpPathGradient));
75 if (!*clone) return OutOfMemory;
77 src = (GpPathGradient*) brush,
78 dest = (GpPathGradient*) *clone;
79 count = src->pathdata.Count;
81 memcpy(dest, src, sizeof(GpPathGradient));
83 dest->pathdata.Count = count;
84 dest->pathdata.Points = GdipAlloc(count * sizeof(PointF));
85 dest->pathdata.Types = GdipAlloc(count);
87 if(!dest->pathdata.Points || !dest->pathdata.Types){
88 GdipFree(dest->pathdata.Points);
89 GdipFree(dest->pathdata.Types);
94 memcpy(dest->pathdata.Points, src->pathdata.Points, count * sizeof(PointF));
95 memcpy(dest->pathdata.Types, src->pathdata.Types, count);
98 count = src->blendcount;
99 dest->blendcount = count;
100 dest->blendfac = GdipAlloc(count * sizeof(REAL));
101 dest->blendpos = GdipAlloc(count * sizeof(REAL));
103 if(!dest->blendfac || !dest->blendpos){
104 GdipFree(dest->pathdata.Points);
105 GdipFree(dest->pathdata.Types);
106 GdipFree(dest->blendfac);
107 GdipFree(dest->blendpos);
112 memcpy(dest->blendfac, src->blendfac, count * sizeof(REAL));
113 memcpy(dest->blendpos, src->blendpos, count * sizeof(REAL));
117 case BrushTypeLinearGradient:{
118 GpLineGradient *dest, *src;
121 dest = GdipAlloc(sizeof(GpLineGradient));
122 if(!dest) return OutOfMemory;
124 src = (GpLineGradient*)brush;
126 memcpy(dest, src, sizeof(GpLineGradient));
128 dest->brush.gdibrush = CreateSolidBrush(dest->brush.lb.lbColor);
130 count = dest->blendcount;
131 dest->blendfac = GdipAlloc(count * sizeof(REAL));
132 dest->blendpos = GdipAlloc(count * sizeof(REAL));
133 pcount = dest->pblendcount;
136 dest->pblendcolor = GdipAlloc(pcount * sizeof(ARGB));
137 dest->pblendpos = GdipAlloc(pcount * sizeof(REAL));
140 if (!dest->blendfac || !dest->blendpos ||
141 (pcount && (!dest->pblendcolor || !dest->pblendpos)))
143 GdipFree(dest->blendfac);
144 GdipFree(dest->blendpos);
145 GdipFree(dest->pblendcolor);
146 GdipFree(dest->pblendpos);
147 DeleteObject(dest->brush.gdibrush);
152 memcpy(dest->blendfac, src->blendfac, count * sizeof(REAL));
153 memcpy(dest->blendpos, src->blendpos, count * sizeof(REAL));
157 memcpy(dest->pblendcolor, src->pblendcolor, pcount * sizeof(ARGB));
158 memcpy(dest->pblendpos, src->pblendpos, pcount * sizeof(REAL));
161 *clone = &dest->brush;
164 case BrushTypeTextureFill:
165 *clone = GdipAlloc(sizeof(GpTexture));
166 if(!*clone) return OutOfMemory;
168 memcpy(*clone, brush, sizeof(GpTexture));
170 (*clone)->gdibrush = CreateBrushIndirect(&(*clone)->lb);
173 ERR("not implemented for brush type %d\n", brush->bt);
174 return NotImplemented;
177 TRACE("<-- %p\n", *clone);
181 static const char HatchBrushes[][8] = {
182 { 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00 }, /* HatchStyleHorizontal */
183 { 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08 }, /* HatchStyleVertical */
184 { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }, /* HatchStyleForwardDiagonal */
185 { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }, /* HatchStyleBackwardDiagonal */
186 { 0x08, 0x08, 0x08, 0xff, 0x08, 0x08, 0x08, 0x08 }, /* HatchStyleCross */
187 { 0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81 }, /* HatchStyleDiagonalCross */
188 { 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x80 }, /* HatchStyle05Percent */
189 { 0x00, 0x02, 0x00, 0x88, 0x00, 0x20, 0x00, 0x88 }, /* HatchStyle10Percent */
190 { 0x00, 0x22, 0x00, 0xcc, 0x00, 0x22, 0x00, 0xcc }, /* HatchStyle20Percent */
191 { 0x00, 0xcc, 0x00, 0xcc, 0x00, 0xcc, 0x00, 0xcc }, /* HatchStyle25Percent */
192 { 0x00, 0xcc, 0x04, 0xcc, 0x00, 0xcc, 0x40, 0xcc }, /* HatchStyle30Percent */
193 { 0x44, 0xcc, 0x22, 0xcc, 0x44, 0xcc, 0x22, 0xcc }, /* HatchStyle40Percent */
194 { 0x55, 0xcc, 0x55, 0xcc, 0x55, 0xcc, 0x55, 0xcc }, /* HatchStyle50Percent */
195 { 0x55, 0xcd, 0x55, 0xee, 0x55, 0xdc, 0x55, 0xee }, /* HatchStyle60Percent */
196 { 0x55, 0xdd, 0x55, 0xff, 0x55, 0xdd, 0x55, 0xff }, /* HatchStyle70Percent */
197 { 0x55, 0xff, 0x55, 0xff, 0x55, 0xff, 0x55, 0xff }, /* HatchStyle75Percent */
198 { 0x55, 0xff, 0x59, 0xff, 0x55, 0xff, 0x99, 0xff }, /* HatchStyle80Percent */
199 { 0x77, 0xff, 0xdd, 0xff, 0x77, 0xff, 0xfd, 0xff }, /* HatchStyle90Percent */
200 { 0x11, 0x22, 0x44, 0x88, 0x11, 0x22, 0x44, 0x88 }, /* HatchStyleLightDownwardDiagonal */
201 { 0x88, 0x44, 0x22, 0x11, 0x88, 0x44, 0x22, 0x11 }, /* HatchStyleLightUpwardDiagonal */
202 { 0x99, 0x33, 0x66, 0xcc, 0x99, 0x33, 0x66, 0xcc }, /* HatchStyleDarkDownwardDiagonal */
203 { 0xcc, 0x66, 0x33, 0x99, 0xcc, 0x66, 0x33, 0x99 }, /* HatchStyleDarkUpwardDiagonal */
204 { 0xc1, 0x83, 0x07, 0x0e, 0x1c, 0x38, 0x70, 0xe0 }, /* HatchStyleWideDownwardDiagonal */
205 { 0xe0, 0x70, 0x38, 0x1c, 0x0e, 0x07, 0x83, 0xc1 }, /* HatchStyleWideUpwardDiagonal */
206 { 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88 }, /* HatchStyleLightVertical */
207 { 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff }, /* HatchStyleLightHorizontal */
208 { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa }, /* HatchStyleNarrowVertical */
209 { 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff }, /* HatchStyleNarrowHorizontal */
210 { 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc }, /* HatchStyleDarkVertical */
211 { 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff }, /* HatchStyleDarkHorizontal */
214 /******************************************************************************
215 * GdipCreateHatchBrush [GDIPLUS.@]
217 GpStatus WINGDIPAPI GdipCreateHatchBrush(HatchStyle hatchstyle, ARGB forecol, ARGB backcol, GpHatch **brush)
219 COLORREF fgcol = ARGB2COLORREF(forecol);
222 TRACE("(%d, %d, %d, %p)\n", hatchstyle, forecol, backcol, brush);
224 if(!brush) return InvalidParameter;
226 *brush = GdipAlloc(sizeof(GpHatch));
227 if (!*brush) return OutOfMemory;
229 if (hatchstyle < sizeof(HatchBrushes) / sizeof(HatchBrushes[0]))
233 BITMAPINFOHEADER bmih;
237 hdc = CreateCompatibleDC(0);
241 bmih.biSize = sizeof(bmih);
245 bmih.biBitCount = 32;
246 bmih.biCompression = BI_RGB;
247 bmih.biSizeImage = 0;
249 hbmp = CreateDIBSection(hdc, (BITMAPINFO*)&bmih, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
255 if ((HatchBrushes[hatchstyle][y] & (0x80 >> x)) != 0)
256 bits[y*8+x] = forecol;
258 bits[y*8+x] = backcol;
270 (*brush)->brush.lb.lbStyle = BS_PATTERN;
271 (*brush)->brush.lb.lbColor = 0;
272 (*brush)->brush.lb.lbHatch = (ULONG_PTR)hbmp;
273 (*brush)->brush.gdibrush = CreateBrushIndirect(&(*brush)->brush.lb);
280 FIXME("Unimplemented hatch style %d\n", hatchstyle);
282 (*brush)->brush.lb.lbStyle = BS_SOLID;
283 (*brush)->brush.lb.lbColor = fgcol;
284 (*brush)->brush.lb.lbHatch = 0;
285 (*brush)->brush.gdibrush = CreateBrushIndirect(&(*brush)->brush.lb);
290 (*brush)->brush.bt = BrushTypeHatchFill;
291 (*brush)->forecol = forecol;
292 (*brush)->backcol = backcol;
293 (*brush)->hatchstyle = hatchstyle;
294 TRACE("<-- %p\n", *brush);
305 /******************************************************************************
306 * GdipCreateLineBrush [GDIPLUS.@]
308 GpStatus WINGDIPAPI GdipCreateLineBrush(GDIPCONST GpPointF* startpoint,
309 GDIPCONST GpPointF* endpoint, ARGB startcolor, ARGB endcolor,
310 GpWrapMode wrap, GpLineGradient **line)
312 COLORREF col = ARGB2COLORREF(startcolor);
314 TRACE("(%s, %s, %x, %x, %d, %p)\n", debugstr_pointf(startpoint),
315 debugstr_pointf(endpoint), startcolor, endcolor, wrap, line);
317 if(!line || !startpoint || !endpoint || wrap == WrapModeClamp)
318 return InvalidParameter;
320 *line = GdipAlloc(sizeof(GpLineGradient));
321 if(!*line) return OutOfMemory;
323 (*line)->brush.lb.lbStyle = BS_SOLID;
324 (*line)->brush.lb.lbColor = col;
325 (*line)->brush.lb.lbHatch = 0;
326 (*line)->brush.gdibrush = CreateSolidBrush(col);
327 (*line)->brush.bt = BrushTypeLinearGradient;
329 (*line)->startpoint.X = startpoint->X;
330 (*line)->startpoint.Y = startpoint->Y;
331 (*line)->endpoint.X = endpoint->X;
332 (*line)->endpoint.Y = endpoint->Y;
333 (*line)->startcolor = startcolor;
334 (*line)->endcolor = endcolor;
335 (*line)->wrap = wrap;
336 (*line)->gamma = FALSE;
338 (*line)->rect.X = (startpoint->X < endpoint->X ? startpoint->X: endpoint->X);
339 (*line)->rect.Y = (startpoint->Y < endpoint->Y ? startpoint->Y: endpoint->Y);
340 (*line)->rect.Width = fabs(startpoint->X - endpoint->X);
341 (*line)->rect.Height = fabs(startpoint->Y - endpoint->Y);
343 if ((*line)->rect.Width == 0)
345 (*line)->rect.X -= (*line)->rect.Height / 2.0f;
346 (*line)->rect.Width = (*line)->rect.Height;
348 else if ((*line)->rect.Height == 0)
350 (*line)->rect.Y -= (*line)->rect.Width / 2.0f;
351 (*line)->rect.Height = (*line)->rect.Width;
354 (*line)->blendcount = 1;
355 (*line)->blendfac = GdipAlloc(sizeof(REAL));
356 (*line)->blendpos = GdipAlloc(sizeof(REAL));
358 if (!(*line)->blendfac || !(*line)->blendpos)
360 GdipFree((*line)->blendfac);
361 GdipFree((*line)->blendpos);
362 DeleteObject((*line)->brush.gdibrush);
368 (*line)->blendfac[0] = 1.0f;
369 (*line)->blendpos[0] = 1.0f;
371 (*line)->pblendcolor = NULL;
372 (*line)->pblendpos = NULL;
373 (*line)->pblendcount = 0;
375 TRACE("<-- %p\n", *line);
380 GpStatus WINGDIPAPI GdipCreateLineBrushI(GDIPCONST GpPoint* startpoint,
381 GDIPCONST GpPoint* endpoint, ARGB startcolor, ARGB endcolor,
382 GpWrapMode wrap, GpLineGradient **line)
387 TRACE("(%p, %p, %x, %x, %d, %p)\n", startpoint, endpoint,
388 startcolor, endcolor, wrap, line);
390 if(!startpoint || !endpoint)
391 return InvalidParameter;
393 stF.X = (REAL)startpoint->X;
394 stF.Y = (REAL)startpoint->Y;
395 endF.X = (REAL)endpoint->X;
396 endF.X = (REAL)endpoint->Y;
398 return GdipCreateLineBrush(&stF, &endF, startcolor, endcolor, wrap, line);
401 GpStatus WINGDIPAPI GdipCreateLineBrushFromRect(GDIPCONST GpRectF* rect,
402 ARGB startcolor, ARGB endcolor, LinearGradientMode mode, GpWrapMode wrap,
403 GpLineGradient **line)
408 TRACE("(%p, %x, %x, %d, %d, %p)\n", rect, startcolor, endcolor, mode,
412 return InvalidParameter;
416 case LinearGradientModeHorizontal:
419 end.X = rect->X + rect->Width;
422 case LinearGradientModeVertical:
426 end.Y = rect->Y + rect->Height;
428 case LinearGradientModeForwardDiagonal:
431 end.X = rect->X + rect->Width;
432 end.Y = rect->Y + rect->Height;
434 case LinearGradientModeBackwardDiagonal:
435 start.X = rect->X + rect->Width;
438 end.Y = rect->Y + rect->Height;
441 return InvalidParameter;
444 stat = GdipCreateLineBrush(&start, &end, startcolor, endcolor, wrap, line);
447 (*line)->rect = *rect;
452 GpStatus WINGDIPAPI GdipCreateLineBrushFromRectI(GDIPCONST GpRect* rect,
453 ARGB startcolor, ARGB endcolor, LinearGradientMode mode, GpWrapMode wrap,
454 GpLineGradient **line)
458 TRACE("(%p, %x, %x, %d, %d, %p)\n", rect, startcolor, endcolor, mode,
461 rectF.X = (REAL) rect->X;
462 rectF.Y = (REAL) rect->Y;
463 rectF.Width = (REAL) rect->Width;
464 rectF.Height = (REAL) rect->Height;
466 return GdipCreateLineBrushFromRect(&rectF, startcolor, endcolor, mode, wrap, line);
469 /******************************************************************************
470 * GdipCreateLineBrushFromRectWithAngle [GDIPLUS.@]
472 * FIXME: angle value completely ignored. Don't know how to use it since native
473 * always set Brush rectangle to rect (independetly of this angle).
474 * Maybe it's used only on drawing.
476 GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngle(GDIPCONST GpRectF* rect,
477 ARGB startcolor, ARGB endcolor, REAL angle, BOOL isAngleScalable, GpWrapMode wrap,
478 GpLineGradient **line)
480 TRACE("(%p, %x, %x, %.2f, %d, %d, %p)\n", rect, startcolor, endcolor, angle, isAngleScalable,
483 return GdipCreateLineBrushFromRect(rect, startcolor, endcolor, LinearGradientModeForwardDiagonal,
487 GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngleI(GDIPCONST GpRect* rect,
488 ARGB startcolor, ARGB endcolor, REAL angle, BOOL isAngleScalable, GpWrapMode wrap,
489 GpLineGradient **line)
491 TRACE("(%p, %x, %x, %.2f, %d, %d, %p)\n", rect, startcolor, endcolor, angle, isAngleScalable,
494 return GdipCreateLineBrushFromRectI(rect, startcolor, endcolor, LinearGradientModeForwardDiagonal,
498 GpStatus WINGDIPAPI GdipCreatePathGradient(GDIPCONST GpPointF* points,
499 INT count, GpWrapMode wrap, GpPathGradient **grad)
501 COLORREF col = ARGB2COLORREF(0xffffffff);
503 TRACE("(%p, %d, %d, %p)\n", points, count, wrap, grad);
506 return InvalidParameter;
511 *grad = GdipAlloc(sizeof(GpPathGradient));
512 if (!*grad) return OutOfMemory;
514 (*grad)->blendfac = GdipAlloc(sizeof(REAL));
515 if(!(*grad)->blendfac){
519 (*grad)->blendfac[0] = 1.0;
520 (*grad)->blendpos = NULL;
521 (*grad)->blendcount = 1;
523 (*grad)->pathdata.Count = count;
524 (*grad)->pathdata.Points = GdipAlloc(count * sizeof(PointF));
525 (*grad)->pathdata.Types = GdipAlloc(count);
527 if(!(*grad)->pathdata.Points || !(*grad)->pathdata.Types){
528 GdipFree((*grad)->pathdata.Points);
529 GdipFree((*grad)->pathdata.Types);
534 memcpy((*grad)->pathdata.Points, points, count * sizeof(PointF));
535 memset((*grad)->pathdata.Types, PathPointTypeLine, count);
537 (*grad)->brush.lb.lbStyle = BS_SOLID;
538 (*grad)->brush.lb.lbColor = col;
539 (*grad)->brush.lb.lbHatch = 0;
541 (*grad)->brush.gdibrush = CreateSolidBrush(col);
542 (*grad)->brush.bt = BrushTypePathGradient;
543 (*grad)->centercolor = 0xffffffff;
544 (*grad)->wrap = wrap;
545 (*grad)->gamma = FALSE;
546 (*grad)->center.X = 0.0;
547 (*grad)->center.Y = 0.0;
548 (*grad)->focus.X = 0.0;
549 (*grad)->focus.Y = 0.0;
551 TRACE("<-- %p\n", *grad);
556 GpStatus WINGDIPAPI GdipCreatePathGradientI(GDIPCONST GpPoint* points,
557 INT count, GpWrapMode wrap, GpPathGradient **grad)
563 TRACE("(%p, %d, %d, %p)\n", points, count, wrap, grad);
566 return InvalidParameter;
571 pointsF = GdipAlloc(sizeof(GpPointF) * count);
575 for(i = 0; i < count; i++){
576 pointsF[i].X = (REAL)points[i].X;
577 pointsF[i].Y = (REAL)points[i].Y;
580 ret = GdipCreatePathGradient(pointsF, count, wrap, grad);
586 /******************************************************************************
587 * GdipCreatePathGradientFromPath [GDIPLUS.@]
589 * FIXME: path gradient brushes not truly supported (drawn as solid brushes)
591 GpStatus WINGDIPAPI GdipCreatePathGradientFromPath(GDIPCONST GpPath* path,
592 GpPathGradient **grad)
594 COLORREF col = ARGB2COLORREF(0xffffffff);
596 TRACE("(%p, %p)\n", path, grad);
599 return InvalidParameter;
601 *grad = GdipAlloc(sizeof(GpPathGradient));
602 if (!*grad) return OutOfMemory;
604 (*grad)->blendfac = GdipAlloc(sizeof(REAL));
605 if(!(*grad)->blendfac){
609 (*grad)->blendfac[0] = 1.0;
610 (*grad)->blendpos = NULL;
611 (*grad)->blendcount = 1;
613 (*grad)->pathdata.Count = path->pathdata.Count;
614 (*grad)->pathdata.Points = GdipAlloc(path->pathdata.Count * sizeof(PointF));
615 (*grad)->pathdata.Types = GdipAlloc(path->pathdata.Count);
617 if(!(*grad)->pathdata.Points || !(*grad)->pathdata.Types){
618 GdipFree((*grad)->pathdata.Points);
619 GdipFree((*grad)->pathdata.Types);
624 memcpy((*grad)->pathdata.Points, path->pathdata.Points,
625 path->pathdata.Count * sizeof(PointF));
626 memcpy((*grad)->pathdata.Types, path->pathdata.Types, path->pathdata.Count);
628 (*grad)->brush.lb.lbStyle = BS_SOLID;
629 (*grad)->brush.lb.lbColor = col;
630 (*grad)->brush.lb.lbHatch = 0;
632 (*grad)->brush.gdibrush = CreateSolidBrush(col);
633 (*grad)->brush.bt = BrushTypePathGradient;
634 (*grad)->centercolor = 0xffffffff;
635 (*grad)->wrap = WrapModeClamp;
636 (*grad)->gamma = FALSE;
637 /* FIXME: this should be set to the "centroid" of the path by default */
638 (*grad)->center.X = 0.0;
639 (*grad)->center.Y = 0.0;
640 (*grad)->focus.X = 0.0;
641 (*grad)->focus.Y = 0.0;
643 TRACE("<-- %p\n", *grad);
648 /******************************************************************************
649 * GdipCreateSolidFill [GDIPLUS.@]
651 GpStatus WINGDIPAPI GdipCreateSolidFill(ARGB color, GpSolidFill **sf)
653 COLORREF col = ARGB2COLORREF(color);
655 TRACE("(%x, %p)\n", color, sf);
657 if(!sf) return InvalidParameter;
659 *sf = GdipAlloc(sizeof(GpSolidFill));
660 if (!*sf) return OutOfMemory;
662 (*sf)->brush.lb.lbStyle = BS_SOLID;
663 (*sf)->brush.lb.lbColor = col;
664 (*sf)->brush.lb.lbHatch = 0;
666 (*sf)->brush.gdibrush = CreateSolidBrush(col);
667 (*sf)->brush.bt = BrushTypeSolidColor;
668 (*sf)->color = color;
669 (*sf)->bmp = ARGB2BMP(color);
671 TRACE("<-- %p\n", *sf);
676 /******************************************************************************
677 * GdipCreateTexture [GDIPLUS.@]
680 * image [I] image to use
681 * wrapmode [I] optional
682 * texture [O] pointer to the resulting texturebrush
686 * FAILURE: element of GpStatus
688 GpStatus WINGDIPAPI GdipCreateTexture(GpImage *image, GpWrapMode wrapmode,
692 GpImageAttributes attributes;
695 TRACE("%p, %d %p\n", image, wrapmode, texture);
697 if (!(image && texture))
698 return InvalidParameter;
700 stat = GdipGetImageWidth(image, &width);
701 if (stat != Ok) return stat;
702 stat = GdipGetImageHeight(image, &height);
703 if (stat != Ok) return stat;
704 attributes.wrap = wrapmode;
706 return GdipCreateTextureIA(image, &attributes, 0, 0, width, height,
710 /******************************************************************************
711 * GdipCreateTexture2 [GDIPLUS.@]
713 GpStatus WINGDIPAPI GdipCreateTexture2(GpImage *image, GpWrapMode wrapmode,
714 REAL x, REAL y, REAL width, REAL height, GpTexture **texture)
716 GpImageAttributes attributes;
718 TRACE("%p %d %f %f %f %f %p\n", image, wrapmode,
719 x, y, width, height, texture);
721 attributes.wrap = wrapmode;
722 return GdipCreateTextureIA(image, &attributes, x, y, width, height,
726 /******************************************************************************
727 * GdipCreateTextureIA [GDIPLUS.@]
729 * FIXME: imageattr ignored
731 GpStatus WINGDIPAPI GdipCreateTextureIA(GpImage *image,
732 GDIPCONST GpImageAttributes *imageattr, REAL x, REAL y, REAL width,
733 REAL height, GpTexture **texture)
736 HBITMAP hbm, old = NULL;
738 BITMAPINFOHEADER *bmih;
739 INT n_x, n_y, n_width, n_height, abs_height, stride, image_stride, i, bytespp;
741 BYTE *dibits, *buff, *textbits;
744 TRACE("(%p, %p, %.2f, %.2f, %.2f, %.2f, %p)\n", image, imageattr, x, y, width, height,
747 if(!image || !texture || x < 0.0 || y < 0.0 || width < 0.0 || height < 0.0)
748 return InvalidParameter;
750 if(image->type != ImageTypeBitmap){
751 FIXME("not implemented for image type %d\n", image->type);
752 return NotImplemented;
757 n_width = roundr(width);
758 n_height = roundr(height);
760 if(n_x + n_width > ((GpBitmap*)image)->width ||
761 n_y + n_height > ((GpBitmap*)image)->height)
762 return InvalidParameter;
764 hbm = ((GpBitmap*)image)->hbitmap;
765 if(!hbm) return GenericError;
766 hdc = ((GpBitmap*)image)->hdc;
767 bm_is_selected = (hdc != 0);
769 pbmi = GdipAlloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
772 pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
773 pbmi->bmiHeader.biBitCount = 0;
776 hdc = CreateCompatibleDC(0);
777 old = SelectObject(hdc, hbm);
781 GetDIBits(hdc, hbm, 0, 0, NULL, pbmi, DIB_RGB_COLORS);
783 bytespp = pbmi->bmiHeader.biBitCount / 8;
784 abs_height = abs(pbmi->bmiHeader.biHeight);
786 if(n_x > pbmi->bmiHeader.biWidth || n_x + n_width > pbmi->bmiHeader.biWidth ||
787 n_y > abs_height || n_y + n_height > abs_height){
789 return InvalidParameter;
792 dibits = GdipAlloc(pbmi->bmiHeader.biSizeImage);
794 if(dibits) /* this is not a good place to error out */
795 GetDIBits(hdc, hbm, 0, abs_height, dibits, pbmi, DIB_RGB_COLORS);
798 SelectObject(hdc, old);
807 image_stride = (pbmi->bmiHeader.biWidth * bytespp + 3) & ~3;
808 stride = (n_width * bytespp + 3) & ~3;
809 buff = GdipAlloc(sizeof(BITMAPINFOHEADER) + stride * n_height);
816 bmih = (BITMAPINFOHEADER*)buff;
817 textbits = (BYTE*) (bmih + 1);
818 bmih->biSize = sizeof(BITMAPINFOHEADER);
819 bmih->biWidth = n_width;
820 bmih->biHeight = n_height;
821 bmih->biCompression = BI_RGB;
822 bmih->biSizeImage = stride * n_height;
823 bmih->biBitCount = pbmi->bmiHeader.biBitCount;
827 /* image is flipped */
828 if(pbmi->bmiHeader.biHeight > 0){
829 dibits += image_stride * (pbmi->bmiHeader.biHeight - 1);
831 textbits += stride * (n_height - 1);
837 for(i = 0; i < n_height; i++)
838 memcpy(&textbits[i * stride],
839 &dibits[n_x * bytespp + (n_y + i) * image_stride],
842 *texture = GdipAlloc(sizeof(GpTexture));
849 if((status = GdipCreateMatrix(&(*texture)->transform)) != Ok){
856 (*texture)->brush.lb.lbStyle = BS_DIBPATTERNPT;
857 (*texture)->brush.lb.lbColor = DIB_RGB_COLORS;
858 (*texture)->brush.lb.lbHatch = (ULONG_PTR)buff;
860 (*texture)->brush.gdibrush = CreateBrushIndirect(&(*texture)->brush.lb);
861 (*texture)->brush.bt = BrushTypeTextureFill;
862 (*texture)->wrap = imageattr->wrap;
867 TRACE("<-- %p\n", *texture);
872 /******************************************************************************
873 * GdipCreateTextureIAI [GDIPLUS.@]
875 GpStatus WINGDIPAPI GdipCreateTextureIAI(GpImage *image, GDIPCONST GpImageAttributes *imageattr,
876 INT x, INT y, INT width, INT height, GpTexture **texture)
878 TRACE("(%p, %p, %d, %d, %d, %d, %p)\n", image, imageattr, x, y, width, height,
881 return GdipCreateTextureIA(image,imageattr,(REAL)x,(REAL)y,(REAL)width,(REAL)height,texture);
884 GpStatus WINGDIPAPI GdipCreateTexture2I(GpImage *image, GpWrapMode wrapmode,
885 INT x, INT y, INT width, INT height, GpTexture **texture)
887 GpImageAttributes imageattr;
889 TRACE("%p %d %d %d %d %d %p\n", image, wrapmode, x, y, width, height,
892 imageattr.wrap = wrapmode;
894 return GdipCreateTextureIA(image, &imageattr, x, y, width, height, texture);
897 GpStatus WINGDIPAPI GdipGetBrushType(GpBrush *brush, GpBrushType *type)
899 TRACE("(%p, %p)\n", brush, type);
901 if(!brush || !type) return InvalidParameter;
908 GpStatus WINGDIPAPI GdipGetHatchBackgroundColor(GpHatch *brush, ARGB *backcol)
910 TRACE("(%p, %p)\n", brush, backcol);
912 if(!brush || !backcol) return InvalidParameter;
914 *backcol = brush->backcol;
919 GpStatus WINGDIPAPI GdipGetHatchForegroundColor(GpHatch *brush, ARGB *forecol)
921 TRACE("(%p, %p)\n", brush, forecol);
923 if(!brush || !forecol) return InvalidParameter;
925 *forecol = brush->forecol;
930 GpStatus WINGDIPAPI GdipGetHatchStyle(GpHatch *brush, HatchStyle *hatchstyle)
932 TRACE("(%p, %p)\n", brush, hatchstyle);
934 if(!brush || !hatchstyle) return InvalidParameter;
936 *hatchstyle = brush->hatchstyle;
941 GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush *brush)
943 TRACE("(%p)\n", brush);
945 if(!brush) return InvalidParameter;
949 case BrushTypePathGradient:
950 GdipFree(((GpPathGradient*) brush)->pathdata.Points);
951 GdipFree(((GpPathGradient*) brush)->pathdata.Types);
952 GdipFree(((GpPathGradient*) brush)->blendfac);
953 GdipFree(((GpPathGradient*) brush)->blendpos);
955 case BrushTypeSolidColor:
956 if (((GpSolidFill*)brush)->bmp)
957 DeleteObject(((GpSolidFill*)brush)->bmp);
959 case BrushTypeLinearGradient:
960 GdipFree(((GpLineGradient*)brush)->blendfac);
961 GdipFree(((GpLineGradient*)brush)->blendpos);
962 GdipFree(((GpLineGradient*)brush)->pblendcolor);
963 GdipFree(((GpLineGradient*)brush)->pblendpos);
965 case BrushTypeTextureFill:
966 GdipDeleteMatrix(((GpTexture*)brush)->transform);
972 DeleteObject(brush->gdibrush);
978 GpStatus WINGDIPAPI GdipGetLineGammaCorrection(GpLineGradient *line,
981 TRACE("(%p, %p)\n", line, usinggamma);
983 if(!line || !usinggamma)
984 return InvalidParameter;
986 *usinggamma = line->gamma;
991 GpStatus WINGDIPAPI GdipGetLineWrapMode(GpLineGradient *brush, GpWrapMode *wrapmode)
993 TRACE("(%p, %p)\n", brush, wrapmode);
995 if(!brush || !wrapmode)
996 return InvalidParameter;
998 *wrapmode = brush->wrap;
1003 GpStatus WINGDIPAPI GdipGetPathGradientBlend(GpPathGradient *brush, REAL *blend,
1004 REAL *positions, INT count)
1006 TRACE("(%p, %p, %p, %d)\n", brush, blend, positions, count);
1008 if(!brush || !blend || !positions || count <= 0)
1009 return InvalidParameter;
1011 if(count < brush->blendcount)
1012 return InsufficientBuffer;
1014 memcpy(blend, brush->blendfac, count*sizeof(REAL));
1015 if(brush->blendcount > 1){
1016 memcpy(positions, brush->blendpos, count*sizeof(REAL));
1022 GpStatus WINGDIPAPI GdipGetPathGradientBlendCount(GpPathGradient *brush, INT *count)
1024 TRACE("(%p, %p)\n", brush, count);
1026 if(!brush || !count)
1027 return InvalidParameter;
1029 *count = brush->blendcount;
1034 GpStatus WINGDIPAPI GdipGetPathGradientCenterPoint(GpPathGradient *grad,
1037 TRACE("(%p, %p)\n", grad, point);
1040 return InvalidParameter;
1042 point->X = grad->center.X;
1043 point->Y = grad->center.Y;
1048 GpStatus WINGDIPAPI GdipGetPathGradientCenterPointI(GpPathGradient *grad,
1054 TRACE("(%p, %p)\n", grad, point);
1057 return InvalidParameter;
1059 ret = GdipGetPathGradientCenterPoint(grad,&ptf);
1062 point->X = roundr(ptf.X);
1063 point->Y = roundr(ptf.Y);
1069 GpStatus WINGDIPAPI GdipGetPathGradientFocusScales(GpPathGradient *grad,
1072 TRACE("(%p, %p, %p)\n", grad, x, y);
1074 if(!grad || !x || !y)
1075 return InvalidParameter;
1083 GpStatus WINGDIPAPI GdipGetPathGradientGammaCorrection(GpPathGradient *grad,
1086 TRACE("(%p, %p)\n", grad, gamma);
1089 return InvalidParameter;
1091 *gamma = grad->gamma;
1096 GpStatus WINGDIPAPI GdipGetPathGradientPointCount(GpPathGradient *grad,
1099 TRACE("(%p, %p)\n", grad, count);
1102 return InvalidParameter;
1104 *count = grad->pathdata.Count;
1109 GpStatus WINGDIPAPI GdipGetPathGradientRect(GpPathGradient *brush, GpRectF *rect)
1115 TRACE("(%p, %p)\n", brush, rect);
1118 return InvalidParameter;
1120 stat = GdipCreatePath2(brush->pathdata.Points, brush->pathdata.Types,
1121 brush->pathdata.Count, FillModeAlternate, &path);
1122 if(stat != Ok) return stat;
1124 stat = GdipGetPathWorldBounds(path, &r, NULL, NULL);
1126 GdipDeletePath(path);
1130 memcpy(rect, &r, sizeof(GpRectF));
1132 GdipDeletePath(path);
1137 GpStatus WINGDIPAPI GdipGetPathGradientRectI(GpPathGradient *brush, GpRect *rect)
1142 TRACE("(%p, %p)\n", brush, rect);
1145 return InvalidParameter;
1147 stat = GdipGetPathGradientRect(brush, &rectf);
1148 if(stat != Ok) return stat;
1150 rect->X = roundr(rectf.X);
1151 rect->Y = roundr(rectf.Y);
1152 rect->Width = roundr(rectf.Width);
1153 rect->Height = roundr(rectf.Height);
1158 GpStatus WINGDIPAPI GdipGetPathGradientSurroundColorsWithCount(GpPathGradient
1159 *grad, ARGB *argb, INT *count)
1163 TRACE("(%p,%p,%p)\n", grad, argb, count);
1165 if(!grad || !argb || !count || (*count < grad->pathdata.Count))
1166 return InvalidParameter;
1169 FIXME("not implemented\n");
1171 return NotImplemented;
1174 GpStatus WINGDIPAPI GdipGetPathGradientWrapMode(GpPathGradient *brush,
1175 GpWrapMode *wrapmode)
1177 TRACE("(%p, %p)\n", brush, wrapmode);
1179 if(!brush || !wrapmode)
1180 return InvalidParameter;
1182 *wrapmode = brush->wrap;
1187 GpStatus WINGDIPAPI GdipGetSolidFillColor(GpSolidFill *sf, ARGB *argb)
1189 TRACE("(%p, %p)\n", sf, argb);
1192 return InvalidParameter;
1199 /******************************************************************************
1200 * GdipGetTextureTransform [GDIPLUS.@]
1202 GpStatus WINGDIPAPI GdipGetTextureTransform(GpTexture *brush, GpMatrix *matrix)
1204 TRACE("(%p, %p)\n", brush, matrix);
1206 if(!brush || !matrix)
1207 return InvalidParameter;
1209 memcpy(matrix, brush->transform, sizeof(GpMatrix));
1214 /******************************************************************************
1215 * GdipGetTextureWrapMode [GDIPLUS.@]
1217 GpStatus WINGDIPAPI GdipGetTextureWrapMode(GpTexture *brush, GpWrapMode *wrapmode)
1219 TRACE("(%p, %p)\n", brush, wrapmode);
1221 if(!brush || !wrapmode)
1222 return InvalidParameter;
1224 *wrapmode = brush->wrap;
1229 /******************************************************************************
1230 * GdipMultiplyTextureTransform [GDIPLUS.@]
1232 GpStatus WINGDIPAPI GdipMultiplyTextureTransform(GpTexture* brush,
1233 GDIPCONST GpMatrix *matrix, GpMatrixOrder order)
1235 TRACE("(%p, %p, %d)\n", brush, matrix, order);
1237 if(!brush || !matrix)
1238 return InvalidParameter;
1240 return GdipMultiplyMatrix(brush->transform, matrix, order);
1243 /******************************************************************************
1244 * GdipResetTextureTransform [GDIPLUS.@]
1246 GpStatus WINGDIPAPI GdipResetTextureTransform(GpTexture* brush)
1248 TRACE("(%p)\n", brush);
1251 return InvalidParameter;
1253 return GdipSetMatrixElements(brush->transform, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
1256 /******************************************************************************
1257 * GdipScaleTextureTransform [GDIPLUS.@]
1259 GpStatus WINGDIPAPI GdipScaleTextureTransform(GpTexture* brush,
1260 REAL sx, REAL sy, GpMatrixOrder order)
1262 TRACE("(%p, %.2f, %.2f, %d)\n", brush, sx, sy, order);
1265 return InvalidParameter;
1267 return GdipScaleMatrix(brush->transform, sx, sy, order);
1270 GpStatus WINGDIPAPI GdipSetLineBlend(GpLineGradient *brush,
1271 GDIPCONST REAL *factors, GDIPCONST REAL* positions, INT count)
1273 REAL *new_blendfac, *new_blendpos;
1275 TRACE("(%p, %p, %p, %i)\n", brush, factors, positions, count);
1277 if(!brush || !factors || !positions || count <= 0 ||
1278 (count >= 2 && (positions[0] != 0.0f || positions[count-1] != 1.0f)))
1279 return InvalidParameter;
1281 new_blendfac = GdipAlloc(count * sizeof(REAL));
1282 new_blendpos = GdipAlloc(count * sizeof(REAL));
1284 if (!new_blendfac || !new_blendpos)
1286 GdipFree(new_blendfac);
1287 GdipFree(new_blendpos);
1291 memcpy(new_blendfac, factors, count * sizeof(REAL));
1292 memcpy(new_blendpos, positions, count * sizeof(REAL));
1294 GdipFree(brush->blendfac);
1295 GdipFree(brush->blendpos);
1297 brush->blendcount = count;
1298 brush->blendfac = new_blendfac;
1299 brush->blendpos = new_blendpos;
1304 GpStatus WINGDIPAPI GdipGetLineBlend(GpLineGradient *brush, REAL *factors,
1305 REAL *positions, INT count)
1307 TRACE("(%p, %p, %p, %i)\n", brush, factors, positions, count);
1309 if (!brush || !factors || !positions || count <= 0)
1310 return InvalidParameter;
1312 if (count < brush->blendcount)
1313 return InsufficientBuffer;
1315 memcpy(factors, brush->blendfac, brush->blendcount * sizeof(REAL));
1316 memcpy(positions, brush->blendpos, brush->blendcount * sizeof(REAL));
1321 GpStatus WINGDIPAPI GdipGetLineBlendCount(GpLineGradient *brush, INT *count)
1323 TRACE("(%p, %p)\n", brush, count);
1325 if (!brush || !count)
1326 return InvalidParameter;
1328 *count = brush->blendcount;
1333 GpStatus WINGDIPAPI GdipSetLineGammaCorrection(GpLineGradient *line,
1336 TRACE("(%p, %d)\n", line, usegamma);
1339 return InvalidParameter;
1341 line->gamma = usegamma;
1346 GpStatus WINGDIPAPI GdipSetLineSigmaBlend(GpLineGradient *line, REAL focus,
1353 const int precision = 16;
1354 REAL erf_range; /* we use values erf(-erf_range) through erf(+erf_range) */
1358 TRACE("(%p, %0.2f, %0.2f)\n", line, focus, scale);
1360 if(!line || focus < 0.0 || focus > 1.0 || scale < 0.0 || scale > 1.0)
1361 return InvalidParameter;
1363 /* we want 2 standard deviations */
1364 erf_range = 2.0 / sqrt(2);
1366 /* calculate the constants we need to normalize the error function to be
1367 between 0.0 and scale over the range we need */
1368 min_erf = erf(-erf_range);
1369 scale_erf = scale / (-2.0 * min_erf);
1375 for (i=1; i<precision; i++)
1377 positions[i] = focus * i / precision;
1378 factors[i] = scale_erf * (erf(2 * erf_range * i / precision - erf_range) - min_erf);
1380 num_points += precision;
1383 positions[num_points] = focus;
1384 factors[num_points] = scale;
1389 for (i=1; i<precision; i++)
1391 positions[i+num_points-1] = (focus + ((1.0-focus) * i / precision));
1392 factors[i+num_points-1] = scale_erf * (erf(erf_range - 2 * erf_range * i / precision) - min_erf);
1394 num_points += precision;
1395 positions[num_points-1] = 1.0;
1396 factors[num_points-1] = 0.0;
1399 return GdipSetLineBlend(line, factors, positions, num_points);
1402 GpStatus WINGDIPAPI GdipSetLineWrapMode(GpLineGradient *line,
1405 TRACE("(%p, %d)\n", line, wrap);
1407 if(!line || wrap == WrapModeClamp)
1408 return InvalidParameter;
1415 GpStatus WINGDIPAPI GdipSetPathGradientBlend(GpPathGradient *brush, GDIPCONST REAL *blend,
1416 GDIPCONST REAL *pos, INT count)
1420 TRACE("(%p,%p,%p,%i)\n", brush, blend, pos, count);
1423 FIXME("not implemented\n");
1425 return NotImplemented;
1428 GpStatus WINGDIPAPI GdipSetPathGradientPresetBlend(GpPathGradient *brush,
1429 GDIPCONST ARGB *blend, GDIPCONST REAL *pos, INT count)
1431 FIXME("(%p,%p,%p,%i): stub\n", brush, blend, pos, count);
1432 return NotImplemented;
1435 GpStatus WINGDIPAPI GdipSetPathGradientCenterColor(GpPathGradient *grad,
1438 TRACE("(%p, %x)\n", grad, argb);
1441 return InvalidParameter;
1443 grad->centercolor = argb;
1444 grad->brush.lb.lbColor = ARGB2COLORREF(argb);
1446 DeleteObject(grad->brush.gdibrush);
1447 grad->brush.gdibrush = CreateSolidBrush(grad->brush.lb.lbColor);
1452 GpStatus WINGDIPAPI GdipSetPathGradientCenterPoint(GpPathGradient *grad,
1455 TRACE("(%p, %s)\n", grad, debugstr_pointf(point));
1458 return InvalidParameter;
1460 grad->center.X = point->X;
1461 grad->center.Y = point->Y;
1466 GpStatus WINGDIPAPI GdipSetPathGradientCenterPointI(GpPathGradient *grad,
1471 TRACE("(%p, %p)\n", grad, point);
1474 return InvalidParameter;
1476 ptf.X = (REAL)point->X;
1477 ptf.Y = (REAL)point->Y;
1479 return GdipSetPathGradientCenterPoint(grad,&ptf);
1482 GpStatus WINGDIPAPI GdipSetPathGradientFocusScales(GpPathGradient *grad,
1485 TRACE("(%p, %.2f, %.2f)\n", grad, x, y);
1488 return InvalidParameter;
1496 GpStatus WINGDIPAPI GdipSetPathGradientGammaCorrection(GpPathGradient *grad,
1499 TRACE("(%p, %d)\n", grad, gamma);
1502 return InvalidParameter;
1504 grad->gamma = gamma;
1509 GpStatus WINGDIPAPI GdipSetPathGradientSigmaBlend(GpPathGradient *grad,
1510 REAL focus, REAL scale)
1514 TRACE("(%p,%0.2f,%0.2f)\n", grad, focus, scale);
1516 if(!grad || focus < 0.0 || focus > 1.0 || scale < 0.0 || scale > 1.0)
1517 return InvalidParameter;
1520 FIXME("not implemented\n");
1522 return NotImplemented;
1525 GpStatus WINGDIPAPI GdipSetPathGradientSurroundColorsWithCount(GpPathGradient
1526 *grad, ARGB *argb, INT *count)
1530 TRACE("(%p,%p,%p)\n", grad, argb, count);
1532 if(!grad || !argb || !count || (*count <= 0) ||
1533 (*count > grad->pathdata.Count))
1534 return InvalidParameter;
1537 FIXME("not implemented\n");
1539 return NotImplemented;
1542 GpStatus WINGDIPAPI GdipSetPathGradientWrapMode(GpPathGradient *grad,
1545 TRACE("(%p, %d)\n", grad, wrap);
1548 return InvalidParameter;
1555 GpStatus WINGDIPAPI GdipSetSolidFillColor(GpSolidFill *sf, ARGB argb)
1557 TRACE("(%p, %x)\n", sf, argb);
1560 return InvalidParameter;
1563 sf->brush.lb.lbColor = ARGB2COLORREF(argb);
1565 DeleteObject(sf->brush.gdibrush);
1566 sf->brush.gdibrush = CreateSolidBrush(sf->brush.lb.lbColor);
1571 /******************************************************************************
1572 * GdipSetTextureTransform [GDIPLUS.@]
1574 GpStatus WINGDIPAPI GdipSetTextureTransform(GpTexture *texture,
1575 GDIPCONST GpMatrix *matrix)
1577 TRACE("(%p, %p)\n", texture, matrix);
1579 if(!texture || !matrix)
1580 return InvalidParameter;
1582 memcpy(texture->transform, matrix, sizeof(GpMatrix));
1587 /******************************************************************************
1588 * GdipSetTextureWrapMode [GDIPLUS.@]
1590 * WrapMode not used, only stored
1592 GpStatus WINGDIPAPI GdipSetTextureWrapMode(GpTexture *brush, GpWrapMode wrapmode)
1594 TRACE("(%p, %d)\n", brush, wrapmode);
1597 return InvalidParameter;
1599 brush->wrap = wrapmode;
1604 GpStatus WINGDIPAPI GdipSetLineColors(GpLineGradient *brush, ARGB color1,
1607 TRACE("(%p, %x, %x)\n", brush, color1, color2);
1610 return InvalidParameter;
1612 brush->startcolor = color1;
1613 brush->endcolor = color2;
1618 GpStatus WINGDIPAPI GdipGetLineColors(GpLineGradient *brush, ARGB *colors)
1620 TRACE("(%p, %p)\n", brush, colors);
1622 if(!brush || !colors)
1623 return InvalidParameter;
1625 colors[0] = brush->startcolor;
1626 colors[1] = brush->endcolor;
1631 /******************************************************************************
1632 * GdipRotateTextureTransform [GDIPLUS.@]
1634 GpStatus WINGDIPAPI GdipRotateTextureTransform(GpTexture* brush, REAL angle,
1635 GpMatrixOrder order)
1637 TRACE("(%p, %.2f, %d)\n", brush, angle, order);
1640 return InvalidParameter;
1642 return GdipRotateMatrix(brush->transform, angle, order);
1645 GpStatus WINGDIPAPI GdipSetLineLinearBlend(GpLineGradient *brush, REAL focus,
1652 TRACE("(%p,%.2f,%.2f)\n", brush, focus, scale);
1654 if (!brush) return InvalidParameter;
1658 factors[num_points] = 0.0;
1659 positions[num_points] = 0.0;
1663 factors[num_points] = scale;
1664 positions[num_points] = focus;
1669 factors[num_points] = 0.0;
1670 positions[num_points] = 1.0;
1674 return GdipSetLineBlend(brush, factors, positions, num_points);
1677 GpStatus WINGDIPAPI GdipSetLinePresetBlend(GpLineGradient *brush,
1678 GDIPCONST ARGB *blend, GDIPCONST REAL* positions, INT count)
1682 TRACE("(%p,%p,%p,%i)\n", brush, blend, positions, count);
1684 if (!brush || !blend || !positions || count < 2 ||
1685 positions[0] != 0.0f || positions[count-1] != 1.0f)
1687 return InvalidParameter;
1690 new_color = GdipAlloc(count * sizeof(ARGB));
1691 new_pos = GdipAlloc(count * sizeof(REAL));
1692 if (!new_color || !new_pos)
1694 GdipFree(new_color);
1699 memcpy(new_color, blend, sizeof(ARGB) * count);
1700 memcpy(new_pos, positions, sizeof(REAL) * count);
1702 GdipFree(brush->pblendcolor);
1703 GdipFree(brush->pblendpos);
1705 brush->pblendcolor = new_color;
1706 brush->pblendpos = new_pos;
1707 brush->pblendcount = count;
1712 GpStatus WINGDIPAPI GdipGetLinePresetBlend(GpLineGradient *brush,
1713 ARGB *blend, REAL* positions, INT count)
1715 if (!brush || !blend || !positions || count < 2)
1716 return InvalidParameter;
1718 if (brush->pblendcount == 0)
1719 return GenericError;
1721 if (count < brush->pblendcount)
1722 return InsufficientBuffer;
1724 memcpy(blend, brush->pblendcolor, sizeof(ARGB) * brush->pblendcount);
1725 memcpy(positions, brush->pblendpos, sizeof(REAL) * brush->pblendcount);
1730 GpStatus WINGDIPAPI GdipGetLinePresetBlendCount(GpLineGradient *brush,
1733 if (!brush || !count)
1734 return InvalidParameter;
1736 *count = brush->pblendcount;
1741 GpStatus WINGDIPAPI GdipResetLineTransform(GpLineGradient *brush)
1745 TRACE("(%p)\n", brush);
1748 FIXME("not implemented\n");
1750 return NotImplemented;
1753 GpStatus WINGDIPAPI GdipSetLineTransform(GpLineGradient *brush,
1754 GDIPCONST GpMatrix *matrix)
1758 TRACE("(%p,%p)\n", brush, matrix);
1761 FIXME("not implemented\n");
1763 return NotImplemented;
1766 GpStatus WINGDIPAPI GdipScaleLineTransform(GpLineGradient *brush, REAL sx, REAL sy,
1767 GpMatrixOrder order)
1771 TRACE("(%p,%0.2f,%0.2f,%u)\n", brush, sx, sy, order);
1774 FIXME("not implemented\n");
1776 return NotImplemented;
1779 GpStatus WINGDIPAPI GdipTranslateLineTransform(GpLineGradient* brush,
1780 REAL dx, REAL dy, GpMatrixOrder order)
1782 FIXME("stub: %p %f %f %d\n", brush, dx, dy, order);
1784 return NotImplemented;
1787 /******************************************************************************
1788 * GdipTranslateTextureTransform [GDIPLUS.@]
1790 GpStatus WINGDIPAPI GdipTranslateTextureTransform(GpTexture* brush, REAL dx, REAL dy,
1791 GpMatrixOrder order)
1793 TRACE("(%p, %.2f, %.2f, %d)\n", brush, dx, dy, order);
1796 return InvalidParameter;
1798 return GdipTranslateMatrix(brush->transform, dx, dy, order);
1801 GpStatus WINGDIPAPI GdipGetLineRect(GpLineGradient *brush, GpRectF *rect)
1803 TRACE("(%p, %p)\n", brush, rect);
1806 return InvalidParameter;
1808 *rect = brush->rect;
1813 GpStatus WINGDIPAPI GdipGetLineRectI(GpLineGradient *brush, GpRect *rect)
1818 TRACE("(%p, %p)\n", brush, rect);
1821 return InvalidParameter;
1823 ret = GdipGetLineRect(brush, &rectF);
1826 rect->X = roundr(rectF.X);
1827 rect->Y = roundr(rectF.Y);
1828 rect->Width = roundr(rectF.Width);
1829 rect->Height = roundr(rectF.Height);
1835 GpStatus WINGDIPAPI GdipRotateLineTransform(GpLineGradient* brush,
1836 REAL angle, GpMatrixOrder order)
1840 TRACE("(%p,%0.2f,%u)\n", brush, angle, order);
1843 return InvalidParameter;
1846 FIXME("(%p, %.2f, %d) stub\n", brush, angle, order);
1848 return NotImplemented;