brush.c 54.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/*
 * Copyright (C) 2007 Google (Evan Stade)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */

19 20
#include <stdarg.h>

21
#include "windef.h"
22 23
#include "winbase.h"
#include "winuser.h"
24
#include "wingdi.h"
25

26
#define COBJMACROS
27
#include "objbase.h"
28 29
#include "olectl.h"
#include "ole2.h"
30

31 32
#include "gdiplus.h"
#include "gdiplus_private.h"
33 34 35
#include "wine/debug.h"

WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
36

37 38 39
/******************************************************************************
 * GdipCloneBrush [GDIPLUS.@]
 */
40 41
GpStatus WINGDIPAPI GdipCloneBrush(GpBrush *brush, GpBrush **clone)
{
42 43
    TRACE("(%p, %p)\n", brush, clone);

44 45 46
    if(!brush || !clone)
        return InvalidParameter;

47 48
    switch(brush->bt){
        case BrushTypeSolidColor:
49 50
        {
            GpSolidFill *fill;
51 52
            *clone = GdipAlloc(sizeof(GpSolidFill));
            if (!*clone) return OutOfMemory;
53

54 55
            fill = (GpSolidFill*)*clone;

56
            memcpy(*clone, brush, sizeof(GpSolidFill));
57

58
            (*clone)->gdibrush = CreateBrushIndirect(&(*clone)->lb);
59
            fill->bmp = ARGB2BMP(fill->color);
60
            break;
61
        }
62
        case BrushTypeHatchFill:
63 64
        {
            GpHatch *hatch = (GpHatch*)brush;
65

66 67
            return GdipCreateHatchBrush(hatch->hatchstyle, hatch->forecol, hatch->backcol, (GpHatch**)clone);
        }
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
        case BrushTypePathGradient:{
            GpPathGradient *src, *dest;
            INT count;

            *clone = GdipAlloc(sizeof(GpPathGradient));
            if (!*clone) return OutOfMemory;

            src = (GpPathGradient*) brush,
            dest = (GpPathGradient*) *clone;
            count = src->pathdata.Count;

            memcpy(dest, src, sizeof(GpPathGradient));

            dest->pathdata.Count = count;
            dest->pathdata.Points = GdipAlloc(count * sizeof(PointF));
            dest->pathdata.Types = GdipAlloc(count);

            if(!dest->pathdata.Points || !dest->pathdata.Types){
                GdipFree(dest->pathdata.Points);
                GdipFree(dest->pathdata.Types);
                GdipFree(dest);
                return OutOfMemory;
            }

            memcpy(dest->pathdata.Points, src->pathdata.Points, count * sizeof(PointF));
            memcpy(dest->pathdata.Types, src->pathdata.Types, count);

95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
            /* blending */
            count = src->blendcount;
            dest->blendcount = count;
            dest->blendfac = GdipAlloc(count * sizeof(REAL));
            dest->blendpos = GdipAlloc(count * sizeof(REAL));

            if(!dest->blendfac || !dest->blendpos){
                GdipFree(dest->pathdata.Points);
                GdipFree(dest->pathdata.Types);
                GdipFree(dest->blendfac);
                GdipFree(dest->blendpos);
                GdipFree(dest);
                return OutOfMemory;
            }

            memcpy(dest->blendfac, src->blendfac, count * sizeof(REAL));
            memcpy(dest->blendpos, src->blendpos, count * sizeof(REAL));

113 114
            break;
        }
115 116
        case BrushTypeLinearGradient:{
            GpLineGradient *dest, *src;
117
            INT count, pcount;
118 119 120 121 122 123 124 125 126 127 128 129 130

            dest = GdipAlloc(sizeof(GpLineGradient));
            if(!dest)    return OutOfMemory;

            src = (GpLineGradient*)brush;

            memcpy(dest, src, sizeof(GpLineGradient));

            dest->brush.gdibrush = CreateSolidBrush(dest->brush.lb.lbColor);

            count = dest->blendcount;
            dest->blendfac = GdipAlloc(count * sizeof(REAL));
            dest->blendpos = GdipAlloc(count * sizeof(REAL));
131 132 133 134 135 136
            pcount = dest->pblendcount;
            if (pcount)
            {
                dest->pblendcolor = GdipAlloc(pcount * sizeof(ARGB));
                dest->pblendpos = GdipAlloc(pcount * sizeof(REAL));
            }
137

138 139
            if (!dest->blendfac || !dest->blendpos ||
                (pcount && (!dest->pblendcolor || !dest->pblendpos)))
140 141 142
            {
                GdipFree(dest->blendfac);
                GdipFree(dest->blendpos);
143 144
                GdipFree(dest->pblendcolor);
                GdipFree(dest->pblendpos);
145 146 147 148
                DeleteObject(dest->brush.gdibrush);
                GdipFree(dest);
                return OutOfMemory;
            }
149

150 151
            memcpy(dest->blendfac, src->blendfac, count * sizeof(REAL));
            memcpy(dest->blendpos, src->blendpos, count * sizeof(REAL));
152

153 154 155 156 157 158
            if (pcount)
            {
                memcpy(dest->pblendcolor, src->pblendcolor, pcount * sizeof(ARGB));
                memcpy(dest->pblendpos, src->pblendpos, pcount * sizeof(REAL));
            }

159
            *clone = &dest->brush;
160
            break;
161
        }
162
        case BrushTypeTextureFill:
163 164 165 166
        {
            GpStatus stat;
            GpTexture *texture = (GpTexture*)brush;
            GpTexture *new_texture;
167
            UINT width, height;
168

169 170 171 172 173 174
            stat = GdipGetImageWidth(texture->image, &width);
            if (stat != Ok) return stat;
            stat = GdipGetImageHeight(texture->image, &height);
            if (stat != Ok) return stat;

            stat = GdipCreateTextureIA(texture->image, texture->imageattributes, 0, 0, width, height, &new_texture);
175

176 177 178 179 180 181 182 183 184 185
            if (stat == Ok)
            {
                memcpy(new_texture->transform, texture->transform, sizeof(GpMatrix));
                *clone = (GpBrush*)new_texture;
            }
            else
                *clone = NULL;

            return stat;
        }
186
        default:
187
            ERR("not implemented for brush type %d\n", brush->bt);
188 189
            return NotImplemented;
    }
190

191
    TRACE("<-- %p\n", *clone);
192 193 194
    return Ok;
}

195 196 197 198 199 200 201
static const char HatchBrushes[][8] = {
    { 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00 }, /* HatchStyleHorizontal */
    { 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08 }, /* HatchStyleVertical */
    { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }, /* HatchStyleForwardDiagonal */
    { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }, /* HatchStyleBackwardDiagonal */
    { 0x08, 0x08, 0x08, 0xff, 0x08, 0x08, 0x08, 0x08 }, /* HatchStyleCross */
    { 0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81 }, /* HatchStyleDiagonalCross */
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
    { 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x80 }, /* HatchStyle05Percent */
    { 0x00, 0x02, 0x00, 0x88, 0x00, 0x20, 0x00, 0x88 }, /* HatchStyle10Percent */
    { 0x00, 0x22, 0x00, 0xcc, 0x00, 0x22, 0x00, 0xcc }, /* HatchStyle20Percent */
    { 0x00, 0xcc, 0x00, 0xcc, 0x00, 0xcc, 0x00, 0xcc }, /* HatchStyle25Percent */
    { 0x00, 0xcc, 0x04, 0xcc, 0x00, 0xcc, 0x40, 0xcc }, /* HatchStyle30Percent */
    { 0x44, 0xcc, 0x22, 0xcc, 0x44, 0xcc, 0x22, 0xcc }, /* HatchStyle40Percent */
    { 0x55, 0xcc, 0x55, 0xcc, 0x55, 0xcc, 0x55, 0xcc }, /* HatchStyle50Percent */
    { 0x55, 0xcd, 0x55, 0xee, 0x55, 0xdc, 0x55, 0xee }, /* HatchStyle60Percent */
    { 0x55, 0xdd, 0x55, 0xff, 0x55, 0xdd, 0x55, 0xff }, /* HatchStyle70Percent */
    { 0x55, 0xff, 0x55, 0xff, 0x55, 0xff, 0x55, 0xff }, /* HatchStyle75Percent */
    { 0x55, 0xff, 0x59, 0xff, 0x55, 0xff, 0x99, 0xff }, /* HatchStyle80Percent */
    { 0x77, 0xff, 0xdd, 0xff, 0x77, 0xff, 0xfd, 0xff }, /* HatchStyle90Percent */
    { 0x11, 0x22, 0x44, 0x88, 0x11, 0x22, 0x44, 0x88 }, /* HatchStyleLightDownwardDiagonal */
    { 0x88, 0x44, 0x22, 0x11, 0x88, 0x44, 0x22, 0x11 }, /* HatchStyleLightUpwardDiagonal */
    { 0x99, 0x33, 0x66, 0xcc, 0x99, 0x33, 0x66, 0xcc }, /* HatchStyleDarkDownwardDiagonal */
    { 0xcc, 0x66, 0x33, 0x99, 0xcc, 0x66, 0x33, 0x99 }, /* HatchStyleDarkUpwardDiagonal */
    { 0xc1, 0x83, 0x07, 0x0e, 0x1c, 0x38, 0x70, 0xe0 }, /* HatchStyleWideDownwardDiagonal */
    { 0xe0, 0x70, 0x38, 0x1c, 0x0e, 0x07, 0x83, 0xc1 }, /* HatchStyleWideUpwardDiagonal */
    { 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88 }, /* HatchStyleLightVertical */
    { 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff }, /* HatchStyleLightHorizontal */
    { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa }, /* HatchStyleNarrowVertical */
    { 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff }, /* HatchStyleNarrowHorizontal */
    { 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc }, /* HatchStyleDarkVertical */
    { 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff }, /* HatchStyleDarkHorizontal */
226
};
227

228 229 230 231 232 233 234 235 236 237 238
GpStatus get_hatch_data(HatchStyle hatchstyle, const char **result)
{
    if (hatchstyle < sizeof(HatchBrushes) / sizeof(HatchBrushes[0]))
    {
        *result = HatchBrushes[hatchstyle];
        return Ok;
    }
    else
        return NotImplemented;
}

239 240 241
/******************************************************************************
 * GdipCreateHatchBrush [GDIPLUS.@]
 */
242
GpStatus WINGDIPAPI GdipCreateHatchBrush(HatchStyle hatchstyle, ARGB forecol, ARGB backcol, GpHatch **brush)
243 244
{
    COLORREF fgcol = ARGB2COLORREF(forecol);
245
    GpStatus stat = Ok;
246 247 248 249 250 251 252 253

    TRACE("(%d, %d, %d, %p)\n", hatchstyle, forecol, backcol, brush);

    if(!brush)  return InvalidParameter;

    *brush = GdipAlloc(sizeof(GpHatch));
    if (!*brush) return OutOfMemory;

254
    if (hatchstyle < sizeof(HatchBrushes) / sizeof(HatchBrushes[0]))
255
    {
256 257 258 259 260
        HBITMAP hbmp;
        HDC hdc;
        BITMAPINFOHEADER bmih;
        DWORD* bits;
        int x, y;
261

262
        hdc = CreateCompatibleDC(0);
263

264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301
        if (hdc)
        {
            bmih.biSize = sizeof(bmih);
            bmih.biWidth = 8;
            bmih.biHeight = 8;
            bmih.biPlanes = 1;
            bmih.biBitCount = 32;
            bmih.biCompression = BI_RGB;
            bmih.biSizeImage = 0;

            hbmp = CreateDIBSection(hdc, (BITMAPINFO*)&bmih, DIB_RGB_COLORS, (void**)&bits, NULL, 0);

            if (hbmp)
            {
                for (y=0; y<8; y++)
                    for (x=0; x<8; x++)
                        if ((HatchBrushes[hatchstyle][y] & (0x80 >> x)) != 0)
                            bits[y*8+x] = forecol;
                        else
                            bits[y*8+x] = backcol;
            }
            else
                stat = GenericError;

            DeleteDC(hdc);
        }
        else
            stat = GenericError;

        if (stat == Ok)
        {
            (*brush)->brush.lb.lbStyle = BS_PATTERN;
            (*brush)->brush.lb.lbColor = 0;
            (*brush)->brush.lb.lbHatch = (ULONG_PTR)hbmp;
            (*brush)->brush.gdibrush = CreateBrushIndirect(&(*brush)->brush.lb);

            DeleteObject(hbmp);
        }
302
    }
303 304 305
    else
    {
        FIXME("Unimplemented hatch style %d\n", hatchstyle);
306

307 308 309 310 311
        (*brush)->brush.lb.lbStyle = BS_SOLID;
        (*brush)->brush.lb.lbColor = fgcol;
        (*brush)->brush.lb.lbHatch = 0;
        (*brush)->brush.gdibrush = CreateBrushIndirect(&(*brush)->brush.lb);
    }
312

313 314 315 316 317 318
    if (stat == Ok)
    {
        (*brush)->brush.bt = BrushTypeHatchFill;
        (*brush)->forecol = forecol;
        (*brush)->backcol = backcol;
        (*brush)->hatchstyle = hatchstyle;
319
        TRACE("<-- %p\n", *brush);
320 321 322 323 324 325
    }
    else
    {
        GdipFree(*brush);
        *brush = NULL;
    }
326

327
    return stat;
328 329
}

330 331 332
/******************************************************************************
 * GdipCreateLineBrush [GDIPLUS.@]
 */
333 334 335 336 337 338
GpStatus WINGDIPAPI GdipCreateLineBrush(GDIPCONST GpPointF* startpoint,
    GDIPCONST GpPointF* endpoint, ARGB startcolor, ARGB endcolor,
    GpWrapMode wrap, GpLineGradient **line)
{
    COLORREF col = ARGB2COLORREF(startcolor);

339 340
    TRACE("(%s, %s, %x, %x, %d, %p)\n", debugstr_pointf(startpoint),
          debugstr_pointf(endpoint), startcolor, endcolor, wrap, line);
341

342
    if(!line || !startpoint || !endpoint || wrap == WrapModeClamp)
343 344
        return InvalidParameter;

345 346 347
    if (startpoint->X == endpoint->X && startpoint->Y == endpoint->Y)
        return OutOfMemory;

348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363
    *line = GdipAlloc(sizeof(GpLineGradient));
    if(!*line)  return OutOfMemory;

    (*line)->brush.lb.lbStyle = BS_SOLID;
    (*line)->brush.lb.lbColor = col;
    (*line)->brush.lb.lbHatch = 0;
    (*line)->brush.gdibrush = CreateSolidBrush(col);
    (*line)->brush.bt = BrushTypeLinearGradient;

    (*line)->startpoint.X = startpoint->X;
    (*line)->startpoint.Y = startpoint->Y;
    (*line)->endpoint.X = endpoint->X;
    (*line)->endpoint.Y = endpoint->Y;
    (*line)->startcolor = startcolor;
    (*line)->endcolor = endcolor;
    (*line)->wrap = wrap;
364
    (*line)->gamma = FALSE;
365

366 367 368 369 370
    (*line)->rect.X = (startpoint->X < endpoint->X ? startpoint->X: endpoint->X);
    (*line)->rect.Y = (startpoint->Y < endpoint->Y ? startpoint->Y: endpoint->Y);
    (*line)->rect.Width  = fabs(startpoint->X - endpoint->X);
    (*line)->rect.Height = fabs(startpoint->Y - endpoint->Y);

371 372 373 374 375 376 377 378 379 380 381
    if ((*line)->rect.Width == 0)
    {
        (*line)->rect.X -= (*line)->rect.Height / 2.0f;
        (*line)->rect.Width = (*line)->rect.Height;
    }
    else if ((*line)->rect.Height == 0)
    {
        (*line)->rect.Y -= (*line)->rect.Width / 2.0f;
        (*line)->rect.Height = (*line)->rect.Width;
    }

382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398
    (*line)->blendcount = 1;
    (*line)->blendfac = GdipAlloc(sizeof(REAL));
    (*line)->blendpos = GdipAlloc(sizeof(REAL));

    if (!(*line)->blendfac || !(*line)->blendpos)
    {
        GdipFree((*line)->blendfac);
        GdipFree((*line)->blendpos);
        DeleteObject((*line)->brush.gdibrush);
        GdipFree(*line);
        *line = NULL;
        return OutOfMemory;
    }

    (*line)->blendfac[0] = 1.0f;
    (*line)->blendpos[0] = 1.0f;

399 400 401 402
    (*line)->pblendcolor = NULL;
    (*line)->pblendpos = NULL;
    (*line)->pblendcount = 0;

403 404
    TRACE("<-- %p\n", *line);

405 406 407
    return Ok;
}

408 409 410 411 412 413 414
GpStatus WINGDIPAPI GdipCreateLineBrushI(GDIPCONST GpPoint* startpoint,
    GDIPCONST GpPoint* endpoint, ARGB startcolor, ARGB endcolor,
    GpWrapMode wrap, GpLineGradient **line)
{
    GpPointF stF;
    GpPointF endF;

415 416 417
    TRACE("(%p, %p, %x, %x, %d, %p)\n", startpoint, endpoint,
          startcolor, endcolor, wrap, line);

418 419 420 421 422 423
    if(!startpoint || !endpoint)
        return InvalidParameter;

    stF.X  = (REAL)startpoint->X;
    stF.Y  = (REAL)startpoint->Y;
    endF.X = (REAL)endpoint->X;
424
    endF.Y = (REAL)endpoint->Y;
425 426 427 428

    return GdipCreateLineBrush(&stF, &endF, startcolor, endcolor, wrap, line);
}

429
GpStatus WINGDIPAPI GdipCreateLineBrushFromRect(GDIPCONST GpRectF* rect,
430 431 432 433
    ARGB startcolor, ARGB endcolor, LinearGradientMode mode, GpWrapMode wrap,
    GpLineGradient **line)
{
    GpPointF start, end;
434
    GpStatus stat;
435

436 437 438
    TRACE("(%p, %x, %x, %d, %d, %p)\n", rect, startcolor, endcolor, mode,
          wrap, line);

439 440 441
    if(!line || !rect)
        return InvalidParameter;

442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470
    switch (mode)
    {
    case LinearGradientModeHorizontal:
        start.X = rect->X;
        start.Y = rect->Y;
        end.X = rect->X + rect->Width;
        end.Y = rect->Y;
        break;
    case LinearGradientModeVertical:
        start.X = rect->X;
        start.Y = rect->Y;
        end.X = rect->X;
        end.Y = rect->Y + rect->Height;
        break;
    case LinearGradientModeForwardDiagonal:
        start.X = rect->X;
        start.Y = rect->Y;
        end.X = rect->X + rect->Width;
        end.Y = rect->Y + rect->Height;
        break;
    case LinearGradientModeBackwardDiagonal:
        start.X = rect->X + rect->Width;
        start.Y = rect->Y;
        end.X = rect->X;
        end.Y = rect->Y + rect->Height;
        break;
    default:
        return InvalidParameter;
    }
471

472 473 474 475 476 477
    stat = GdipCreateLineBrush(&start, &end, startcolor, endcolor, wrap, line);

    if (stat == Ok)
        (*line)->rect = *rect;

    return stat;
478 479
}

480 481 482 483 484 485
GpStatus WINGDIPAPI GdipCreateLineBrushFromRectI(GDIPCONST GpRect* rect,
    ARGB startcolor, ARGB endcolor, LinearGradientMode mode, GpWrapMode wrap,
    GpLineGradient **line)
{
    GpRectF rectF;

486 487 488
    TRACE("(%p, %x, %x, %d, %d, %p)\n", rect, startcolor, endcolor, mode,
          wrap, line);

489 490 491 492 493 494 495 496
    rectF.X      = (REAL) rect->X;
    rectF.Y      = (REAL) rect->Y;
    rectF.Width  = (REAL) rect->Width;
    rectF.Height = (REAL) rect->Height;

    return GdipCreateLineBrushFromRect(&rectF, startcolor, endcolor, mode, wrap, line);
}

497 498 499
/******************************************************************************
 * GdipCreateLineBrushFromRectWithAngle [GDIPLUS.@]
 */
500 501 502 503
GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngle(GDIPCONST GpRectF* rect,
    ARGB startcolor, ARGB endcolor, REAL angle, BOOL isAngleScalable, GpWrapMode wrap,
    GpLineGradient **line)
{
504 505 506 507 508
    GpStatus stat;
    LinearGradientMode mode;
    REAL width, height, exofs, eyofs;
    REAL sin_angle, cos_angle, sin_cos_angle;

509 510 511
    TRACE("(%p, %x, %x, %.2f, %d, %d, %p)\n", rect, startcolor, endcolor, angle, isAngleScalable,
          wrap, line);

512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566
    sin_angle = sinf(deg2rad(angle));
    cos_angle = cosf(deg2rad(angle));
    sin_cos_angle = sin_angle * cos_angle;

    if (isAngleScalable)
    {
        width = height = 1.0;
    }
    else
    {
        width = rect->Width;
        height = rect->Height;
    }

    if (sin_cos_angle >= 0)
        mode = LinearGradientModeForwardDiagonal;
    else
        mode = LinearGradientModeBackwardDiagonal;

    stat = GdipCreateLineBrushFromRect(rect, startcolor, endcolor, mode, wrap, line);

    if (stat == Ok)
    {
        if (sin_cos_angle >= 0)
        {
            exofs = width * sin_cos_angle + height * cos_angle * cos_angle;
            eyofs = width * sin_angle * sin_angle + height * sin_cos_angle;
        }
        else
        {
            exofs = width * sin_angle * sin_angle + height * sin_cos_angle;
            eyofs = -width * sin_cos_angle + height * sin_angle * sin_angle;
        }

        if (isAngleScalable)
        {
            exofs = exofs * rect->Width;
            eyofs = eyofs * rect->Height;
        }

        if (sin_angle >= 0)
        {
            (*line)->endpoint.X = rect->X + exofs;
            (*line)->endpoint.Y = rect->Y + eyofs;
        }
        else
        {
            (*line)->endpoint.X = (*line)->startpoint.X;
            (*line)->endpoint.Y = (*line)->startpoint.Y;
            (*line)->startpoint.X = rect->X + exofs;
            (*line)->startpoint.Y = rect->Y + eyofs;
        }
    }

    return stat;
567 568 569 570 571 572
}

GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngleI(GDIPCONST GpRect* rect,
    ARGB startcolor, ARGB endcolor, REAL angle, BOOL isAngleScalable, GpWrapMode wrap,
    GpLineGradient **line)
{
573 574 575
    TRACE("(%p, %x, %x, %.2f, %d, %d, %p)\n", rect, startcolor, endcolor, angle, isAngleScalable,
          wrap, line);

576 577 578 579
    return GdipCreateLineBrushFromRectI(rect, startcolor, endcolor, LinearGradientModeForwardDiagonal,
                                        wrap, line);
}

580 581 582 583 584
GpStatus WINGDIPAPI GdipCreatePathGradient(GDIPCONST GpPointF* points,
    INT count, GpWrapMode wrap, GpPathGradient **grad)
{
    COLORREF col = ARGB2COLORREF(0xffffffff);

585 586
    TRACE("(%p, %d, %d, %p)\n", points, count, wrap, grad);

587 588 589 590 591 592 593 594 595
    if(!points || !grad)
        return InvalidParameter;

    if(count <= 0)
        return OutOfMemory;

    *grad = GdipAlloc(sizeof(GpPathGradient));
    if (!*grad) return OutOfMemory;

596
    (*grad)->blendfac = GdipAlloc(sizeof(REAL));
597 598 599 600
    (*grad)->blendpos = GdipAlloc(sizeof(REAL));
    if(!(*grad)->blendfac || !(*grad)->blendpos){
        GdipFree((*grad)->blendfac);
        GdipFree((*grad)->blendpos);
601
        GdipFree(*grad);
602
        *grad = NULL;
603 604 605
        return OutOfMemory;
    }
    (*grad)->blendfac[0] = 1.0;
606
    (*grad)->blendpos[0] = 1.0;
607 608
    (*grad)->blendcount  = 1;

609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630
    (*grad)->pathdata.Count = count;
    (*grad)->pathdata.Points = GdipAlloc(count * sizeof(PointF));
    (*grad)->pathdata.Types = GdipAlloc(count);

    if(!(*grad)->pathdata.Points || !(*grad)->pathdata.Types){
        GdipFree((*grad)->pathdata.Points);
        GdipFree((*grad)->pathdata.Types);
        GdipFree(*grad);
        return OutOfMemory;
    }

    memcpy((*grad)->pathdata.Points, points, count * sizeof(PointF));
    memset((*grad)->pathdata.Types, PathPointTypeLine, count);

    (*grad)->brush.lb.lbStyle = BS_SOLID;
    (*grad)->brush.lb.lbColor = col;
    (*grad)->brush.lb.lbHatch = 0;

    (*grad)->brush.gdibrush = CreateSolidBrush(col);
    (*grad)->brush.bt = BrushTypePathGradient;
    (*grad)->centercolor = 0xffffffff;
    (*grad)->wrap = wrap;
631
    (*grad)->gamma = FALSE;
632 633
    (*grad)->center.X = 0.0;
    (*grad)->center.Y = 0.0;
634 635
    (*grad)->focus.X = 0.0;
    (*grad)->focus.Y = 0.0;
636

637 638
    TRACE("<-- %p\n", *grad);

639 640 641
    return Ok;
}

642 643 644 645 646 647 648
GpStatus WINGDIPAPI GdipCreatePathGradientI(GDIPCONST GpPoint* points,
    INT count, GpWrapMode wrap, GpPathGradient **grad)
{
    GpPointF *pointsF;
    GpStatus ret;
    INT i;

649 650
    TRACE("(%p, %d, %d, %p)\n", points, count, wrap, grad);

651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671
    if(!points || !grad)
        return InvalidParameter;

    if(count <= 0)
        return OutOfMemory;

    pointsF = GdipAlloc(sizeof(GpPointF) * count);
    if(!pointsF)
        return OutOfMemory;

    for(i = 0; i < count; i++){
        pointsF[i].X = (REAL)points[i].X;
        pointsF[i].Y = (REAL)points[i].Y;
    }

    ret = GdipCreatePathGradient(pointsF, count, wrap, grad);
    GdipFree(pointsF);

    return ret;
}

672 673 674 675 676
/******************************************************************************
 * GdipCreatePathGradientFromPath [GDIPLUS.@]
 *
 * FIXME: path gradient brushes not truly supported (drawn as solid brushes)
 */
677 678 679 680 681
GpStatus WINGDIPAPI GdipCreatePathGradientFromPath(GDIPCONST GpPath* path,
    GpPathGradient **grad)
{
    COLORREF col = ARGB2COLORREF(0xffffffff);

682 683
    TRACE("(%p, %p)\n", path, grad);

684 685 686 687 688 689
    if(!path || !grad)
        return InvalidParameter;

    *grad = GdipAlloc(sizeof(GpPathGradient));
    if (!*grad) return OutOfMemory;

690
    (*grad)->blendfac = GdipAlloc(sizeof(REAL));
691 692 693 694
    (*grad)->blendpos = GdipAlloc(sizeof(REAL));
    if(!(*grad)->blendfac || !(*grad)->blendpos){
        GdipFree((*grad)->blendfac);
        GdipFree((*grad)->blendpos);
695
        GdipFree(*grad);
696
        *grad = NULL;
697 698 699
        return OutOfMemory;
    }
    (*grad)->blendfac[0] = 1.0;
700
    (*grad)->blendpos[0] = 1.0;
701 702
    (*grad)->blendcount  = 1;

703 704 705 706 707 708 709 710 711 712 713 714 715 716 717
    (*grad)->pathdata.Count = path->pathdata.Count;
    (*grad)->pathdata.Points = GdipAlloc(path->pathdata.Count * sizeof(PointF));
    (*grad)->pathdata.Types = GdipAlloc(path->pathdata.Count);

    if(!(*grad)->pathdata.Points || !(*grad)->pathdata.Types){
        GdipFree((*grad)->pathdata.Points);
        GdipFree((*grad)->pathdata.Types);
        GdipFree(*grad);
        return OutOfMemory;
    }

    memcpy((*grad)->pathdata.Points, path->pathdata.Points,
           path->pathdata.Count * sizeof(PointF));
    memcpy((*grad)->pathdata.Types, path->pathdata.Types, path->pathdata.Count);

718 719 720 721 722
    (*grad)->brush.lb.lbStyle = BS_SOLID;
    (*grad)->brush.lb.lbColor = col;
    (*grad)->brush.lb.lbHatch = 0;

    (*grad)->brush.gdibrush = CreateSolidBrush(col);
723
    (*grad)->brush.bt = BrushTypePathGradient;
724
    (*grad)->centercolor = 0xffffffff;
725
    (*grad)->wrap = WrapModeClamp;
726
    (*grad)->gamma = FALSE;
727 728 729
    /* FIXME: this should be set to the "centroid" of the path by default */
    (*grad)->center.X = 0.0;
    (*grad)->center.Y = 0.0;
730 731
    (*grad)->focus.X = 0.0;
    (*grad)->focus.Y = 0.0;
732

733 734
    TRACE("<-- %p\n", *grad);

735 736 737
    return Ok;
}

738 739 740
/******************************************************************************
 * GdipCreateSolidFill [GDIPLUS.@]
 */
741 742 743 744
GpStatus WINGDIPAPI GdipCreateSolidFill(ARGB color, GpSolidFill **sf)
{
    COLORREF col = ARGB2COLORREF(color);

745 746
    TRACE("(%x, %p)\n", color, sf);

747 748 749 750 751
    if(!sf)  return InvalidParameter;

    *sf = GdipAlloc(sizeof(GpSolidFill));
    if (!*sf) return OutOfMemory;

752 753 754 755
    (*sf)->brush.lb.lbStyle = BS_SOLID;
    (*sf)->brush.lb.lbColor = col;
    (*sf)->brush.lb.lbHatch = 0;

756 757
    (*sf)->brush.gdibrush = CreateSolidBrush(col);
    (*sf)->brush.bt = BrushTypeSolidColor;
758
    (*sf)->color = color;
759
    (*sf)->bmp = ARGB2BMP(color);
760

761 762
    TRACE("<-- %p\n", *sf);

763 764 765
    return Ok;
}

766
/******************************************************************************
767 768 769 770 771 772 773 774 775 776 777
 * GdipCreateTexture [GDIPLUS.@]
 *
 * PARAMS
 *  image       [I] image to use
 *  wrapmode    [I] optional
 *  texture     [O] pointer to the resulting texturebrush
 *
 * RETURNS
 *  SUCCESS: Ok
 *  FAILURE: element of GpStatus
 */
778 779 780
GpStatus WINGDIPAPI GdipCreateTexture(GpImage *image, GpWrapMode wrapmode,
        GpTexture **texture)
{
781
    UINT width, height;
782
    GpImageAttributes *attributes;
783
    GpStatus stat;
784

785 786 787 788 789 790 791 792 793 794
    TRACE("%p, %d %p\n", image, wrapmode, texture);

    if (!(image && texture))
        return InvalidParameter;

    stat = GdipGetImageWidth(image, &width);
    if (stat != Ok) return stat;
    stat = GdipGetImageHeight(image, &height);
    if (stat != Ok) return stat;

795 796 797 798 799 800 801
    stat = GdipCreateImageAttributes(&attributes);

    if (stat == Ok)
    {
        attributes->wrap = wrapmode;

        stat = GdipCreateTextureIA(image, attributes, 0, 0, width, height,
802
            texture);
803 804 805 806 807

        GdipDisposeImageAttributes(attributes);
    }

    return stat;
808 809
}

810 811 812
/******************************************************************************
 * GdipCreateTexture2 [GDIPLUS.@]
 */
813 814 815
GpStatus WINGDIPAPI GdipCreateTexture2(GpImage *image, GpWrapMode wrapmode,
        REAL x, REAL y, REAL width, REAL height, GpTexture **texture)
{
816 817
    GpImageAttributes *attributes;
    GpStatus stat;
818 819

    TRACE("%p %d %f %f %f %f %p\n", image, wrapmode,
820 821
            x, y, width, height, texture);

822 823 824 825 826 827 828 829 830 831 832 833 834
    stat = GdipCreateImageAttributes(&attributes);

    if (stat == Ok)
    {
        attributes->wrap = wrapmode;

        stat = GdipCreateTextureIA(image, attributes, x, y, width, height,
                texture);

        GdipDisposeImageAttributes(attributes);
    }

    return stat;
835 836
}

837 838 839 840 841
/******************************************************************************
 * GdipCreateTextureIA [GDIPLUS.@]
 *
 * FIXME: imageattr ignored
 */
842 843 844 845
GpStatus WINGDIPAPI GdipCreateTextureIA(GpImage *image,
    GDIPCONST GpImageAttributes *imageattr, REAL x, REAL y, REAL width,
    REAL height, GpTexture **texture)
{
846
    HBITMAP hbm=NULL;
847
    GpStatus status;
848
    GpImage *new_image=NULL;
849

850 851 852
    TRACE("(%p, %p, %.2f, %.2f, %.2f, %.2f, %p)\n", image, imageattr, x, y, width, height,
           texture);

853 854 855
    if(!image || !texture || x < 0.0 || y < 0.0 || width < 0.0 || height < 0.0)
        return InvalidParameter;

856 857
    *texture = NULL;

858 859 860 861 862
    if(image->type != ImageTypeBitmap){
        FIXME("not implemented for image type %d\n", image->type);
        return NotImplemented;
    }

863 864 865
    status = GdipCloneBitmapArea(x, y, width, height, PixelFormatDontCare, (GpBitmap*)image, (GpBitmap**)&new_image);
    if (status != Ok)
        return status;
866

867
    status = GdipCreateHBITMAPFromBitmap((GpBitmap*)new_image, &hbm, 0);
868 869 870 871
    if(!hbm)
    {
        status = GenericError;
        goto exit;
872 873 874
    }

    *texture = GdipAlloc(sizeof(GpTexture));
875
    if (!*texture){
876 877
        status = OutOfMemory;
        goto exit;
878
    }
879

880
    if((status = GdipCreateMatrix(&(*texture)->transform)) != Ok){
881
        goto exit;
882 883
    }

884 885 886 887 888 889 890 891 892 893 894 895 896
    if (imageattr)
    {
        status = GdipCloneImageAttributes(imageattr, &(*texture)->imageattributes);
    }
    else
    {
        status = GdipCreateImageAttributes(&(*texture)->imageattributes);
        if (status == Ok)
            (*texture)->imageattributes->wrap = WrapModeTile;
    }
    if (status != Ok)
        goto exit;

897 898 899
    (*texture)->brush.lb.lbStyle = BS_PATTERN;
    (*texture)->brush.lb.lbColor = 0;
    (*texture)->brush.lb.lbHatch = (ULONG_PTR)hbm;
900 901 902

    (*texture)->brush.gdibrush = CreateBrushIndirect(&(*texture)->brush.lb);
    (*texture)->brush.bt = BrushTypeTextureFill;
903
    (*texture)->image = new_image;
904

905 906 907 908 909 910 911 912 913 914
exit:
    if (status == Ok)
    {
        TRACE("<-- %p\n", *texture);
    }
    else
    {
        if (*texture)
        {
            GdipDeleteMatrix((*texture)->transform);
915
            GdipDisposeImageAttributes((*texture)->imageattributes);
916 917 918
            GdipFree(*texture);
            *texture = NULL;
        }
919
        GdipDisposeImage(new_image);
920 921
        TRACE("<-- error %u\n", status);
    }
922

923 924
    DeleteObject(hbm);

925
    return status;
926 927
}

928 929 930
/******************************************************************************
 * GdipCreateTextureIAI [GDIPLUS.@]
 */
931 932 933
GpStatus WINGDIPAPI GdipCreateTextureIAI(GpImage *image, GDIPCONST GpImageAttributes *imageattr,
    INT x, INT y, INT width, INT height, GpTexture **texture)
{
934 935 936
    TRACE("(%p, %p, %d, %d, %d, %d, %p)\n", image, imageattr, x, y, width, height,
           texture);

937 938 939
    return GdipCreateTextureIA(image,imageattr,(REAL)x,(REAL)y,(REAL)width,(REAL)height,texture);
}

940 941 942
GpStatus WINGDIPAPI GdipCreateTexture2I(GpImage *image, GpWrapMode wrapmode,
        INT x, INT y, INT width, INT height, GpTexture **texture)
{
943 944
    GpImageAttributes *imageattr;
    GpStatus stat;
945

946
    TRACE("%p %d %d %d %d %d %p\n", image, wrapmode, x, y, width, height,
947 948
            texture);

949 950 951 952 953
    stat = GdipCreateImageAttributes(&imageattr);

    if (stat == Ok)
    {
        imageattr->wrap = wrapmode;
954

955 956 957 958
        stat = GdipCreateTextureIA(image, imageattr, x, y, width, height, texture);
    }

    return stat;
959 960
}

961 962
GpStatus WINGDIPAPI GdipGetBrushType(GpBrush *brush, GpBrushType *type)
{
963 964
    TRACE("(%p, %p)\n", brush, type);

965 966 967 968 969 970 971
    if(!brush || !type)  return InvalidParameter;

    *type = brush->bt;

    return Ok;
}

972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004
GpStatus WINGDIPAPI GdipGetHatchBackgroundColor(GpHatch *brush, ARGB *backcol)
{
    TRACE("(%p, %p)\n", brush, backcol);

    if(!brush || !backcol)  return InvalidParameter;

    *backcol = brush->backcol;

    return Ok;
}

GpStatus WINGDIPAPI GdipGetHatchForegroundColor(GpHatch *brush, ARGB *forecol)
{
    TRACE("(%p, %p)\n", brush, forecol);

    if(!brush || !forecol)  return InvalidParameter;

    *forecol = brush->forecol;

    return Ok;
}

GpStatus WINGDIPAPI GdipGetHatchStyle(GpHatch *brush, HatchStyle *hatchstyle)
{
    TRACE("(%p, %p)\n", brush, hatchstyle);

    if(!brush || !hatchstyle)  return InvalidParameter;

    *hatchstyle = brush->hatchstyle;

    return Ok;
}

1005 1006
GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush *brush)
{
1007 1008
    TRACE("(%p)\n", brush);

1009 1010
    if(!brush)  return InvalidParameter;

1011 1012 1013 1014 1015
    switch(brush->bt)
    {
        case BrushTypePathGradient:
            GdipFree(((GpPathGradient*) brush)->pathdata.Points);
            GdipFree(((GpPathGradient*) brush)->pathdata.Types);
1016 1017
            GdipFree(((GpPathGradient*) brush)->blendfac);
            GdipFree(((GpPathGradient*) brush)->blendpos);
1018 1019
            break;
        case BrushTypeSolidColor:
1020 1021
            if (((GpSolidFill*)brush)->bmp)
                DeleteObject(((GpSolidFill*)brush)->bmp);
1022
            break;
1023
        case BrushTypeLinearGradient:
1024 1025
            GdipFree(((GpLineGradient*)brush)->blendfac);
            GdipFree(((GpLineGradient*)brush)->blendpos);
1026 1027
            GdipFree(((GpLineGradient*)brush)->pblendcolor);
            GdipFree(((GpLineGradient*)brush)->pblendpos);
1028
            break;
1029
        case BrushTypeTextureFill:
1030
            GdipDeleteMatrix(((GpTexture*)brush)->transform);
1031
            GdipDisposeImage(((GpTexture*)brush)->image);
1032
            GdipDisposeImageAttributes(((GpTexture*)brush)->imageattributes);
1033
            GdipFree(((GpTexture*)brush)->bitmap_bits);
1034
            break;
1035 1036 1037 1038
        default:
            break;
    }

1039 1040 1041
    DeleteObject(brush->gdibrush);
    GdipFree(brush);

1042 1043 1044
    return Ok;
}

1045 1046 1047
GpStatus WINGDIPAPI GdipGetLineGammaCorrection(GpLineGradient *line,
    BOOL *usinggamma)
{
1048 1049
    TRACE("(%p, %p)\n", line, usinggamma);

1050
    if(!line || !usinggamma)
1051 1052 1053 1054 1055 1056 1057
        return InvalidParameter;

    *usinggamma = line->gamma;

    return Ok;
}

1058 1059
GpStatus WINGDIPAPI GdipGetLineWrapMode(GpLineGradient *brush, GpWrapMode *wrapmode)
{
1060 1061
    TRACE("(%p, %p)\n", brush, wrapmode);

1062 1063 1064 1065 1066 1067 1068 1069
    if(!brush || !wrapmode)
        return InvalidParameter;

    *wrapmode = brush->wrap;

    return Ok;
}

1070 1071 1072
GpStatus WINGDIPAPI GdipGetPathGradientBlend(GpPathGradient *brush, REAL *blend,
    REAL *positions, INT count)
{
1073 1074
    TRACE("(%p, %p, %p, %d)\n", brush, blend, positions, count);

1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088
    if(!brush || !blend || !positions || count <= 0)
        return InvalidParameter;

    if(count < brush->blendcount)
        return InsufficientBuffer;

    memcpy(blend, brush->blendfac, count*sizeof(REAL));
    if(brush->blendcount > 1){
        memcpy(positions, brush->blendpos, count*sizeof(REAL));
    }

    return Ok;
}

1089 1090
GpStatus WINGDIPAPI GdipGetPathGradientBlendCount(GpPathGradient *brush, INT *count)
{
1091 1092
    TRACE("(%p, %p)\n", brush, count);

1093 1094 1095 1096 1097 1098 1099 1100
    if(!brush || !count)
        return InvalidParameter;

    *count = brush->blendcount;

    return Ok;
}

1101 1102 1103
GpStatus WINGDIPAPI GdipGetPathGradientCenterPoint(GpPathGradient *grad,
    GpPointF *point)
{
1104 1105
    TRACE("(%p, %p)\n", grad, point);

1106 1107 1108 1109 1110 1111 1112 1113 1114
    if(!grad || !point)
        return InvalidParameter;

    point->X = grad->center.X;
    point->Y = grad->center.Y;

    return Ok;
}

1115 1116 1117 1118 1119 1120
GpStatus WINGDIPAPI GdipGetPathGradientCenterPointI(GpPathGradient *grad,
    GpPoint *point)
{
    GpStatus ret;
    GpPointF ptf;

1121 1122
    TRACE("(%p, %p)\n", grad, point);

1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135
    if(!point)
        return InvalidParameter;

    ret = GdipGetPathGradientCenterPoint(grad,&ptf);

    if(ret == Ok){
        point->X = roundr(ptf.X);
        point->Y = roundr(ptf.Y);
    }

    return ret;
}

1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148
GpStatus WINGDIPAPI GdipGetPathGradientCenterColor(GpPathGradient *grad,
    ARGB *colors)
{
    static int calls;

    TRACE("(%p,%p)\n", grad, colors);

    if(!(calls++))
        FIXME("not implemented\n");

    return NotImplemented;
}

1149 1150 1151
GpStatus WINGDIPAPI GdipGetPathGradientFocusScales(GpPathGradient *grad,
    REAL *x, REAL *y)
{
1152 1153
    TRACE("(%p, %p, %p)\n", grad, x, y);

1154 1155 1156 1157 1158 1159 1160 1161 1162
    if(!grad || !x || !y)
        return InvalidParameter;

    *x = grad->focus.X;
    *y = grad->focus.Y;

    return Ok;
}

1163 1164 1165
GpStatus WINGDIPAPI GdipGetPathGradientGammaCorrection(GpPathGradient *grad,
    BOOL *gamma)
{
1166 1167
    TRACE("(%p, %p)\n", grad, gamma);

1168 1169 1170 1171 1172 1173 1174 1175
    if(!grad || !gamma)
        return InvalidParameter;

    *gamma = grad->gamma;

    return Ok;
}

1176 1177 1178
GpStatus WINGDIPAPI GdipGetPathGradientPointCount(GpPathGradient *grad,
    INT *count)
{
1179 1180
    TRACE("(%p, %p)\n", grad, count);

1181 1182 1183 1184 1185
    if(!grad || !count)
        return InvalidParameter;

    *count = grad->pathdata.Count;

1186 1187
    return Ok;
}
1188

1189 1190 1191 1192 1193 1194
GpStatus WINGDIPAPI GdipGetPathGradientRect(GpPathGradient *brush, GpRectF *rect)
{
    GpRectF r;
    GpPath* path;
    GpStatus stat;

1195 1196
    TRACE("(%p, %p)\n", brush, rect);

1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221
    if(!brush || !rect)
        return InvalidParameter;

    stat = GdipCreatePath2(brush->pathdata.Points, brush->pathdata.Types,
                           brush->pathdata.Count, FillModeAlternate, &path);
    if(stat != Ok)  return stat;

    stat = GdipGetPathWorldBounds(path, &r, NULL, NULL);
    if(stat != Ok){
        GdipDeletePath(path);
        return stat;
    }

    memcpy(rect, &r, sizeof(GpRectF));

    GdipDeletePath(path);

    return Ok;
}

GpStatus WINGDIPAPI GdipGetPathGradientRectI(GpPathGradient *brush, GpRect *rect)
{
    GpRectF rectf;
    GpStatus stat;

1222 1223
    TRACE("(%p, %p)\n", brush, rect);

1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237
    if(!brush || !rect)
        return InvalidParameter;

    stat = GdipGetPathGradientRect(brush, &rectf);
    if(stat != Ok)  return stat;

    rect->X = roundr(rectf.X);
    rect->Y = roundr(rectf.Y);
    rect->Width  = roundr(rectf.Width);
    rect->Height = roundr(rectf.Height);

    return Ok;
}

1238 1239 1240 1241 1242
GpStatus WINGDIPAPI GdipGetPathGradientSurroundColorsWithCount(GpPathGradient
    *grad, ARGB *argb, INT *count)
{
    static int calls;

1243 1244
    TRACE("(%p,%p,%p)\n", grad, argb, count);

1245 1246 1247 1248 1249 1250 1251 1252 1253
    if(!grad || !argb || !count || (*count < grad->pathdata.Count))
        return InvalidParameter;

    if(!(calls++))
        FIXME("not implemented\n");

    return NotImplemented;
}

1254 1255
GpStatus WINGDIPAPI GdipGetPathGradientSurroundColorCount(GpPathGradient *brush, INT *count)
{
André Hentschel's avatar
André Hentschel committed
1256 1257
    static int calls;

1258 1259 1260 1261 1262
    TRACE("(%p, %p)\n", brush, count);

    if (!brush || !count)
       return InvalidParameter;

André Hentschel's avatar
André Hentschel committed
1263 1264 1265
    if(!(calls++))
        FIXME("not implemented\n");

1266 1267 1268
    return NotImplemented;
}

1269 1270 1271
GpStatus WINGDIPAPI GdipGetPathGradientWrapMode(GpPathGradient *brush,
    GpWrapMode *wrapmode)
{
1272 1273
    TRACE("(%p, %p)\n", brush, wrapmode);

1274 1275 1276 1277 1278 1279 1280 1281
    if(!brush || !wrapmode)
        return InvalidParameter;

    *wrapmode = brush->wrap;

    return Ok;
}

1282 1283
GpStatus WINGDIPAPI GdipGetSolidFillColor(GpSolidFill *sf, ARGB *argb)
{
1284 1285
    TRACE("(%p, %p)\n", sf, argb);

1286 1287 1288
    if(!sf || !argb)
        return InvalidParameter;

1289 1290 1291
    *argb = sf->color;

    return Ok;
1292 1293
}

1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306
/******************************************************************************
 * GdipGetTextureImage [GDIPLUS.@]
 */
GpStatus WINGDIPAPI GdipGetTextureImage(GpTexture *brush, GpImage **image)
{
    TRACE("(%p, %p)\n", brush, image);

    if(!brush || !image)
        return InvalidParameter;

    return GdipCloneImage(brush->image, image);
}

1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321
/******************************************************************************
 * GdipGetTextureTransform [GDIPLUS.@]
 */
GpStatus WINGDIPAPI GdipGetTextureTransform(GpTexture *brush, GpMatrix *matrix)
{
    TRACE("(%p, %p)\n", brush, matrix);

    if(!brush || !matrix)
        return InvalidParameter;

    memcpy(matrix, brush->transform, sizeof(GpMatrix));

    return Ok;
}

1322 1323 1324 1325 1326 1327 1328 1329 1330 1331
/******************************************************************************
 * GdipGetTextureWrapMode [GDIPLUS.@]
 */
GpStatus WINGDIPAPI GdipGetTextureWrapMode(GpTexture *brush, GpWrapMode *wrapmode)
{
    TRACE("(%p, %p)\n", brush, wrapmode);

    if(!brush || !wrapmode)
        return InvalidParameter;

1332
    *wrapmode = brush->imageattributes->wrap;
1333 1334 1335 1336

    return Ok;
}

1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350
/******************************************************************************
 * GdipMultiplyTextureTransform [GDIPLUS.@]
 */
GpStatus WINGDIPAPI GdipMultiplyTextureTransform(GpTexture* brush,
    GDIPCONST GpMatrix *matrix, GpMatrixOrder order)
{
    TRACE("(%p, %p, %d)\n", brush, matrix, order);

    if(!brush || !matrix)
        return InvalidParameter;

    return GdipMultiplyMatrix(brush->transform, matrix, order);
}

1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363
/******************************************************************************
 * GdipResetTextureTransform [GDIPLUS.@]
 */
GpStatus WINGDIPAPI GdipResetTextureTransform(GpTexture* brush)
{
    TRACE("(%p)\n", brush);

    if(!brush)
        return InvalidParameter;

    return GdipSetMatrixElements(brush->transform, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
}

1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377
/******************************************************************************
 * GdipScaleTextureTransform [GDIPLUS.@]
 */
GpStatus WINGDIPAPI GdipScaleTextureTransform(GpTexture* brush,
    REAL sx, REAL sy, GpMatrixOrder order)
{
    TRACE("(%p, %.2f, %.2f, %d)\n", brush, sx, sy, order);

    if(!brush)
        return InvalidParameter;

    return GdipScaleMatrix(brush->transform, sx, sy, order);
}

1378
GpStatus WINGDIPAPI GdipSetLineBlend(GpLineGradient *brush,
1379
    GDIPCONST REAL *factors, GDIPCONST REAL* positions, INT count)
1380
{
1381
    REAL *new_blendfac, *new_blendpos;
1382

1383 1384 1385 1386
    TRACE("(%p, %p, %p, %i)\n", brush, factors, positions, count);

    if(!brush || !factors || !positions || count <= 0 ||
       (count >= 2 && (positions[0] != 0.0f || positions[count-1] != 1.0f)))
1387 1388
        return InvalidParameter;

1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407
    new_blendfac = GdipAlloc(count * sizeof(REAL));
    new_blendpos = GdipAlloc(count * sizeof(REAL));

    if (!new_blendfac || !new_blendpos)
    {
        GdipFree(new_blendfac);
        GdipFree(new_blendpos);
        return OutOfMemory;
    }

    memcpy(new_blendfac, factors, count * sizeof(REAL));
    memcpy(new_blendpos, positions, count * sizeof(REAL));

    GdipFree(brush->blendfac);
    GdipFree(brush->blendpos);

    brush->blendcount = count;
    brush->blendfac = new_blendfac;
    brush->blendpos = new_blendpos;
1408 1409 1410 1411

    return Ok;
}

1412 1413 1414 1415 1416
GpStatus WINGDIPAPI GdipGetLineBlend(GpLineGradient *brush, REAL *factors,
    REAL *positions, INT count)
{
    TRACE("(%p, %p, %p, %i)\n", brush, factors, positions, count);

1417 1418
    if (!brush || !factors || !positions || count <= 0)
        return InvalidParameter;
1419

1420 1421 1422 1423 1424 1425 1426
    if (count < brush->blendcount)
        return InsufficientBuffer;

    memcpy(factors, brush->blendfac, brush->blendcount * sizeof(REAL));
    memcpy(positions, brush->blendpos, brush->blendcount * sizeof(REAL));

    return Ok;
1427 1428
}

1429 1430 1431 1432
GpStatus WINGDIPAPI GdipGetLineBlendCount(GpLineGradient *brush, INT *count)
{
    TRACE("(%p, %p)\n", brush, count);

1433 1434
    if (!brush || !count)
        return InvalidParameter;
1435

1436 1437 1438
    *count = brush->blendcount;

    return Ok;
1439 1440
}

1441 1442 1443
GpStatus WINGDIPAPI GdipSetLineGammaCorrection(GpLineGradient *line,
    BOOL usegamma)
{
1444 1445
    TRACE("(%p, %d)\n", line, usegamma);

1446 1447 1448 1449 1450 1451 1452 1453
    if(!line)
        return InvalidParameter;

    line->gamma = usegamma;

    return Ok;
}

1454 1455 1456
GpStatus WINGDIPAPI GdipSetLineSigmaBlend(GpLineGradient *line, REAL focus,
    REAL scale)
{
1457 1458 1459 1460 1461 1462 1463 1464 1465 1466
    REAL factors[33];
    REAL positions[33];
    int num_points = 0;
    int i;
    const int precision = 16;
    REAL erf_range; /* we use values erf(-erf_range) through erf(+erf_range) */
    REAL min_erf;
    REAL scale_erf;

    TRACE("(%p, %0.2f, %0.2f)\n", line, focus, scale);
1467 1468 1469 1470

    if(!line || focus < 0.0 || focus > 1.0 || scale < 0.0 || scale > 1.0)
        return InvalidParameter;

1471 1472
    /* we want 2 standard deviations */
    erf_range = 2.0 / sqrt(2);
1473

1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507
    /* calculate the constants we need to normalize the error function to be
        between 0.0 and scale over the range we need */
    min_erf = erf(-erf_range);
    scale_erf = scale / (-2.0 * min_erf);

    if (focus != 0.0)
    {
        positions[0] = 0.0;
        factors[0] = 0.0;
        for (i=1; i<precision; i++)
        {
            positions[i] = focus * i / precision;
            factors[i] = scale_erf * (erf(2 * erf_range * i / precision - erf_range) - min_erf);
        }
        num_points += precision;
    }

    positions[num_points] = focus;
    factors[num_points] = scale;
    num_points += 1;

    if (focus != 1.0)
    {
        for (i=1; i<precision; i++)
        {
            positions[i+num_points-1] = (focus + ((1.0-focus) * i / precision));
            factors[i+num_points-1] = scale_erf * (erf(erf_range - 2 * erf_range * i / precision) - min_erf);
        }
        num_points += precision;
        positions[num_points-1] = 1.0;
        factors[num_points-1] = 0.0;
    }

    return GdipSetLineBlend(line, factors, positions, num_points);
1508 1509
}

1510 1511 1512
GpStatus WINGDIPAPI GdipSetLineWrapMode(GpLineGradient *line,
    GpWrapMode wrap)
{
1513 1514
    TRACE("(%p, %d)\n", line, wrap);

1515 1516 1517 1518 1519 1520 1521 1522
    if(!line || wrap == WrapModeClamp)
        return InvalidParameter;

    line->wrap = wrap;

    return Ok;
}

1523 1524 1525 1526 1527
GpStatus WINGDIPAPI GdipSetPathGradientBlend(GpPathGradient *brush, GDIPCONST REAL *blend,
    GDIPCONST REAL *pos, INT count)
{
    static int calls;

1528 1529
    TRACE("(%p,%p,%p,%i)\n", brush, blend, pos, count);

1530 1531
    if(!(calls++))
        FIXME("not implemented\n");
1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544

    return NotImplemented;
}

GpStatus WINGDIPAPI GdipSetPathGradientLinearBlend(GpPathGradient *brush,
    REAL focus, REAL scale)
{
    static int calls;

    TRACE("(%p,%0.2f,%0.2f)\n", brush, focus, scale);

    if(!(calls++))
        FIXME("not implemented\n");
1545 1546 1547 1548

    return NotImplemented;
}

1549 1550 1551 1552 1553 1554 1555
GpStatus WINGDIPAPI GdipSetPathGradientPresetBlend(GpPathGradient *brush,
    GDIPCONST ARGB *blend, GDIPCONST REAL *pos, INT count)
{
    FIXME("(%p,%p,%p,%i): stub\n", brush, blend, pos, count);
    return NotImplemented;
}

1556 1557 1558 1559 1560 1561 1562
GpStatus WINGDIPAPI GdipGetPathGradientPresetBlend(GpPathGradient *brush,
    ARGB *blend, REAL *pos, INT count)
{
    FIXME("(%p,%p,%p,%i): stub\n", brush, blend, pos, count);
    return NotImplemented;
}

1563 1564 1565 1566 1567 1568 1569
GpStatus WINGDIPAPI GdipGetPathGradientPresetBlendCount(GpPathGradient *brush,
    INT *count)
{
    FIXME("(%p,%p): stub\n", brush, count);
    return NotImplemented;
}

1570 1571 1572
GpStatus WINGDIPAPI GdipSetPathGradientCenterColor(GpPathGradient *grad,
    ARGB argb)
{
1573 1574
    TRACE("(%p, %x)\n", grad, argb);

1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586
    if(!grad)
        return InvalidParameter;

    grad->centercolor = argb;
    grad->brush.lb.lbColor = ARGB2COLORREF(argb);

    DeleteObject(grad->brush.gdibrush);
    grad->brush.gdibrush = CreateSolidBrush(grad->brush.lb.lbColor);

    return Ok;
}

1587 1588 1589
GpStatus WINGDIPAPI GdipSetPathGradientCenterPoint(GpPathGradient *grad,
    GpPointF *point)
{
1590
    TRACE("(%p, %s)\n", grad, debugstr_pointf(point));
1591

1592 1593 1594 1595 1596 1597 1598 1599 1600
    if(!grad || !point)
        return InvalidParameter;

    grad->center.X = point->X;
    grad->center.Y = point->Y;

    return Ok;
}

1601 1602 1603 1604 1605
GpStatus WINGDIPAPI GdipSetPathGradientCenterPointI(GpPathGradient *grad,
    GpPoint *point)
{
    GpPointF ptf;

1606 1607
    TRACE("(%p, %p)\n", grad, point);

1608 1609 1610 1611 1612 1613 1614 1615 1616
    if(!point)
        return InvalidParameter;

    ptf.X = (REAL)point->X;
    ptf.Y = (REAL)point->Y;

    return GdipSetPathGradientCenterPoint(grad,&ptf);
}

1617 1618 1619
GpStatus WINGDIPAPI GdipSetPathGradientFocusScales(GpPathGradient *grad,
    REAL x, REAL y)
{
1620 1621
    TRACE("(%p, %.2f, %.2f)\n", grad, x, y);

1622 1623 1624 1625 1626 1627 1628 1629 1630
    if(!grad)
        return InvalidParameter;

    grad->focus.X = x;
    grad->focus.Y = y;

    return Ok;
}

1631 1632 1633
GpStatus WINGDIPAPI GdipSetPathGradientGammaCorrection(GpPathGradient *grad,
    BOOL gamma)
{
1634 1635
    TRACE("(%p, %d)\n", grad, gamma);

1636 1637 1638 1639 1640 1641 1642 1643
    if(!grad)
        return InvalidParameter;

    grad->gamma = gamma;

    return Ok;
}

1644 1645 1646 1647 1648
GpStatus WINGDIPAPI GdipSetPathGradientSigmaBlend(GpPathGradient *grad,
    REAL focus, REAL scale)
{
    static int calls;

1649 1650
    TRACE("(%p,%0.2f,%0.2f)\n", grad, focus, scale);

1651 1652 1653 1654 1655 1656 1657 1658 1659
    if(!grad || focus < 0.0 || focus > 1.0 || scale < 0.0 || scale > 1.0)
        return InvalidParameter;

    if(!(calls++))
        FIXME("not implemented\n");

    return NotImplemented;
}

1660
GpStatus WINGDIPAPI GdipSetPathGradientSurroundColorsWithCount(GpPathGradient
1661
    *grad, GDIPCONST ARGB *argb, INT *count)
1662 1663 1664
{
    static int calls;

1665 1666
    TRACE("(%p,%p,%p)\n", grad, argb, count);

1667 1668 1669 1670 1671 1672 1673 1674 1675 1676
    if(!grad || !argb || !count || (*count <= 0) ||
        (*count > grad->pathdata.Count))
        return InvalidParameter;

    if(!(calls++))
        FIXME("not implemented\n");

    return NotImplemented;
}

1677 1678 1679
GpStatus WINGDIPAPI GdipSetPathGradientWrapMode(GpPathGradient *grad,
    GpWrapMode wrap)
{
1680 1681
    TRACE("(%p, %d)\n", grad, wrap);

1682 1683 1684 1685 1686 1687 1688 1689
    if(!grad)
        return InvalidParameter;

    grad->wrap = wrap;

    return Ok;
}

1690 1691 1692 1693 1694 1695
GpStatus WINGDIPAPI GdipSetPathGradientTransform(GpPathGradient *grad,
    GpMatrix *matrix)
{
    static int calls;

    TRACE("(%p,%p)\n", grad, matrix);
1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708

    if(!(calls++))
        FIXME("not implemented\n");

    return NotImplemented;
}

GpStatus WINGDIPAPI GdipGetPathGradientTransform(GpPathGradient *grad,
    GpMatrix *matrix)
{
    static int calls;

    TRACE("(%p,%p)\n", grad, matrix);
1709 1710 1711 1712 1713 1714 1715

    if(!(calls++))
        FIXME("not implemented\n");

    return NotImplemented;
}

1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728
GpStatus WINGDIPAPI GdipMultiplyPathGradientTransform(GpPathGradient *grad,
    GDIPCONST GpMatrix *matrix, GpMatrixOrder order)
{
    static int calls;

    TRACE("(%p,%p,%i)\n", grad, matrix, order);

    if(!(calls++))
        FIXME("not implemented\n");

    return NotImplemented;
}

1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741
GpStatus WINGDIPAPI GdipRotatePathGradientTransform(GpPathGradient *grad,
    REAL angle, GpMatrixOrder order)
{
    static int calls;

    TRACE("(%p,%0.2f,%i)\n", grad, angle, order);

    if(!(calls++))
        FIXME("not implemented\n");

    return NotImplemented;
}

1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754
GpStatus WINGDIPAPI GdipScalePathGradientTransform(GpPathGradient *grad,
    REAL sx, REAL sy, GpMatrixOrder order)
{
    static int calls;

    TRACE("(%p,%0.2f,%0.2f,%i)\n", grad, sx, sy, order);

    if(!(calls++))
        FIXME("not implemented\n");

    return NotImplemented;
}

1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767
GpStatus WINGDIPAPI GdipTranslatePathGradientTransform(GpPathGradient *grad,
    REAL dx, REAL dy, GpMatrixOrder order)
{
    static int calls;

    TRACE("(%p,%0.2f,%0.2f,%i)\n", grad, dx, dy, order);

    if(!(calls++))
        FIXME("not implemented\n");

    return NotImplemented;
}

1768 1769
GpStatus WINGDIPAPI GdipSetSolidFillColor(GpSolidFill *sf, ARGB argb)
{
1770 1771
    TRACE("(%p, %x)\n", sf, argb);

1772 1773 1774
    if(!sf)
        return InvalidParameter;

1775 1776 1777 1778 1779 1780 1781
    sf->color = argb;
    sf->brush.lb.lbColor = ARGB2COLORREF(argb);

    DeleteObject(sf->brush.gdibrush);
    sf->brush.gdibrush = CreateSolidBrush(sf->brush.lb.lbColor);

    return Ok;
1782
}
1783

1784 1785 1786
/******************************************************************************
 * GdipSetTextureTransform [GDIPLUS.@]
 */
1787 1788 1789
GpStatus WINGDIPAPI GdipSetTextureTransform(GpTexture *texture,
    GDIPCONST GpMatrix *matrix)
{
1790
    TRACE("(%p, %p)\n", texture, matrix);
1791 1792 1793 1794

    if(!texture || !matrix)
        return InvalidParameter;

1795
    memcpy(texture->transform, matrix, sizeof(GpMatrix));
1796 1797 1798

    return Ok;
}
1799

1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811
/******************************************************************************
 * GdipSetTextureWrapMode [GDIPLUS.@]
 *
 * WrapMode not used, only stored
 */
GpStatus WINGDIPAPI GdipSetTextureWrapMode(GpTexture *brush, GpWrapMode wrapmode)
{
    TRACE("(%p, %d)\n", brush, wrapmode);

    if(!brush)
        return InvalidParameter;

1812
    brush->imageattributes->wrap = wrapmode;
1813 1814 1815 1816

    return Ok;
}

1817 1818 1819
GpStatus WINGDIPAPI GdipSetLineColors(GpLineGradient *brush, ARGB color1,
    ARGB color2)
{
1820 1821
    TRACE("(%p, %x, %x)\n", brush, color1, color2);

1822 1823
    if(!brush)
        return InvalidParameter;
1824

1825 1826
    brush->startcolor = color1;
    brush->endcolor   = color2;
1827

1828
    return Ok;
1829
}
1830

1831 1832
GpStatus WINGDIPAPI GdipGetLineColors(GpLineGradient *brush, ARGB *colors)
{
1833 1834
    TRACE("(%p, %p)\n", brush, colors);

1835 1836 1837 1838 1839 1840 1841 1842 1843
    if(!brush || !colors)
        return InvalidParameter;

    colors[0] = brush->startcolor;
    colors[1] = brush->endcolor;

    return Ok;
}

1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857
/******************************************************************************
 * GdipRotateTextureTransform [GDIPLUS.@]
 */
GpStatus WINGDIPAPI GdipRotateTextureTransform(GpTexture* brush, REAL angle,
    GpMatrixOrder order)
{
    TRACE("(%p, %.2f, %d)\n", brush, angle, order);

    if(!brush)
        return InvalidParameter;

    return GdipRotateMatrix(brush->transform, angle, order);
}

1858 1859 1860
GpStatus WINGDIPAPI GdipSetLineLinearBlend(GpLineGradient *brush, REAL focus,
    REAL scale)
{
1861 1862 1863
    REAL factors[3];
    REAL positions[3];
    int num_points = 0;
1864

1865
    TRACE("(%p,%.2f,%.2f)\n", brush, focus, scale);
1866

1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887
    if (!brush) return InvalidParameter;

    if (focus != 0.0)
    {
        factors[num_points] = 0.0;
        positions[num_points] = 0.0;
        num_points++;
    }

    factors[num_points] = scale;
    positions[num_points] = focus;
    num_points++;

    if (focus != 1.0)
    {
        factors[num_points] = 0.0;
        positions[num_points] = 1.0;
        num_points++;
    }

    return GdipSetLineBlend(brush, factors, positions, num_points);
1888
}
1889 1890 1891 1892

GpStatus WINGDIPAPI GdipSetLinePresetBlend(GpLineGradient *brush,
    GDIPCONST ARGB *blend, GDIPCONST REAL* positions, INT count)
{
1893 1894 1895
    ARGB *new_color;
    REAL *new_pos;
    TRACE("(%p,%p,%p,%i)\n", brush, blend, positions, count);
1896

1897 1898 1899 1900 1901
    if (!brush || !blend || !positions || count < 2 ||
        positions[0] != 0.0f || positions[count-1] != 1.0f)
    {
        return InvalidParameter;
    }
1902

1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922
    new_color = GdipAlloc(count * sizeof(ARGB));
    new_pos = GdipAlloc(count * sizeof(REAL));
    if (!new_color || !new_pos)
    {
        GdipFree(new_color);
        GdipFree(new_pos);
        return OutOfMemory;
    }

    memcpy(new_color, blend, sizeof(ARGB) * count);
    memcpy(new_pos, positions, sizeof(REAL) * count);

    GdipFree(brush->pblendcolor);
    GdipFree(brush->pblendpos);

    brush->pblendcolor = new_color;
    brush->pblendpos = new_pos;
    brush->pblendcount = count;

    return Ok;
1923
}
1924

1925 1926 1927
GpStatus WINGDIPAPI GdipGetLinePresetBlend(GpLineGradient *brush,
    ARGB *blend, REAL* positions, INT count)
{
1928 1929
    if (!brush || !blend || !positions || count < 2)
        return InvalidParameter;
1930

1931 1932
    if (brush->pblendcount == 0)
        return GenericError;
1933

1934 1935 1936 1937 1938 1939 1940
    if (count < brush->pblendcount)
        return InsufficientBuffer;

    memcpy(blend, brush->pblendcolor, sizeof(ARGB) * brush->pblendcount);
    memcpy(positions, brush->pblendpos, sizeof(REAL) * brush->pblendcount);

    return Ok;
1941 1942 1943 1944 1945
}

GpStatus WINGDIPAPI GdipGetLinePresetBlendCount(GpLineGradient *brush,
    INT *count)
{
1946 1947
    if (!brush || !count)
        return InvalidParameter;
1948

1949
    *count = brush->pblendcount;
1950

1951
    return Ok;
1952 1953
}

1954 1955 1956 1957
GpStatus WINGDIPAPI GdipResetLineTransform(GpLineGradient *brush)
{
    static int calls;

1958 1959
    TRACE("(%p)\n", brush);

1960 1961 1962 1963 1964 1965
    if(!(calls++))
        FIXME("not implemented\n");

    return NotImplemented;
}

1966 1967 1968 1969 1970
GpStatus WINGDIPAPI GdipSetLineTransform(GpLineGradient *brush,
    GDIPCONST GpMatrix *matrix)
{
    static int calls;

1971 1972
    TRACE("(%p,%p)\n", brush,  matrix);

1973 1974 1975 1976 1977
    if(!(calls++))
        FIXME("not implemented\n");

    return NotImplemented;
}
1978

1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990
GpStatus WINGDIPAPI GdipGetLineTransform(GpLineGradient *brush, GpMatrix *matrix)
{
    static int calls;

    TRACE("(%p,%p)\n", brush, matrix);

    if(!(calls++))
        FIXME("not implemented\n");

    return NotImplemented;
}

1991 1992 1993 1994 1995
GpStatus WINGDIPAPI GdipScaleLineTransform(GpLineGradient *brush, REAL sx, REAL sy,
    GpMatrixOrder order)
{
    static int calls;

1996 1997
    TRACE("(%p,%0.2f,%0.2f,%u)\n", brush, sx, sy, order);

1998 1999 2000 2001 2002 2003
    if(!(calls++))
        FIXME("not implemented\n");

    return NotImplemented;
}

2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016
GpStatus WINGDIPAPI GdipMultiplyLineTransform(GpLineGradient *brush,
    GDIPCONST GpMatrix *matrix, GpMatrixOrder order)
{
    static int calls;

    TRACE("(%p,%p,%u)\n", brush, matrix, order);

    if(!(calls++))
        FIXME("not implemented\n");

    return NotImplemented;
}

2017 2018 2019 2020 2021 2022 2023 2024
GpStatus WINGDIPAPI GdipTranslateLineTransform(GpLineGradient* brush,
        REAL dx, REAL dy, GpMatrixOrder order)
{
    FIXME("stub: %p %f %f %d\n", brush, dx, dy, order);

    return NotImplemented;
}

2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038
/******************************************************************************
 * GdipTranslateTextureTransform [GDIPLUS.@]
 */
GpStatus WINGDIPAPI GdipTranslateTextureTransform(GpTexture* brush, REAL dx, REAL dy,
    GpMatrixOrder order)
{
    TRACE("(%p, %.2f, %.2f, %d)\n", brush, dx, dy, order);

    if(!brush)
        return InvalidParameter;

    return GdipTranslateMatrix(brush->transform, dx, dy, order);
}

2039 2040
GpStatus WINGDIPAPI GdipGetLineRect(GpLineGradient *brush, GpRectF *rect)
{
2041 2042
    TRACE("(%p, %p)\n", brush, rect);

2043 2044 2045
    if(!brush || !rect)
        return InvalidParameter;

2046
    *rect = brush->rect;
2047 2048 2049 2050 2051 2052 2053 2054 2055

    return Ok;
}

GpStatus WINGDIPAPI GdipGetLineRectI(GpLineGradient *brush, GpRect *rect)
{
    GpRectF  rectF;
    GpStatus ret;

2056 2057
    TRACE("(%p, %p)\n", brush, rect);

2058 2059 2060
    if(!rect)
        return InvalidParameter;

2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071
    ret = GdipGetLineRect(brush, &rectF);

    if(ret == Ok){
        rect->X      = roundr(rectF.X);
        rect->Y      = roundr(rectF.Y);
        rect->Width  = roundr(rectF.Width);
        rect->Height = roundr(rectF.Height);
    }

    return ret;
}
2072 2073 2074 2075 2076 2077

GpStatus WINGDIPAPI GdipRotateLineTransform(GpLineGradient* brush,
    REAL angle, GpMatrixOrder order)
{
    static int calls;

2078 2079
    TRACE("(%p,%0.2f,%u)\n", brush, angle, order);

2080 2081 2082 2083 2084 2085 2086 2087
    if(!brush)
        return InvalidParameter;

    if(!(calls++))
        FIXME("(%p, %.2f, %d) stub\n", brush, angle, order);

    return NotImplemented;
}