2 * PostScript colour functions
4 * Copyright 1998 Huw D M Davies
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/debug.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(psdrv
);
27 PSRGB
rgb_to_grayscale_scale( void )
29 static const PSRGB scale
= {0.3, 0.59, 0.11};
30 /* FIXME configurable */
34 /**********************************************************************
37 * Creates a PostScript colour from a COLORREF.
38 * Result is grey scale if ColorDevice field of ppd is CD_False else an
39 * rgb colour is produced.
41 void PSDRV_CreateColor( print_ctx
*ctx
, PSCOLOR
*pscolor
, COLORREF wincolor
)
43 int ctype
= wincolor
>> 24;
46 if(ctype
!= 0 && ctype
!= 2)
47 FIXME("Colour is %08lx\n", wincolor
);
49 r
= (wincolor
& 0xff) / 256.0;
50 g
= ((wincolor
>> 8) & 0xff) / 256.0;
51 b
= ((wincolor
>> 16) & 0xff) / 256.0;
53 if(ctx
->pi
->ppd
->ColorDevice
!= CD_False
) {
54 pscolor
->type
= PSCOLOR_RGB
;
55 pscolor
->value
.rgb
.r
= r
;
56 pscolor
->value
.rgb
.g
= g
;
57 pscolor
->value
.rgb
.b
= b
;
59 PSRGB scale
= rgb_to_grayscale_scale();
60 pscolor
->type
= PSCOLOR_GRAY
;
61 pscolor
->value
.gray
.i
= r
* scale
.r
+ g
* scale
.g
+ b
* scale
.b
;
67 /***********************************************************************
70 COLORREF
PSDRV_SetBkColor( print_ctx
*ctx
, COLORREF color
)
72 PSDRV_CreateColor(ctx
, &ctx
->bkColor
, color
);
77 /***********************************************************************
80 COLORREF
PSDRV_SetTextColor( print_ctx
*ctx
, COLORREF color
)
82 PSDRV_CreateColor(ctx
, &ctx
->font
.color
, color
);
83 ctx
->font
.set
= FALSE
;