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;
180 static const char HatchBrushes[][8] = {
181 { 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00 }, /* HatchStyleHorizontal */
182 { 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08 }, /* HatchStyleVertical */
183 { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }, /* HatchStyleForwardDiagonal */
184 { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }, /* HatchStyleBackwardDiagonal */
185 { 0x08, 0x08, 0x08, 0xff, 0x08, 0x08, 0x08, 0x08 }, /* HatchStyleCross */
186 { 0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81 }, /* HatchStyleDiagonalCross */
187 { 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x80 }, /* HatchStyle05Percent */
188 { 0x00, 0x02, 0x00, 0x88, 0x00, 0x20, 0x00, 0x88 }, /* HatchStyle10Percent */
189 { 0x00, 0x22, 0x00, 0xcc, 0x00, 0x22, 0x00, 0xcc }, /* HatchStyle20Percent */
190 { 0x00, 0xcc, 0x00, 0xcc, 0x00, 0xcc, 0x00, 0xcc }, /* HatchStyle25Percent */
191 { 0x00, 0xcc, 0x04, 0xcc, 0x00, 0xcc, 0x40, 0xcc }, /* HatchStyle30Percent */
192 { 0x44, 0xcc, 0x22, 0xcc, 0x44, 0xcc, 0x22, 0xcc }, /* HatchStyle40Percent */
193 { 0x55, 0xcc, 0x55, 0xcc, 0x55, 0xcc, 0x55, 0xcc }, /* HatchStyle50Percent */
194 { 0x55, 0xcd, 0x55, 0xee, 0x55, 0xdc, 0x55, 0xee }, /* HatchStyle60Percent */
195 { 0x55, 0xdd, 0x55, 0xff, 0x55, 0xdd, 0x55, 0xff }, /* HatchStyle70Percent */
196 { 0x55, 0xff, 0x55, 0xff, 0x55, 0xff, 0x55, 0xff }, /* HatchStyle75Percent */
197 { 0x55, 0xff, 0x59, 0xff, 0x55, 0xff, 0x99, 0xff }, /* HatchStyle80Percent */
198 { 0x77, 0xff, 0xdd, 0xff, 0x77, 0xff, 0xfd, 0xff }, /* HatchStyle90Percent */
199 { 0x11, 0x22, 0x44, 0x88, 0x11, 0x22, 0x44, 0x88 }, /* HatchStyleLightDownwardDiagonal */
200 { 0x88, 0x44, 0x22, 0x11, 0x88, 0x44, 0x22, 0x11 }, /* HatchStyleLightUpwardDiagonal */
201 { 0x99, 0x33, 0x66, 0xcc, 0x99, 0x33, 0x66, 0xcc }, /* HatchStyleDarkDownwardDiagonal */
202 { 0xcc, 0x66, 0x33, 0x99, 0xcc, 0x66, 0x33, 0x99 }, /* HatchStyleDarkUpwardDiagonal */
203 { 0xc1, 0x83, 0x07, 0x0e, 0x1c, 0x38, 0x70, 0xe0 }, /* HatchStyleWideDownwardDiagonal */
204 { 0xe0, 0x70, 0x38, 0x1c, 0x0e, 0x07, 0x83, 0xc1 }, /* HatchStyleWideUpwardDiagonal */
205 { 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88 }, /* HatchStyleLightVertical */
206 { 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff }, /* HatchStyleLightHorizontal */
207 { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa }, /* HatchStyleNarrowVertical */
208 { 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff }, /* HatchStyleNarrowHorizontal */
209 { 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc }, /* HatchStyleDarkVertical */
210 { 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff }, /* HatchStyleDarkHorizontal */
213 /******************************************************************************
214 * GdipCreateHatchBrush [GDIPLUS.@]
216 GpStatus WINGDIPAPI GdipCreateHatchBrush(HatchStyle hatchstyle, ARGB forecol, ARGB backcol, GpHatch **brush)
218 COLORREF fgcol = ARGB2COLORREF(forecol);
221 TRACE("(%d, %d, %d, %p)\n", hatchstyle, forecol, backcol, brush);
223 if(!brush) return InvalidParameter;
225 *brush = GdipAlloc(sizeof(GpHatch));
226 if (!*brush) return OutOfMemory;
228 if (hatchstyle < sizeof(HatchBrushes) / sizeof(HatchBrushes[0]))
232 BITMAPINFOHEADER bmih;
236 hdc = CreateCompatibleDC(0);
240 bmih.biSize = sizeof(bmih);
244 bmih.biBitCount = 32;
245 bmih.biCompression = BI_RGB;
246 bmih.biSizeImage = 0;
248 hbmp = CreateDIBSection(hdc, (BITMAPINFO*)&bmih, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
254 if ((HatchBrushes[hatchstyle][y] & (0x80 >> x)) != 0)
255 bits[y*8+x] = forecol;
257 bits[y*8+x] = backcol;
269 (*brush)->brush.lb.lbStyle = BS_PATTERN;
270 (*brush)->brush.lb.lbColor = 0;
271 (*brush)->brush.lb.lbHatch = (ULONG_PTR)hbmp;
272 (*brush)->brush.gdibrush = CreateBrushIndirect(&(*brush)->brush.lb);
279 FIXME("Unimplemented hatch style %d\n", hatchstyle);
281 (*brush)->brush.lb.lbStyle = BS_SOLID;
282 (*brush)->brush.lb.lbColor = fgcol;
283 (*brush)->brush.lb.lbHatch = 0;
284 (*brush)->brush.gdibrush = CreateBrushIndirect(&(*brush)->brush.lb);
289 (*brush)->brush.bt = BrushTypeHatchFill;
290 (*brush)->forecol = forecol;
291 (*brush)->backcol = backcol;
292 (*brush)->hatchstyle = hatchstyle;
303 /******************************************************************************
304 * GdipCreateLineBrush [GDIPLUS.@]
306 GpStatus WINGDIPAPI GdipCreateLineBrush(GDIPCONST GpPointF* startpoint,
307 GDIPCONST GpPointF* endpoint, ARGB startcolor, ARGB endcolor,
308 GpWrapMode wrap, GpLineGradient **line)
310 COLORREF col = ARGB2COLORREF(startcolor);
312 TRACE("(%p, %p, %x, %x, %d, %p)\n", startpoint, endpoint,
313 startcolor, endcolor, wrap, line);
315 if(!line || !startpoint || !endpoint || wrap == WrapModeClamp)
316 return InvalidParameter;
318 *line = GdipAlloc(sizeof(GpLineGradient));
319 if(!*line) return OutOfMemory;
321 (*line)->brush.lb.lbStyle = BS_SOLID;
322 (*line)->brush.lb.lbColor = col;
323 (*line)->brush.lb.lbHatch = 0;
324 (*line)->brush.gdibrush = CreateSolidBrush(col);
325 (*line)->brush.bt = BrushTypeLinearGradient;
327 (*line)->startpoint.X = startpoint->X;
328 (*line)->startpoint.Y = startpoint->Y;
329 (*line)->endpoint.X = endpoint->X;
330 (*line)->endpoint.Y = endpoint->Y;
331 (*line)->startcolor = startcolor;
332 (*line)->endcolor = endcolor;
333 (*line)->wrap = wrap;
334 (*line)->gamma = FALSE;
336 (*line)->rect.X = (startpoint->X < endpoint->X ? startpoint->X: endpoint->X);
337 (*line)->rect.Y = (startpoint->Y < endpoint->Y ? startpoint->Y: endpoint->Y);
338 (*line)->rect.Width = fabs(startpoint->X - endpoint->X);
339 (*line)->rect.Height = fabs(startpoint->Y - endpoint->Y);
341 if ((*line)->rect.Width == 0)
343 (*line)->rect.X -= (*line)->rect.Height / 2.0f;
344 (*line)->rect.Width = (*line)->rect.Height;
346 else if ((*line)->rect.Height == 0)
348 (*line)->rect.Y -= (*line)->rect.Width / 2.0f;
349 (*line)->rect.Height = (*line)->rect.Width;
352 (*line)->blendcount = 1;
353 (*line)->blendfac = GdipAlloc(sizeof(REAL));
354 (*line)->blendpos = GdipAlloc(sizeof(REAL));
356 if (!(*line)->blendfac || !(*line)->blendpos)
358 GdipFree((*line)->blendfac);
359 GdipFree((*line)->blendpos);
360 DeleteObject((*line)->brush.gdibrush);
366 (*line)->blendfac[0] = 1.0f;
367 (*line)->blendpos[0] = 1.0f;
369 (*line)->pblendcolor = NULL;
370 (*line)->pblendpos = NULL;
371 (*line)->pblendcount = 0;
376 GpStatus WINGDIPAPI GdipCreateLineBrushI(GDIPCONST GpPoint* startpoint,
377 GDIPCONST GpPoint* endpoint, ARGB startcolor, ARGB endcolor,
378 GpWrapMode wrap, GpLineGradient **line)
383 TRACE("(%p, %p, %x, %x, %d, %p)\n", startpoint, endpoint,
384 startcolor, endcolor, wrap, line);
386 if(!startpoint || !endpoint)
387 return InvalidParameter;
389 stF.X = (REAL)startpoint->X;
390 stF.Y = (REAL)startpoint->Y;
391 endF.X = (REAL)endpoint->X;
392 endF.X = (REAL)endpoint->Y;
394 return GdipCreateLineBrush(&stF, &endF, startcolor, endcolor, wrap, line);
397 GpStatus WINGDIPAPI GdipCreateLineBrushFromRect(GDIPCONST GpRectF* rect,
398 ARGB startcolor, ARGB endcolor, LinearGradientMode mode, GpWrapMode wrap,
399 GpLineGradient **line)
404 TRACE("(%p, %x, %x, %d, %d, %p)\n", rect, startcolor, endcolor, mode,
408 return InvalidParameter;
412 case LinearGradientModeHorizontal:
415 end.X = rect->X + rect->Width;
418 case LinearGradientModeVertical:
422 end.Y = rect->Y + rect->Height;
424 case LinearGradientModeForwardDiagonal:
427 end.X = rect->X + rect->Width;
428 end.Y = rect->Y + rect->Height;
430 case LinearGradientModeBackwardDiagonal:
431 start.X = rect->X + rect->Width;
434 end.Y = rect->Y + rect->Height;
437 return InvalidParameter;
440 stat = GdipCreateLineBrush(&start, &end, startcolor, endcolor, wrap, line);
443 (*line)->rect = *rect;
448 GpStatus WINGDIPAPI GdipCreateLineBrushFromRectI(GDIPCONST GpRect* rect,
449 ARGB startcolor, ARGB endcolor, LinearGradientMode mode, GpWrapMode wrap,
450 GpLineGradient **line)
454 TRACE("(%p, %x, %x, %d, %d, %p)\n", rect, startcolor, endcolor, mode,
457 rectF.X = (REAL) rect->X;
458 rectF.Y = (REAL) rect->Y;
459 rectF.Width = (REAL) rect->Width;
460 rectF.Height = (REAL) rect->Height;
462 return GdipCreateLineBrushFromRect(&rectF, startcolor, endcolor, mode, wrap, line);
465 /******************************************************************************
466 * GdipCreateLineBrushFromRectWithAngle [GDIPLUS.@]
468 * FIXME: angle value completely ignored. Don't know how to use it since native
469 * always set Brush rectangle to rect (independetly of this angle).
470 * Maybe it's used only on drawing.
472 GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngle(GDIPCONST GpRectF* rect,
473 ARGB startcolor, ARGB endcolor, REAL angle, BOOL isAngleScalable, GpWrapMode wrap,
474 GpLineGradient **line)
476 TRACE("(%p, %x, %x, %.2f, %d, %d, %p)\n", rect, startcolor, endcolor, angle, isAngleScalable,
479 return GdipCreateLineBrushFromRect(rect, startcolor, endcolor, LinearGradientModeForwardDiagonal,
483 GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngleI(GDIPCONST GpRect* rect,
484 ARGB startcolor, ARGB endcolor, REAL angle, BOOL isAngleScalable, GpWrapMode wrap,
485 GpLineGradient **line)
487 TRACE("(%p, %x, %x, %.2f, %d, %d, %p)\n", rect, startcolor, endcolor, angle, isAngleScalable,
490 return GdipCreateLineBrushFromRectI(rect, startcolor, endcolor, LinearGradientModeForwardDiagonal,
494 GpStatus WINGDIPAPI GdipCreatePathGradient(GDIPCONST GpPointF* points,
495 INT count, GpWrapMode wrap, GpPathGradient **grad)
497 COLORREF col = ARGB2COLORREF(0xffffffff);
499 TRACE("(%p, %d, %d, %p)\n", points, count, wrap, grad);
502 return InvalidParameter;
507 *grad = GdipAlloc(sizeof(GpPathGradient));
508 if (!*grad) return OutOfMemory;
510 (*grad)->blendfac = GdipAlloc(sizeof(REAL));
511 if(!(*grad)->blendfac){
515 (*grad)->blendfac[0] = 1.0;
516 (*grad)->blendpos = NULL;
517 (*grad)->blendcount = 1;
519 (*grad)->pathdata.Count = count;
520 (*grad)->pathdata.Points = GdipAlloc(count * sizeof(PointF));
521 (*grad)->pathdata.Types = GdipAlloc(count);
523 if(!(*grad)->pathdata.Points || !(*grad)->pathdata.Types){
524 GdipFree((*grad)->pathdata.Points);
525 GdipFree((*grad)->pathdata.Types);
530 memcpy((*grad)->pathdata.Points, points, count * sizeof(PointF));
531 memset((*grad)->pathdata.Types, PathPointTypeLine, count);
533 (*grad)->brush.lb.lbStyle = BS_SOLID;
534 (*grad)->brush.lb.lbColor = col;
535 (*grad)->brush.lb.lbHatch = 0;
537 (*grad)->brush.gdibrush = CreateSolidBrush(col);
538 (*grad)->brush.bt = BrushTypePathGradient;
539 (*grad)->centercolor = 0xffffffff;
540 (*grad)->wrap = wrap;
541 (*grad)->gamma = FALSE;
542 (*grad)->center.X = 0.0;
543 (*grad)->center.Y = 0.0;
544 (*grad)->focus.X = 0.0;
545 (*grad)->focus.Y = 0.0;
550 GpStatus WINGDIPAPI GdipCreatePathGradientI(GDIPCONST GpPoint* points,
551 INT count, GpWrapMode wrap, GpPathGradient **grad)
557 TRACE("(%p, %d, %d, %p)\n", points, count, wrap, grad);
560 return InvalidParameter;
565 pointsF = GdipAlloc(sizeof(GpPointF) * count);
569 for(i = 0; i < count; i++){
570 pointsF[i].X = (REAL)points[i].X;
571 pointsF[i].Y = (REAL)points[i].Y;
574 ret = GdipCreatePathGradient(pointsF, count, wrap, grad);
580 /******************************************************************************
581 * GdipCreatePathGradientFromPath [GDIPLUS.@]
583 * FIXME: path gradient brushes not truly supported (drawn as solid brushes)
585 GpStatus WINGDIPAPI GdipCreatePathGradientFromPath(GDIPCONST GpPath* path,
586 GpPathGradient **grad)
588 COLORREF col = ARGB2COLORREF(0xffffffff);
590 TRACE("(%p, %p)\n", path, grad);
593 return InvalidParameter;
595 *grad = GdipAlloc(sizeof(GpPathGradient));
596 if (!*grad) return OutOfMemory;
598 (*grad)->blendfac = GdipAlloc(sizeof(REAL));
599 if(!(*grad)->blendfac){
603 (*grad)->blendfac[0] = 1.0;
604 (*grad)->blendpos = NULL;
605 (*grad)->blendcount = 1;
607 (*grad)->pathdata.Count = path->pathdata.Count;
608 (*grad)->pathdata.Points = GdipAlloc(path->pathdata.Count * sizeof(PointF));
609 (*grad)->pathdata.Types = GdipAlloc(path->pathdata.Count);
611 if(!(*grad)->pathdata.Points || !(*grad)->pathdata.Types){
612 GdipFree((*grad)->pathdata.Points);
613 GdipFree((*grad)->pathdata.Types);
618 memcpy((*grad)->pathdata.Points, path->pathdata.Points,
619 path->pathdata.Count * sizeof(PointF));
620 memcpy((*grad)->pathdata.Types, path->pathdata.Types, path->pathdata.Count);
622 (*grad)->brush.lb.lbStyle = BS_SOLID;
623 (*grad)->brush.lb.lbColor = col;
624 (*grad)->brush.lb.lbHatch = 0;
626 (*grad)->brush.gdibrush = CreateSolidBrush(col);
627 (*grad)->brush.bt = BrushTypePathGradient;
628 (*grad)->centercolor = 0xffffffff;
629 (*grad)->wrap = WrapModeClamp;
630 (*grad)->gamma = FALSE;
631 /* FIXME: this should be set to the "centroid" of the path by default */
632 (*grad)->center.X = 0.0;
633 (*grad)->center.Y = 0.0;
634 (*grad)->focus.X = 0.0;
635 (*grad)->focus.Y = 0.0;
640 /******************************************************************************
641 * GdipCreateSolidFill [GDIPLUS.@]
643 GpStatus WINGDIPAPI GdipCreateSolidFill(ARGB color, GpSolidFill **sf)
645 COLORREF col = ARGB2COLORREF(color);
647 TRACE("(%x, %p)\n", color, sf);
649 if(!sf) return InvalidParameter;
651 *sf = GdipAlloc(sizeof(GpSolidFill));
652 if (!*sf) return OutOfMemory;
654 (*sf)->brush.lb.lbStyle = BS_SOLID;
655 (*sf)->brush.lb.lbColor = col;
656 (*sf)->brush.lb.lbHatch = 0;
658 (*sf)->brush.gdibrush = CreateSolidBrush(col);
659 (*sf)->brush.bt = BrushTypeSolidColor;
660 (*sf)->color = color;
661 (*sf)->bmp = ARGB2BMP(color);
666 /******************************************************************************
667 * GdipCreateTexture [GDIPLUS.@]
670 * image [I] image to use
671 * wrapmode [I] optional
672 * texture [O] pointer to the resulting texturebrush
676 * FAILURE: element of GpStatus
678 GpStatus WINGDIPAPI GdipCreateTexture(GpImage *image, GpWrapMode wrapmode,
682 GpImageAttributes attributes;
685 TRACE("%p, %d %p\n", image, wrapmode, texture);
687 if (!(image && texture))
688 return InvalidParameter;
690 stat = GdipGetImageWidth(image, &width);
691 if (stat != Ok) return stat;
692 stat = GdipGetImageHeight(image, &height);
693 if (stat != Ok) return stat;
694 attributes.wrap = wrapmode;
696 return GdipCreateTextureIA(image, &attributes, 0, 0, width, height,
700 /******************************************************************************
701 * GdipCreateTexture2 [GDIPLUS.@]
703 GpStatus WINGDIPAPI GdipCreateTexture2(GpImage *image, GpWrapMode wrapmode,
704 REAL x, REAL y, REAL width, REAL height, GpTexture **texture)
706 GpImageAttributes attributes;
708 TRACE("%p %d %f %f %f %f %p\n", image, wrapmode,
709 x, y, width, height, texture);
711 attributes.wrap = wrapmode;
712 return GdipCreateTextureIA(image, &attributes, x, y, width, height,
716 /******************************************************************************
717 * GdipCreateTextureIA [GDIPLUS.@]
719 * FIXME: imageattr ignored
721 GpStatus WINGDIPAPI GdipCreateTextureIA(GpImage *image,
722 GDIPCONST GpImageAttributes *imageattr, REAL x, REAL y, REAL width,
723 REAL height, GpTexture **texture)
726 HBITMAP hbm, old = NULL;
728 BITMAPINFOHEADER *bmih;
729 INT n_x, n_y, n_width, n_height, abs_height, stride, image_stride, i, bytespp;
731 BYTE *dibits, *buff, *textbits;
734 TRACE("(%p, %p, %.2f, %.2f, %.2f, %.2f, %p)\n", image, imageattr, x, y, width, height,
737 if(!image || !texture || x < 0.0 || y < 0.0 || width < 0.0 || height < 0.0)
738 return InvalidParameter;
740 if(image->type != ImageTypeBitmap){
741 FIXME("not implemented for image type %d\n", image->type);
742 return NotImplemented;
747 n_width = roundr(width);
748 n_height = roundr(height);
750 if(n_x + n_width > ((GpBitmap*)image)->width ||
751 n_y + n_height > ((GpBitmap*)image)->height)
752 return InvalidParameter;
754 hbm = ((GpBitmap*)image)->hbitmap;
755 if(!hbm) return GenericError;
756 hdc = ((GpBitmap*)image)->hdc;
757 bm_is_selected = (hdc != 0);
759 pbmi = GdipAlloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
762 pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
763 pbmi->bmiHeader.biBitCount = 0;
766 hdc = CreateCompatibleDC(0);
767 old = SelectObject(hdc, hbm);
771 GetDIBits(hdc, hbm, 0, 0, NULL, pbmi, DIB_RGB_COLORS);
773 bytespp = pbmi->bmiHeader.biBitCount / 8;
774 abs_height = abs(pbmi->bmiHeader.biHeight);
776 if(n_x > pbmi->bmiHeader.biWidth || n_x + n_width > pbmi->bmiHeader.biWidth ||
777 n_y > abs_height || n_y + n_height > abs_height){
779 return InvalidParameter;
782 dibits = GdipAlloc(pbmi->bmiHeader.biSizeImage);
784 if(dibits) /* this is not a good place to error out */
785 GetDIBits(hdc, hbm, 0, abs_height, dibits, pbmi, DIB_RGB_COLORS);
788 SelectObject(hdc, old);
797 image_stride = (pbmi->bmiHeader.biWidth * bytespp + 3) & ~3;
798 stride = (n_width * bytespp + 3) & ~3;
799 buff = GdipAlloc(sizeof(BITMAPINFOHEADER) + stride * n_height);
806 bmih = (BITMAPINFOHEADER*)buff;
807 textbits = (BYTE*) (bmih + 1);
808 bmih->biSize = sizeof(BITMAPINFOHEADER);
809 bmih->biWidth = n_width;
810 bmih->biHeight = n_height;
811 bmih->biCompression = BI_RGB;
812 bmih->biSizeImage = stride * n_height;
813 bmih->biBitCount = pbmi->bmiHeader.biBitCount;
817 /* image is flipped */
818 if(pbmi->bmiHeader.biHeight > 0){
819 dibits += image_stride * (pbmi->bmiHeader.biHeight - 1);
821 textbits += stride * (n_height - 1);
827 for(i = 0; i < n_height; i++)
828 memcpy(&textbits[i * stride],
829 &dibits[n_x * bytespp + (n_y + i) * image_stride],
832 *texture = GdipAlloc(sizeof(GpTexture));
839 if((status = GdipCreateMatrix(&(*texture)->transform)) != Ok){
846 (*texture)->brush.lb.lbStyle = BS_DIBPATTERNPT;
847 (*texture)->brush.lb.lbColor = DIB_RGB_COLORS;
848 (*texture)->brush.lb.lbHatch = (ULONG_PTR)buff;
850 (*texture)->brush.gdibrush = CreateBrushIndirect(&(*texture)->brush.lb);
851 (*texture)->brush.bt = BrushTypeTextureFill;
852 (*texture)->wrap = imageattr->wrap;
860 /******************************************************************************
861 * GdipCreateTextureIAI [GDIPLUS.@]
863 GpStatus WINGDIPAPI GdipCreateTextureIAI(GpImage *image, GDIPCONST GpImageAttributes *imageattr,
864 INT x, INT y, INT width, INT height, GpTexture **texture)
866 TRACE("(%p, %p, %d, %d, %d, %d, %p)\n", image, imageattr, x, y, width, height,
869 return GdipCreateTextureIA(image,imageattr,(REAL)x,(REAL)y,(REAL)width,(REAL)height,texture);
872 GpStatus WINGDIPAPI GdipCreateTexture2I(GpImage *image, GpWrapMode wrapmode,
873 INT x, INT y, INT width, INT height, GpTexture **texture)
875 GpImageAttributes imageattr;
877 TRACE("%p %d %d %d %d %d %p\n", image, wrapmode, x, y, width, height,
880 imageattr.wrap = wrapmode;
882 return GdipCreateTextureIA(image, &imageattr, x, y, width, height, texture);
885 GpStatus WINGDIPAPI GdipGetBrushType(GpBrush *brush, GpBrushType *type)
887 TRACE("(%p, %p)\n", brush, type);
889 if(!brush || !type) return InvalidParameter;
896 GpStatus WINGDIPAPI GdipGetHatchBackgroundColor(GpHatch *brush, ARGB *backcol)
898 TRACE("(%p, %p)\n", brush, backcol);
900 if(!brush || !backcol) return InvalidParameter;
902 *backcol = brush->backcol;
907 GpStatus WINGDIPAPI GdipGetHatchForegroundColor(GpHatch *brush, ARGB *forecol)
909 TRACE("(%p, %p)\n", brush, forecol);
911 if(!brush || !forecol) return InvalidParameter;
913 *forecol = brush->forecol;
918 GpStatus WINGDIPAPI GdipGetHatchStyle(GpHatch *brush, HatchStyle *hatchstyle)
920 TRACE("(%p, %p)\n", brush, hatchstyle);
922 if(!brush || !hatchstyle) return InvalidParameter;
924 *hatchstyle = brush->hatchstyle;
929 GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush *brush)
931 TRACE("(%p)\n", brush);
933 if(!brush) return InvalidParameter;
937 case BrushTypePathGradient:
938 GdipFree(((GpPathGradient*) brush)->pathdata.Points);
939 GdipFree(((GpPathGradient*) brush)->pathdata.Types);
940 GdipFree(((GpPathGradient*) brush)->blendfac);
941 GdipFree(((GpPathGradient*) brush)->blendpos);
943 case BrushTypeSolidColor:
944 if (((GpSolidFill*)brush)->bmp)
945 DeleteObject(((GpSolidFill*)brush)->bmp);
947 case BrushTypeLinearGradient:
948 GdipFree(((GpLineGradient*)brush)->blendfac);
949 GdipFree(((GpLineGradient*)brush)->blendpos);
950 GdipFree(((GpLineGradient*)brush)->pblendcolor);
951 GdipFree(((GpLineGradient*)brush)->pblendpos);
953 case BrushTypeTextureFill:
954 GdipDeleteMatrix(((GpTexture*)brush)->transform);
960 DeleteObject(brush->gdibrush);
966 GpStatus WINGDIPAPI GdipGetLineGammaCorrection(GpLineGradient *line,
969 TRACE("(%p, %p)\n", line, usinggamma);
971 if(!line || !usinggamma)
972 return InvalidParameter;
974 *usinggamma = line->gamma;
979 GpStatus WINGDIPAPI GdipGetLineWrapMode(GpLineGradient *brush, GpWrapMode *wrapmode)
981 TRACE("(%p, %p)\n", brush, wrapmode);
983 if(!brush || !wrapmode)
984 return InvalidParameter;
986 *wrapmode = brush->wrap;
991 GpStatus WINGDIPAPI GdipGetPathGradientBlend(GpPathGradient *brush, REAL *blend,
992 REAL *positions, INT count)
994 TRACE("(%p, %p, %p, %d)\n", brush, blend, positions, count);
996 if(!brush || !blend || !positions || count <= 0)
997 return InvalidParameter;
999 if(count < brush->blendcount)
1000 return InsufficientBuffer;
1002 memcpy(blend, brush->blendfac, count*sizeof(REAL));
1003 if(brush->blendcount > 1){
1004 memcpy(positions, brush->blendpos, count*sizeof(REAL));
1010 GpStatus WINGDIPAPI GdipGetPathGradientBlendCount(GpPathGradient *brush, INT *count)
1012 TRACE("(%p, %p)\n", brush, count);
1014 if(!brush || !count)
1015 return InvalidParameter;
1017 *count = brush->blendcount;
1022 GpStatus WINGDIPAPI GdipGetPathGradientCenterPoint(GpPathGradient *grad,
1025 TRACE("(%p, %p)\n", grad, point);
1028 return InvalidParameter;
1030 point->X = grad->center.X;
1031 point->Y = grad->center.Y;
1036 GpStatus WINGDIPAPI GdipGetPathGradientCenterPointI(GpPathGradient *grad,
1042 TRACE("(%p, %p)\n", grad, point);
1045 return InvalidParameter;
1047 ret = GdipGetPathGradientCenterPoint(grad,&ptf);
1050 point->X = roundr(ptf.X);
1051 point->Y = roundr(ptf.Y);
1057 GpStatus WINGDIPAPI GdipGetPathGradientFocusScales(GpPathGradient *grad,
1060 TRACE("(%p, %p, %p)\n", grad, x, y);
1062 if(!grad || !x || !y)
1063 return InvalidParameter;
1071 GpStatus WINGDIPAPI GdipGetPathGradientGammaCorrection(GpPathGradient *grad,
1074 TRACE("(%p, %p)\n", grad, gamma);
1077 return InvalidParameter;
1079 *gamma = grad->gamma;
1084 GpStatus WINGDIPAPI GdipGetPathGradientPointCount(GpPathGradient *grad,
1087 TRACE("(%p, %p)\n", grad, count);
1090 return InvalidParameter;
1092 *count = grad->pathdata.Count;
1097 GpStatus WINGDIPAPI GdipGetPathGradientRect(GpPathGradient *brush, GpRectF *rect)
1103 TRACE("(%p, %p)\n", brush, rect);
1106 return InvalidParameter;
1108 stat = GdipCreatePath2(brush->pathdata.Points, brush->pathdata.Types,
1109 brush->pathdata.Count, FillModeAlternate, &path);
1110 if(stat != Ok) return stat;
1112 stat = GdipGetPathWorldBounds(path, &r, NULL, NULL);
1114 GdipDeletePath(path);
1118 memcpy(rect, &r, sizeof(GpRectF));
1120 GdipDeletePath(path);
1125 GpStatus WINGDIPAPI GdipGetPathGradientRectI(GpPathGradient *brush, GpRect *rect)
1130 TRACE("(%p, %p)\n", brush, rect);
1133 return InvalidParameter;
1135 stat = GdipGetPathGradientRect(brush, &rectf);
1136 if(stat != Ok) return stat;
1138 rect->X = roundr(rectf.X);
1139 rect->Y = roundr(rectf.Y);
1140 rect->Width = roundr(rectf.Width);
1141 rect->Height = roundr(rectf.Height);
1146 GpStatus WINGDIPAPI GdipGetPathGradientSurroundColorsWithCount(GpPathGradient
1147 *grad, ARGB *argb, INT *count)
1151 if(!grad || !argb || !count || (*count < grad->pathdata.Count))
1152 return InvalidParameter;
1155 FIXME("not implemented\n");
1157 return NotImplemented;
1160 GpStatus WINGDIPAPI GdipGetPathGradientWrapMode(GpPathGradient *brush,
1161 GpWrapMode *wrapmode)
1163 TRACE("(%p, %p)\n", brush, wrapmode);
1165 if(!brush || !wrapmode)
1166 return InvalidParameter;
1168 *wrapmode = brush->wrap;
1173 GpStatus WINGDIPAPI GdipGetSolidFillColor(GpSolidFill *sf, ARGB *argb)
1175 TRACE("(%p, %p)\n", sf, argb);
1178 return InvalidParameter;
1185 /******************************************************************************
1186 * GdipGetTextureTransform [GDIPLUS.@]
1188 GpStatus WINGDIPAPI GdipGetTextureTransform(GpTexture *brush, GpMatrix *matrix)
1190 TRACE("(%p, %p)\n", brush, matrix);
1192 if(!brush || !matrix)
1193 return InvalidParameter;
1195 memcpy(matrix, brush->transform, sizeof(GpMatrix));
1200 /******************************************************************************
1201 * GdipGetTextureWrapMode [GDIPLUS.@]
1203 GpStatus WINGDIPAPI GdipGetTextureWrapMode(GpTexture *brush, GpWrapMode *wrapmode)
1205 TRACE("(%p, %p)\n", brush, wrapmode);
1207 if(!brush || !wrapmode)
1208 return InvalidParameter;
1210 *wrapmode = brush->wrap;
1215 /******************************************************************************
1216 * GdipMultiplyTextureTransform [GDIPLUS.@]
1218 GpStatus WINGDIPAPI GdipMultiplyTextureTransform(GpTexture* brush,
1219 GDIPCONST GpMatrix *matrix, GpMatrixOrder order)
1221 TRACE("(%p, %p, %d)\n", brush, matrix, order);
1223 if(!brush || !matrix)
1224 return InvalidParameter;
1226 return GdipMultiplyMatrix(brush->transform, matrix, order);
1229 /******************************************************************************
1230 * GdipResetTextureTransform [GDIPLUS.@]
1232 GpStatus WINGDIPAPI GdipResetTextureTransform(GpTexture* brush)
1234 TRACE("(%p)\n", brush);
1237 return InvalidParameter;
1239 return GdipSetMatrixElements(brush->transform, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
1242 /******************************************************************************
1243 * GdipScaleTextureTransform [GDIPLUS.@]
1245 GpStatus WINGDIPAPI GdipScaleTextureTransform(GpTexture* brush,
1246 REAL sx, REAL sy, GpMatrixOrder order)
1248 TRACE("(%p, %.2f, %.2f, %d)\n", brush, sx, sy, order);
1251 return InvalidParameter;
1253 return GdipScaleMatrix(brush->transform, sx, sy, order);
1256 GpStatus WINGDIPAPI GdipSetLineBlend(GpLineGradient *brush,
1257 GDIPCONST REAL *factors, GDIPCONST REAL* positions, INT count)
1259 REAL *new_blendfac, *new_blendpos;
1261 TRACE("(%p, %p, %p, %i)\n", brush, factors, positions, count);
1263 if(!brush || !factors || !positions || count <= 0 ||
1264 (count >= 2 && (positions[0] != 0.0f || positions[count-1] != 1.0f)))
1265 return InvalidParameter;
1267 new_blendfac = GdipAlloc(count * sizeof(REAL));
1268 new_blendpos = GdipAlloc(count * sizeof(REAL));
1270 if (!new_blendfac || !new_blendpos)
1272 GdipFree(new_blendfac);
1273 GdipFree(new_blendpos);
1277 memcpy(new_blendfac, factors, count * sizeof(REAL));
1278 memcpy(new_blendpos, positions, count * sizeof(REAL));
1280 GdipFree(brush->blendfac);
1281 GdipFree(brush->blendpos);
1283 brush->blendcount = count;
1284 brush->blendfac = new_blendfac;
1285 brush->blendpos = new_blendpos;
1290 GpStatus WINGDIPAPI GdipGetLineBlend(GpLineGradient *brush, REAL *factors,
1291 REAL *positions, INT count)
1293 TRACE("(%p, %p, %p, %i)\n", brush, factors, positions, count);
1295 if (!brush || !factors || !positions || count <= 0)
1296 return InvalidParameter;
1298 if (count < brush->blendcount)
1299 return InsufficientBuffer;
1301 memcpy(factors, brush->blendfac, brush->blendcount * sizeof(REAL));
1302 memcpy(positions, brush->blendpos, brush->blendcount * sizeof(REAL));
1307 GpStatus WINGDIPAPI GdipGetLineBlendCount(GpLineGradient *brush, INT *count)
1309 TRACE("(%p, %p)\n", brush, count);
1311 if (!brush || !count)
1312 return InvalidParameter;
1314 *count = brush->blendcount;
1319 GpStatus WINGDIPAPI GdipSetLineGammaCorrection(GpLineGradient *line,
1322 TRACE("(%p, %d)\n", line, usegamma);
1325 return InvalidParameter;
1327 line->gamma = usegamma;
1332 GpStatus WINGDIPAPI GdipSetLineSigmaBlend(GpLineGradient *line, REAL focus,
1339 const int precision = 16;
1340 REAL erf_range; /* we use values erf(-erf_range) through erf(+erf_range) */
1344 TRACE("(%p, %0.2f, %0.2f)\n", line, focus, scale);
1346 if(!line || focus < 0.0 || focus > 1.0 || scale < 0.0 || scale > 1.0)
1347 return InvalidParameter;
1349 /* we want 2 standard deviations */
1350 erf_range = 2.0 / sqrt(2);
1352 /* calculate the constants we need to normalize the error function to be
1353 between 0.0 and scale over the range we need */
1354 min_erf = erf(-erf_range);
1355 scale_erf = scale / (-2.0 * min_erf);
1361 for (i=1; i<precision; i++)
1363 positions[i] = focus * i / precision;
1364 factors[i] = scale_erf * (erf(2 * erf_range * i / precision - erf_range) - min_erf);
1366 num_points += precision;
1369 positions[num_points] = focus;
1370 factors[num_points] = scale;
1375 for (i=1; i<precision; i++)
1377 positions[i+num_points-1] = (focus + ((1.0-focus) * i / precision));
1378 factors[i+num_points-1] = scale_erf * (erf(erf_range - 2 * erf_range * i / precision) - min_erf);
1380 num_points += precision;
1381 positions[num_points-1] = 1.0;
1382 factors[num_points-1] = 0.0;
1385 return GdipSetLineBlend(line, factors, positions, num_points);
1388 GpStatus WINGDIPAPI GdipSetLineWrapMode(GpLineGradient *line,
1391 TRACE("(%p, %d)\n", line, wrap);
1393 if(!line || wrap == WrapModeClamp)
1394 return InvalidParameter;
1401 GpStatus WINGDIPAPI GdipSetPathGradientBlend(GpPathGradient *brush, GDIPCONST REAL *blend,
1402 GDIPCONST REAL *pos, INT count)
1407 FIXME("not implemented\n");
1409 return NotImplemented;
1412 GpStatus WINGDIPAPI GdipSetPathGradientPresetBlend(GpPathGradient *brush,
1413 GDIPCONST ARGB *blend, GDIPCONST REAL *pos, INT count)
1415 FIXME("(%p,%p,%p,%i): stub\n", brush, blend, pos, count);
1416 return NotImplemented;
1419 GpStatus WINGDIPAPI GdipSetPathGradientCenterColor(GpPathGradient *grad,
1422 TRACE("(%p, %x)\n", grad, argb);
1425 return InvalidParameter;
1427 grad->centercolor = argb;
1428 grad->brush.lb.lbColor = ARGB2COLORREF(argb);
1430 DeleteObject(grad->brush.gdibrush);
1431 grad->brush.gdibrush = CreateSolidBrush(grad->brush.lb.lbColor);
1436 GpStatus WINGDIPAPI GdipSetPathGradientCenterPoint(GpPathGradient *grad,
1439 TRACE("(%p, %p)\n", grad, point);
1442 return InvalidParameter;
1444 grad->center.X = point->X;
1445 grad->center.Y = point->Y;
1450 GpStatus WINGDIPAPI GdipSetPathGradientCenterPointI(GpPathGradient *grad,
1455 TRACE("(%p, %p)\n", grad, point);
1458 return InvalidParameter;
1460 ptf.X = (REAL)point->X;
1461 ptf.Y = (REAL)point->Y;
1463 return GdipSetPathGradientCenterPoint(grad,&ptf);
1466 GpStatus WINGDIPAPI GdipSetPathGradientFocusScales(GpPathGradient *grad,
1469 TRACE("(%p, %.2f, %.2f)\n", grad, x, y);
1472 return InvalidParameter;
1480 GpStatus WINGDIPAPI GdipSetPathGradientGammaCorrection(GpPathGradient *grad,
1483 TRACE("(%p, %d)\n", grad, gamma);
1486 return InvalidParameter;
1488 grad->gamma = gamma;
1493 GpStatus WINGDIPAPI GdipSetPathGradientSigmaBlend(GpPathGradient *grad,
1494 REAL focus, REAL scale)
1498 if(!grad || focus < 0.0 || focus > 1.0 || scale < 0.0 || scale > 1.0)
1499 return InvalidParameter;
1502 FIXME("not implemented\n");
1504 return NotImplemented;
1507 GpStatus WINGDIPAPI GdipSetPathGradientSurroundColorsWithCount(GpPathGradient
1508 *grad, ARGB *argb, INT *count)
1512 if(!grad || !argb || !count || (*count <= 0) ||
1513 (*count > grad->pathdata.Count))
1514 return InvalidParameter;
1517 FIXME("not implemented\n");
1519 return NotImplemented;
1522 GpStatus WINGDIPAPI GdipSetPathGradientWrapMode(GpPathGradient *grad,
1525 TRACE("(%p, %d)\n", grad, wrap);
1528 return InvalidParameter;
1535 GpStatus WINGDIPAPI GdipSetSolidFillColor(GpSolidFill *sf, ARGB argb)
1537 TRACE("(%p, %x)\n", sf, argb);
1540 return InvalidParameter;
1543 sf->brush.lb.lbColor = ARGB2COLORREF(argb);
1545 DeleteObject(sf->brush.gdibrush);
1546 sf->brush.gdibrush = CreateSolidBrush(sf->brush.lb.lbColor);
1551 /******************************************************************************
1552 * GdipSetTextureTransform [GDIPLUS.@]
1554 GpStatus WINGDIPAPI GdipSetTextureTransform(GpTexture *texture,
1555 GDIPCONST GpMatrix *matrix)
1557 TRACE("(%p, %p)\n", texture, matrix);
1559 if(!texture || !matrix)
1560 return InvalidParameter;
1562 memcpy(texture->transform, matrix, sizeof(GpMatrix));
1567 /******************************************************************************
1568 * GdipSetTextureWrapMode [GDIPLUS.@]
1570 * WrapMode not used, only stored
1572 GpStatus WINGDIPAPI GdipSetTextureWrapMode(GpTexture *brush, GpWrapMode wrapmode)
1574 TRACE("(%p, %d)\n", brush, wrapmode);
1577 return InvalidParameter;
1579 brush->wrap = wrapmode;
1584 GpStatus WINGDIPAPI GdipSetLineColors(GpLineGradient *brush, ARGB color1,
1587 TRACE("(%p, %x, %x)\n", brush, color1, color2);
1590 return InvalidParameter;
1592 brush->startcolor = color1;
1593 brush->endcolor = color2;
1598 GpStatus WINGDIPAPI GdipGetLineColors(GpLineGradient *brush, ARGB *colors)
1600 TRACE("(%p, %p)\n", brush, colors);
1602 if(!brush || !colors)
1603 return InvalidParameter;
1605 colors[0] = brush->startcolor;
1606 colors[1] = brush->endcolor;
1611 /******************************************************************************
1612 * GdipRotateTextureTransform [GDIPLUS.@]
1614 GpStatus WINGDIPAPI GdipRotateTextureTransform(GpTexture* brush, REAL angle,
1615 GpMatrixOrder order)
1617 TRACE("(%p, %.2f, %d)\n", brush, angle, order);
1620 return InvalidParameter;
1622 return GdipRotateMatrix(brush->transform, angle, order);
1625 GpStatus WINGDIPAPI GdipSetLineLinearBlend(GpLineGradient *brush, REAL focus,
1632 TRACE("(%p,%.2f,%.2f)\n", brush, focus, scale);
1634 if (!brush) return InvalidParameter;
1638 factors[num_points] = 0.0;
1639 positions[num_points] = 0.0;
1643 factors[num_points] = scale;
1644 positions[num_points] = focus;
1649 factors[num_points] = 0.0;
1650 positions[num_points] = 1.0;
1654 return GdipSetLineBlend(brush, factors, positions, num_points);
1657 GpStatus WINGDIPAPI GdipSetLinePresetBlend(GpLineGradient *brush,
1658 GDIPCONST ARGB *blend, GDIPCONST REAL* positions, INT count)
1662 TRACE("(%p,%p,%p,%i)\n", brush, blend, positions, count);
1664 if (!brush || !blend || !positions || count < 2 ||
1665 positions[0] != 0.0f || positions[count-1] != 1.0f)
1667 return InvalidParameter;
1670 new_color = GdipAlloc(count * sizeof(ARGB));
1671 new_pos = GdipAlloc(count * sizeof(REAL));
1672 if (!new_color || !new_pos)
1674 GdipFree(new_color);
1679 memcpy(new_color, blend, sizeof(ARGB) * count);
1680 memcpy(new_pos, positions, sizeof(REAL) * count);
1682 GdipFree(brush->pblendcolor);
1683 GdipFree(brush->pblendpos);
1685 brush->pblendcolor = new_color;
1686 brush->pblendpos = new_pos;
1687 brush->pblendcount = count;
1692 GpStatus WINGDIPAPI GdipGetLinePresetBlend(GpLineGradient *brush,
1693 ARGB *blend, REAL* positions, INT count)
1695 if (!brush || !blend || !positions || count < 2)
1696 return InvalidParameter;
1698 if (brush->pblendcount == 0)
1699 return GenericError;
1701 if (count < brush->pblendcount)
1702 return InsufficientBuffer;
1704 memcpy(blend, brush->pblendcolor, sizeof(ARGB) * brush->pblendcount);
1705 memcpy(positions, brush->pblendpos, sizeof(REAL) * brush->pblendcount);
1710 GpStatus WINGDIPAPI GdipGetLinePresetBlendCount(GpLineGradient *brush,
1713 if (!brush || !count)
1714 return InvalidParameter;
1716 *count = brush->pblendcount;
1721 GpStatus WINGDIPAPI GdipResetLineTransform(GpLineGradient *brush)
1726 FIXME("not implemented\n");
1728 return NotImplemented;
1731 GpStatus WINGDIPAPI GdipSetLineTransform(GpLineGradient *brush,
1732 GDIPCONST GpMatrix *matrix)
1737 FIXME("not implemented\n");
1739 return NotImplemented;
1742 GpStatus WINGDIPAPI GdipScaleLineTransform(GpLineGradient *brush, REAL sx, REAL sy,
1743 GpMatrixOrder order)
1748 FIXME("not implemented\n");
1750 return NotImplemented;
1753 GpStatus WINGDIPAPI GdipTranslateLineTransform(GpLineGradient* brush,
1754 REAL dx, REAL dy, GpMatrixOrder order)
1756 FIXME("stub: %p %f %f %d\n", brush, dx, dy, order);
1758 return NotImplemented;
1761 /******************************************************************************
1762 * GdipTranslateTextureTransform [GDIPLUS.@]
1764 GpStatus WINGDIPAPI GdipTranslateTextureTransform(GpTexture* brush, REAL dx, REAL dy,
1765 GpMatrixOrder order)
1767 TRACE("(%p, %.2f, %.2f, %d)\n", brush, dx, dy, order);
1770 return InvalidParameter;
1772 return GdipTranslateMatrix(brush->transform, dx, dy, order);
1775 GpStatus WINGDIPAPI GdipGetLineRect(GpLineGradient *brush, GpRectF *rect)
1777 TRACE("(%p, %p)\n", brush, rect);
1780 return InvalidParameter;
1782 *rect = brush->rect;
1787 GpStatus WINGDIPAPI GdipGetLineRectI(GpLineGradient *brush, GpRect *rect)
1792 TRACE("(%p, %p)\n", brush, rect);
1795 return InvalidParameter;
1797 ret = GdipGetLineRect(brush, &rectF);
1800 rect->X = roundr(rectF.X);
1801 rect->Y = roundr(rectF.Y);
1802 rect->Width = roundr(rectF.Width);
1803 rect->Height = roundr(rectF.Height);
1809 GpStatus WINGDIPAPI GdipRotateLineTransform(GpLineGradient* brush,
1810 REAL angle, GpMatrixOrder order)
1815 return InvalidParameter;
1818 FIXME("(%p, %.2f, %d) stub\n", brush, angle, order);
1820 return NotImplemented;