gdiplus: Add a test for a floating-point triangle.
[wine] / dlls / gdiplus / brush.c
1 /*
2  * Copyright (C) 2007 Google (Evan Stade)
3  *
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.
8  *
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.
13  *
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
17  */
18
19 #include <stdarg.h>
20
21 #include "windef.h"
22 #include "winbase.h"
23 #include "winuser.h"
24 #include "wingdi.h"
25
26 #define COBJMACROS
27 #include "objbase.h"
28 #include "olectl.h"
29 #include "ole2.h"
30
31 #include "gdiplus.h"
32 #include "gdiplus_private.h"
33 #include "wine/debug.h"
34
35 WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
36
37 GpStatus WINGDIPAPI GdipCloneBrush(GpBrush *brush, GpBrush **clone)
38 {
39     if(!brush || !clone)
40         return InvalidParameter;
41
42     switch(brush->bt){
43         case BrushTypeSolidColor:
44             *clone = GdipAlloc(sizeof(GpSolidFill));
45             if (!*clone) return OutOfMemory;
46
47             memcpy(*clone, brush, sizeof(GpSolidFill));
48
49             (*clone)->gdibrush = CreateBrushIndirect(&(*clone)->lb);
50             break;
51         case BrushTypePathGradient:{
52             GpPathGradient *src, *dest;
53             INT count;
54
55             *clone = GdipAlloc(sizeof(GpPathGradient));
56             if (!*clone) return OutOfMemory;
57
58             src = (GpPathGradient*) brush,
59             dest = (GpPathGradient*) *clone;
60             count = src->pathdata.Count;
61
62             memcpy(dest, src, sizeof(GpPathGradient));
63
64             dest->pathdata.Count = count;
65             dest->pathdata.Points = GdipAlloc(count * sizeof(PointF));
66             dest->pathdata.Types = GdipAlloc(count);
67
68             if(!dest->pathdata.Points || !dest->pathdata.Types){
69                 GdipFree(dest->pathdata.Points);
70                 GdipFree(dest->pathdata.Types);
71                 GdipFree(dest);
72                 return OutOfMemory;
73             }
74
75             memcpy(dest->pathdata.Points, src->pathdata.Points, count * sizeof(PointF));
76             memcpy(dest->pathdata.Types, src->pathdata.Types, count);
77
78             break;
79         }
80         case BrushTypeLinearGradient:
81             *clone = GdipAlloc(sizeof(GpLineGradient));
82             if(!*clone)    return OutOfMemory;
83
84             memcpy(*clone, brush, sizeof(GpLineGradient));
85
86             (*clone)->gdibrush = CreateSolidBrush((*clone)->lb.lbColor);
87             break;
88         case BrushTypeTextureFill:
89             *clone = GdipAlloc(sizeof(GpTexture));
90             if(!*clone)    return OutOfMemory;
91
92             memcpy(*clone, brush, sizeof(GpTexture));
93
94             (*clone)->gdibrush = CreateBrushIndirect(&(*clone)->lb);
95             break;
96         default:
97             ERR("not implemented for brush type %d\n", brush->bt);
98             return NotImplemented;
99     }
100
101     return Ok;
102 }
103
104 GpStatus WINGDIPAPI GdipCreateLineBrush(GDIPCONST GpPointF* startpoint,
105     GDIPCONST GpPointF* endpoint, ARGB startcolor, ARGB endcolor,
106     GpWrapMode wrap, GpLineGradient **line)
107 {
108     COLORREF col = ARGB2COLORREF(startcolor);
109
110     if(!line || !startpoint || !endpoint || wrap == WrapModeClamp)
111         return InvalidParameter;
112
113     *line = GdipAlloc(sizeof(GpLineGradient));
114     if(!*line)  return OutOfMemory;
115
116     (*line)->brush.lb.lbStyle = BS_SOLID;
117     (*line)->brush.lb.lbColor = col;
118     (*line)->brush.lb.lbHatch = 0;
119     (*line)->brush.gdibrush = CreateSolidBrush(col);
120     (*line)->brush.bt = BrushTypeLinearGradient;
121
122     (*line)->startpoint.X = startpoint->X;
123     (*line)->startpoint.Y = startpoint->Y;
124     (*line)->endpoint.X = endpoint->X;
125     (*line)->endpoint.Y = endpoint->Y;
126     (*line)->startcolor = startcolor;
127     (*line)->endcolor = endcolor;
128     (*line)->wrap = wrap;
129     (*line)->gamma = FALSE;
130
131     return Ok;
132 }
133
134 GpStatus WINGDIPAPI GdipCreateLineBrushI(GDIPCONST GpPoint* startpoint,
135     GDIPCONST GpPoint* endpoint, ARGB startcolor, ARGB endcolor,
136     GpWrapMode wrap, GpLineGradient **line)
137 {
138     GpPointF stF;
139     GpPointF endF;
140
141     if(!startpoint || !endpoint)
142         return InvalidParameter;
143
144     stF.X  = (REAL)startpoint->X;
145     stF.Y  = (REAL)startpoint->Y;
146     endF.X = (REAL)endpoint->X;
147     endF.X = (REAL)endpoint->Y;
148
149     return GdipCreateLineBrush(&stF, &endF, startcolor, endcolor, wrap, line);
150 }
151
152 GpStatus WINGDIPAPI GdipCreateLineBrushFromRect(GDIPCONST GpRectF* rect,
153     ARGB startcolor, ARGB endcolor, LinearGradientMode mode, GpWrapMode wrap,
154     GpLineGradient **line)
155 {
156     GpPointF start, end;
157
158     if(!line || !rect)
159         return InvalidParameter;
160
161     start.X = rect->X;
162     start.Y = rect->Y;
163     end.X = rect->X + rect->Width;
164     end.Y = rect->Y + rect->Height;
165
166     return GdipCreateLineBrush(&start, &end, startcolor, endcolor, wrap, line);
167 }
168
169 GpStatus WINGDIPAPI GdipCreateLineBrushFromRectI(GDIPCONST GpRect* rect,
170     ARGB startcolor, ARGB endcolor, LinearGradientMode mode, GpWrapMode wrap,
171     GpLineGradient **line)
172 {
173     GpRectF rectF;
174
175     rectF.X      = (REAL) rect->X;
176     rectF.Y      = (REAL) rect->Y;
177     rectF.Width  = (REAL) rect->Width;
178     rectF.Height = (REAL) rect->Height;
179
180     return GdipCreateLineBrushFromRect(&rectF, startcolor, endcolor, mode, wrap, line);
181 }
182
183 /* FIXME: angle value completely ignored. Don't know how to use it since native
184           always set Brush rectangle to rect (independetly of this angle).
185           Maybe it's used only on drawing.  */
186 GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngle(GDIPCONST GpRectF* rect,
187     ARGB startcolor, ARGB endcolor, REAL angle, BOOL isAngleScalable, GpWrapMode wrap,
188     GpLineGradient **line)
189 {
190     return GdipCreateLineBrushFromRect(rect, startcolor, endcolor, LinearGradientModeForwardDiagonal,
191                                        wrap, line);
192 }
193
194 GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngleI(GDIPCONST GpRect* rect,
195     ARGB startcolor, ARGB endcolor, REAL angle, BOOL isAngleScalable, GpWrapMode wrap,
196     GpLineGradient **line)
197 {
198     return GdipCreateLineBrushFromRectI(rect, startcolor, endcolor, LinearGradientModeForwardDiagonal,
199                                         wrap, line);
200 }
201
202 GpStatus WINGDIPAPI GdipCreatePathGradient(GDIPCONST GpPointF* points,
203     INT count, GpWrapMode wrap, GpPathGradient **grad)
204 {
205     COLORREF col = ARGB2COLORREF(0xffffffff);
206
207     if(!points || !grad)
208         return InvalidParameter;
209
210     if(count <= 0)
211         return OutOfMemory;
212
213     *grad = GdipAlloc(sizeof(GpPathGradient));
214     if (!*grad) return OutOfMemory;
215
216     (*grad)->pathdata.Count = count;
217     (*grad)->pathdata.Points = GdipAlloc(count * sizeof(PointF));
218     (*grad)->pathdata.Types = GdipAlloc(count);
219
220     if(!(*grad)->pathdata.Points || !(*grad)->pathdata.Types){
221         GdipFree((*grad)->pathdata.Points);
222         GdipFree((*grad)->pathdata.Types);
223         GdipFree(*grad);
224         return OutOfMemory;
225     }
226
227     memcpy((*grad)->pathdata.Points, points, count * sizeof(PointF));
228     memset((*grad)->pathdata.Types, PathPointTypeLine, count);
229
230     (*grad)->brush.lb.lbStyle = BS_SOLID;
231     (*grad)->brush.lb.lbColor = col;
232     (*grad)->brush.lb.lbHatch = 0;
233
234     (*grad)->brush.gdibrush = CreateSolidBrush(col);
235     (*grad)->brush.bt = BrushTypePathGradient;
236     (*grad)->centercolor = 0xffffffff;
237     (*grad)->wrap = wrap;
238     (*grad)->gamma = FALSE;
239     (*grad)->center.X = 0.0;
240     (*grad)->center.Y = 0.0;
241     (*grad)->focus.X = 0.0;
242     (*grad)->focus.Y = 0.0;
243
244     return Ok;
245 }
246
247 GpStatus WINGDIPAPI GdipCreatePathGradientI(GDIPCONST GpPoint* points,
248     INT count, GpWrapMode wrap, GpPathGradient **grad)
249 {
250     GpPointF *pointsF;
251     GpStatus ret;
252     INT i;
253
254     if(!points || !grad)
255         return InvalidParameter;
256
257     if(count <= 0)
258         return OutOfMemory;
259
260     pointsF = GdipAlloc(sizeof(GpPointF) * count);
261     if(!pointsF)
262         return OutOfMemory;
263
264     for(i = 0; i < count; i++){
265         pointsF[i].X = (REAL)points[i].X;
266         pointsF[i].Y = (REAL)points[i].Y;
267     }
268
269     ret = GdipCreatePathGradient(pointsF, count, wrap, grad);
270     GdipFree(pointsF);
271
272     return ret;
273 }
274
275 /* FIXME: path gradient brushes not truly supported (drawn as solid brushes) */
276 GpStatus WINGDIPAPI GdipCreatePathGradientFromPath(GDIPCONST GpPath* path,
277     GpPathGradient **grad)
278 {
279     COLORREF col = ARGB2COLORREF(0xffffffff);
280
281     if(!path || !grad)
282         return InvalidParameter;
283
284     *grad = GdipAlloc(sizeof(GpPathGradient));
285     if (!*grad) return OutOfMemory;
286
287     (*grad)->pathdata.Count = path->pathdata.Count;
288     (*grad)->pathdata.Points = GdipAlloc(path->pathdata.Count * sizeof(PointF));
289     (*grad)->pathdata.Types = GdipAlloc(path->pathdata.Count);
290
291     if(!(*grad)->pathdata.Points || !(*grad)->pathdata.Types){
292         GdipFree((*grad)->pathdata.Points);
293         GdipFree((*grad)->pathdata.Types);
294         GdipFree(*grad);
295         return OutOfMemory;
296     }
297
298     memcpy((*grad)->pathdata.Points, path->pathdata.Points,
299            path->pathdata.Count * sizeof(PointF));
300     memcpy((*grad)->pathdata.Types, path->pathdata.Types, path->pathdata.Count);
301
302     (*grad)->brush.lb.lbStyle = BS_SOLID;
303     (*grad)->brush.lb.lbColor = col;
304     (*grad)->brush.lb.lbHatch = 0;
305
306     (*grad)->brush.gdibrush = CreateSolidBrush(col);
307     (*grad)->brush.bt = BrushTypePathGradient;
308     (*grad)->centercolor = 0xffffffff;
309     (*grad)->wrap = WrapModeClamp;
310     (*grad)->gamma = FALSE;
311     /* FIXME: this should be set to the "centroid" of the path by default */
312     (*grad)->center.X = 0.0;
313     (*grad)->center.Y = 0.0;
314     (*grad)->focus.X = 0.0;
315     (*grad)->focus.Y = 0.0;
316
317     return Ok;
318 }
319
320 GpStatus WINGDIPAPI GdipCreateSolidFill(ARGB color, GpSolidFill **sf)
321 {
322     COLORREF col = ARGB2COLORREF(color);
323
324     if(!sf)  return InvalidParameter;
325
326     *sf = GdipAlloc(sizeof(GpSolidFill));
327     if (!*sf) return OutOfMemory;
328
329     (*sf)->brush.lb.lbStyle = BS_SOLID;
330     (*sf)->brush.lb.lbColor = col;
331     (*sf)->brush.lb.lbHatch = 0;
332
333     (*sf)->brush.gdibrush = CreateSolidBrush(col);
334     (*sf)->brush.bt = BrushTypeSolidColor;
335     (*sf)->color = color;
336
337     return Ok;
338 }
339
340 /* FIXME: imageattr ignored */
341 GpStatus WINGDIPAPI GdipCreateTextureIA(GpImage *image,
342     GDIPCONST GpImageAttributes *imageattr, REAL x, REAL y, REAL width,
343     REAL height, GpTexture **texture)
344 {
345     HDC hdc;
346     OLE_HANDLE hbm;
347     HBITMAP old = NULL;
348     BITMAPINFO bmi;
349     BITMAPINFOHEADER *bmih;
350     INT n_x, n_y, n_width, n_height, abs_height, stride, image_stride, i, bytespp;
351     BOOL bm_is_selected;
352     BYTE *dibits, *buff, *textbits;
353
354     if(!image || !texture || x < 0.0 || y < 0.0 || width < 0.0 || height < 0.0)
355         return InvalidParameter;
356
357     if(image->type != ImageTypeBitmap){
358         FIXME("not implemented for image type %d\n", image->type);
359         return NotImplemented;
360     }
361
362     n_x = roundr(x);
363     n_y = roundr(y);
364     n_width = roundr(width);
365     n_height = roundr(height);
366
367     if(n_x + n_width > ((GpBitmap*)image)->width ||
368        n_y + n_height > ((GpBitmap*)image)->height)
369         return InvalidParameter;
370
371     IPicture_get_Handle(image->picture, &hbm);
372     if(!hbm)   return GenericError;
373     IPicture_get_CurDC(image->picture, &hdc);
374     bm_is_selected = (hdc != 0);
375
376     bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
377     bmi.bmiHeader.biBitCount = 0;
378
379     if(!bm_is_selected){
380         hdc = CreateCompatibleDC(0);
381         old = SelectObject(hdc, (HBITMAP)hbm);
382     }
383
384     /* fill out bmi */
385     GetDIBits(hdc, (HBITMAP)hbm, 0, 0, NULL, &bmi, DIB_RGB_COLORS);
386
387     bytespp = bmi.bmiHeader.biBitCount / 8;
388     abs_height = abs(bmi.bmiHeader.biHeight);
389
390     if(n_x > bmi.bmiHeader.biWidth || n_x + n_width > bmi.bmiHeader.biWidth ||
391        n_y > abs_height || n_y + n_height > abs_height)
392         return InvalidParameter;
393
394     dibits = GdipAlloc(bmi.bmiHeader.biSizeImage);
395
396     if(dibits)  /* this is not a good place to error out */
397         GetDIBits(hdc, (HBITMAP)hbm, 0, abs_height, dibits, &bmi, DIB_RGB_COLORS);
398
399     if(!bm_is_selected){
400         SelectObject(hdc, old);
401         DeleteDC(hdc);
402     }
403
404     if(!dibits)
405         return OutOfMemory;
406
407     image_stride = (bmi.bmiHeader.biWidth * bytespp + 3) & ~3;
408     stride = (n_width * bytespp + 3) & ~3;
409     buff = GdipAlloc(sizeof(BITMAPINFOHEADER) + stride * n_height);
410     if(!buff){
411         GdipFree(dibits);
412         return OutOfMemory;
413     }
414
415     bmih = (BITMAPINFOHEADER*)buff;
416     textbits = (BYTE*) (bmih + 1);
417     bmih->biSize = sizeof(BITMAPINFOHEADER);
418     bmih->biWidth = n_width;
419     bmih->biHeight = n_height;
420     bmih->biCompression = BI_RGB;
421     bmih->biSizeImage = stride * n_height;
422     bmih->biBitCount = bmi.bmiHeader.biBitCount;
423     bmih->biClrUsed = 0;
424     bmih->biPlanes = 1;
425
426     /* image is flipped */
427     if(bmi.bmiHeader.biHeight > 0){
428         dibits += bmi.bmiHeader.biSizeImage;
429         image_stride *= -1;
430         textbits += stride * (n_height - 1);
431         stride *= -1;
432     }
433
434     for(i = 0; i < n_height; i++)
435         memcpy(&textbits[i * stride],
436                &dibits[n_x * bytespp + (n_y + i) * image_stride],
437                abs(stride));
438
439     *texture = GdipAlloc(sizeof(GpTexture));
440     if (!*texture) return OutOfMemory;
441
442     (*texture)->brush.lb.lbStyle = BS_DIBPATTERNPT;
443     (*texture)->brush.lb.lbColor = DIB_RGB_COLORS;
444     (*texture)->brush.lb.lbHatch = (ULONG_PTR)buff;
445
446     (*texture)->brush.gdibrush = CreateBrushIndirect(&(*texture)->brush.lb);
447     (*texture)->brush.bt = BrushTypeTextureFill;
448
449     GdipFree(dibits);
450     GdipFree(buff);
451
452     return Ok;
453 }
454
455 GpStatus WINGDIPAPI GdipCreateTextureIAI(GpImage *image, GDIPCONST GpImageAttributes *imageattr,
456     INT x, INT y, INT width, INT height, GpTexture **texture)
457 {
458     return GdipCreateTextureIA(image,imageattr,(REAL)x,(REAL)y,(REAL)width,(REAL)height,texture);
459 }
460
461 GpStatus WINGDIPAPI GdipGetBrushType(GpBrush *brush, GpBrushType *type)
462 {
463     if(!brush || !type)  return InvalidParameter;
464
465     *type = brush->bt;
466
467     return Ok;
468 }
469
470 GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush *brush)
471 {
472     if(!brush)  return InvalidParameter;
473
474     switch(brush->bt)
475     {
476         case BrushTypePathGradient:
477             GdipFree(((GpPathGradient*) brush)->pathdata.Points);
478             GdipFree(((GpPathGradient*) brush)->pathdata.Types);
479             break;
480         case BrushTypeSolidColor:
481         case BrushTypeLinearGradient:
482         case BrushTypeTextureFill:
483         default:
484             break;
485     }
486
487     DeleteObject(brush->gdibrush);
488     GdipFree(brush);
489
490     return Ok;
491 }
492
493 GpStatus WINGDIPAPI GdipGetLineGammaCorrection(GpLineGradient *line,
494     BOOL *usinggamma)
495 {
496     if(!line)
497         return InvalidParameter;
498
499     *usinggamma = line->gamma;
500
501     return Ok;
502 }
503
504 GpStatus WINGDIPAPI GdipGetLineWrapMode(GpLineGradient *brush, GpWrapMode *wrapmode)
505 {
506     if(!brush || !wrapmode)
507         return InvalidParameter;
508
509     *wrapmode = brush->wrap;
510
511     return Ok;
512 }
513
514 GpStatus WINGDIPAPI GdipGetPathGradientCenterPoint(GpPathGradient *grad,
515     GpPointF *point)
516 {
517     if(!grad || !point)
518         return InvalidParameter;
519
520     point->X = grad->center.X;
521     point->Y = grad->center.Y;
522
523     return Ok;
524 }
525
526 GpStatus WINGDIPAPI GdipGetPathGradientCenterPointI(GpPathGradient *grad,
527     GpPoint *point)
528 {
529     GpStatus ret;
530     GpPointF ptf;
531
532     if(!point)
533         return InvalidParameter;
534
535     ret = GdipGetPathGradientCenterPoint(grad,&ptf);
536
537     if(ret == Ok){
538         point->X = roundr(ptf.X);
539         point->Y = roundr(ptf.Y);
540     }
541
542     return ret;
543 }
544
545 GpStatus WINGDIPAPI GdipGetPathGradientFocusScales(GpPathGradient *grad,
546     REAL *x, REAL *y)
547 {
548     if(!grad || !x || !y)
549         return InvalidParameter;
550
551     *x = grad->focus.X;
552     *y = grad->focus.Y;
553
554     return Ok;
555 }
556
557 GpStatus WINGDIPAPI GdipGetPathGradientGammaCorrection(GpPathGradient *grad,
558     BOOL *gamma)
559 {
560     if(!grad || !gamma)
561         return InvalidParameter;
562
563     *gamma = grad->gamma;
564
565     return Ok;
566 }
567
568 GpStatus WINGDIPAPI GdipGetPathGradientPointCount(GpPathGradient *grad,
569     INT *count)
570 {
571     if(!grad || !count)
572         return InvalidParameter;
573
574     *count = grad->pathdata.Count;
575
576     return Ok;
577 }
578
579 GpStatus WINGDIPAPI GdipGetPathGradientSurroundColorsWithCount(GpPathGradient
580     *grad, ARGB *argb, INT *count)
581 {
582     static int calls;
583
584     if(!grad || !argb || !count || (*count < grad->pathdata.Count))
585         return InvalidParameter;
586
587     if(!(calls++))
588         FIXME("not implemented\n");
589
590     return NotImplemented;
591 }
592
593 GpStatus WINGDIPAPI GdipGetPathGradientWrapMode(GpPathGradient *brush,
594     GpWrapMode *wrapmode)
595 {
596     if(!brush || !wrapmode)
597         return InvalidParameter;
598
599     *wrapmode = brush->wrap;
600
601     return Ok;
602 }
603
604 GpStatus WINGDIPAPI GdipGetSolidFillColor(GpSolidFill *sf, ARGB *argb)
605 {
606     if(!sf || !argb)
607         return InvalidParameter;
608
609     *argb = sf->color;
610
611     return Ok;
612 }
613
614 GpStatus WINGDIPAPI GdipSetLineBlend(GpLineGradient *brush,
615     GDIPCONST REAL *blend, GDIPCONST REAL* positions, INT count)
616 {
617     static int calls;
618
619     if(!brush || !blend || !positions || count <= 0)
620         return InvalidParameter;
621
622     if(!(calls++))
623         FIXME("not implemented\n");
624
625     return Ok;
626 }
627
628 GpStatus WINGDIPAPI GdipSetLineGammaCorrection(GpLineGradient *line,
629     BOOL usegamma)
630 {
631     if(!line)
632         return InvalidParameter;
633
634     line->gamma = usegamma;
635
636     return Ok;
637 }
638
639 GpStatus WINGDIPAPI GdipSetLineSigmaBlend(GpLineGradient *line, REAL focus,
640     REAL scale)
641 {
642     static int calls;
643
644     if(!line || focus < 0.0 || focus > 1.0 || scale < 0.0 || scale > 1.0)
645         return InvalidParameter;
646
647     if(!(calls++))
648         FIXME("not implemented\n");
649
650     return NotImplemented;
651 }
652
653 GpStatus WINGDIPAPI GdipSetLineWrapMode(GpLineGradient *line,
654     GpWrapMode wrap)
655 {
656     if(!line || wrap == WrapModeClamp)
657         return InvalidParameter;
658
659     line->wrap = wrap;
660
661     return Ok;
662 }
663
664 GpStatus WINGDIPAPI GdipSetPathGradientCenterColor(GpPathGradient *grad,
665     ARGB argb)
666 {
667     if(!grad)
668         return InvalidParameter;
669
670     grad->centercolor = argb;
671     grad->brush.lb.lbColor = ARGB2COLORREF(argb);
672
673     DeleteObject(grad->brush.gdibrush);
674     grad->brush.gdibrush = CreateSolidBrush(grad->brush.lb.lbColor);
675
676     return Ok;
677 }
678
679 GpStatus WINGDIPAPI GdipSetPathGradientCenterPoint(GpPathGradient *grad,
680     GpPointF *point)
681 {
682     if(!grad || !point)
683         return InvalidParameter;
684
685     grad->center.X = point->X;
686     grad->center.Y = point->Y;
687
688     return Ok;
689 }
690
691 GpStatus WINGDIPAPI GdipSetPathGradientCenterPointI(GpPathGradient *grad,
692     GpPoint *point)
693 {
694     GpPointF ptf;
695
696     if(!point)
697         return InvalidParameter;
698
699     ptf.X = (REAL)point->X;
700     ptf.Y = (REAL)point->Y;
701
702     return GdipSetPathGradientCenterPoint(grad,&ptf);
703 }
704
705 GpStatus WINGDIPAPI GdipSetPathGradientFocusScales(GpPathGradient *grad,
706     REAL x, REAL y)
707 {
708     if(!grad)
709         return InvalidParameter;
710
711     grad->focus.X = x;
712     grad->focus.Y = y;
713
714     return Ok;
715 }
716
717 GpStatus WINGDIPAPI GdipSetPathGradientGammaCorrection(GpPathGradient *grad,
718     BOOL gamma)
719 {
720     if(!grad)
721         return InvalidParameter;
722
723     grad->gamma = gamma;
724
725     return Ok;
726 }
727
728 GpStatus WINGDIPAPI GdipSetPathGradientSigmaBlend(GpPathGradient *grad,
729     REAL focus, REAL scale)
730 {
731     static int calls;
732
733     if(!grad || focus < 0.0 || focus > 1.0 || scale < 0.0 || scale > 1.0)
734         return InvalidParameter;
735
736     if(!(calls++))
737         FIXME("not implemented\n");
738
739     return NotImplemented;
740 }
741
742 GpStatus WINGDIPAPI GdipSetPathGradientSurroundColorsWithCount(GpPathGradient
743     *grad, ARGB *argb, INT *count)
744 {
745     static int calls;
746
747     if(!grad || !argb || !count || (*count <= 0) ||
748         (*count > grad->pathdata.Count))
749         return InvalidParameter;
750
751     if(!(calls++))
752         FIXME("not implemented\n");
753
754     return NotImplemented;
755 }
756
757 GpStatus WINGDIPAPI GdipSetPathGradientWrapMode(GpPathGradient *grad,
758     GpWrapMode wrap)
759 {
760     if(!grad)
761         return InvalidParameter;
762
763     grad->wrap = wrap;
764
765     return Ok;
766 }
767
768 GpStatus WINGDIPAPI GdipSetSolidFillColor(GpSolidFill *sf, ARGB argb)
769 {
770     if(!sf)
771         return InvalidParameter;
772
773     sf->color = argb;
774     sf->brush.lb.lbColor = ARGB2COLORREF(argb);
775
776     DeleteObject(sf->brush.gdibrush);
777     sf->brush.gdibrush = CreateSolidBrush(sf->brush.lb.lbColor);
778
779     return Ok;
780 }
781
782 GpStatus WINGDIPAPI GdipSetTextureTransform(GpTexture *texture,
783     GDIPCONST GpMatrix *matrix)
784 {
785     static int calls;
786
787     if(!texture || !matrix)
788         return InvalidParameter;
789
790     if(!(calls++))
791         FIXME("not implemented\n");
792
793     return Ok;
794 }
795
796 GpStatus WINGDIPAPI GdipSetLineColors(GpLineGradient *brush, ARGB color1,
797     ARGB color2)
798 {
799     if(!brush)
800         return InvalidParameter;
801
802     brush->startcolor = color1;
803     brush->endcolor   = color2;
804
805     return Ok;
806 }
807
808 GpStatus WINGDIPAPI GdipGetLineColors(GpLineGradient *brush, ARGB *colors)
809 {
810     if(!brush || !colors)
811         return InvalidParameter;
812
813     colors[0] = brush->startcolor;
814     colors[1] = brush->endcolor;
815
816     return Ok;
817 }
818
819 GpStatus WINGDIPAPI GdipSetLineLinearBlend(GpLineGradient *brush, REAL focus,
820     REAL scale)
821 {
822     static int calls;
823
824     if(!(calls++))
825         FIXME("not implemented\n");
826
827     return NotImplemented;
828 }
829
830 GpStatus WINGDIPAPI GdipSetLinePresetBlend(GpLineGradient *brush,
831     GDIPCONST ARGB *blend, GDIPCONST REAL* positions, INT count)
832 {
833     static int calls;
834
835     if(!(calls++))
836         FIXME("not implemented\n");
837
838     return NotImplemented;
839 }
840
841 GpStatus WINGDIPAPI GdipSetLineTransform(GpLineGradient *brush,
842     GDIPCONST GpMatrix *matrix)
843 {
844     static int calls;
845
846     if(!(calls++))
847         FIXME("not implemented\n");
848
849     return NotImplemented;
850 }
851
852 GpStatus WINGDIPAPI GdipGetLineRect(GpLineGradient *brush, GpRectF *rect)
853 {
854     if(!brush || !rect)
855         return InvalidParameter;
856
857     rect->X = (brush->startpoint.X < brush->endpoint.X ? brush->startpoint.X: brush->endpoint.X);
858     rect->Y = (brush->startpoint.Y < brush->endpoint.Y ? brush->startpoint.Y: brush->endpoint.Y);
859
860     rect->Width  = fabs(brush->startpoint.X - brush->endpoint.X);
861     rect->Height = fabs(brush->startpoint.Y - brush->endpoint.Y);
862
863     return Ok;
864 }
865
866 GpStatus WINGDIPAPI GdipGetLineRectI(GpLineGradient *brush, GpRect *rect)
867 {
868     GpRectF  rectF;
869     GpStatus ret;
870
871     if(!rect)
872         return InvalidParameter;
873
874     ret = GdipGetLineRect(brush, &rectF);
875
876     if(ret == Ok){
877         rect->X      = roundr(rectF.X);
878         rect->Y      = roundr(rectF.Y);
879         rect->Width  = roundr(rectF.Width);
880         rect->Height = roundr(rectF.Height);
881     }
882
883     return ret;
884 }