2 * PostScript colour functions
4 * Copyright 1998 Huw D M Davies
9 #include "debugtools.h"
11 DEFAULT_DEBUG_CHANNEL(psdrv
)
13 /**********************************************************************
16 * Return TRUE if col1 == col2
18 BOOL
PSDRV_CmpColor(PSCOLOR
*col1
, PSCOLOR
*col2
)
20 if(col1
->type
!= col2
->type
)
25 if(col1
->value
.gray
.i
== col2
->value
.gray
.i
)
29 if( col1
->value
.rgb
.r
== col2
->value
.rgb
.r
&&
30 col1
->value
.rgb
.g
== col2
->value
.rgb
.g
&&
31 col1
->value
.rgb
.b
== col2
->value
.rgb
.b
)
35 ERR("Unknown colour type %d\n", col1
->type
);
41 /**********************************************************************
44 * Copies col2 into col1. Return FALSE on error.
46 BOOL
PSDRV_CopyColor(PSCOLOR
*col1
, PSCOLOR
*col2
)
51 col1
->value
.gray
.i
= col2
->value
.gray
.i
;
55 col1
->value
.rgb
.r
= col2
->value
.rgb
.r
;
56 col1
->value
.rgb
.g
= col2
->value
.rgb
.g
;
57 col1
->value
.rgb
.b
= col2
->value
.rgb
.b
;
61 ERR("Unknown colour type %d\n", col1
->type
);
65 col1
->type
= col2
->type
;
70 /**********************************************************************
73 * Creates a PostScript colour from a COLORREF.
74 * Result is grey scale if ColorDevice field of ppd is FALSE else an
75 * rgb colour is produced.
77 void PSDRV_CreateColor( PSDRV_PDEVICE
*physDev
, PSCOLOR
*pscolor
,
80 int ctype
= wincolor
>> 24;
83 if(ctype
!= 0 && ctype
!= 2)
84 FIXME("Colour is %08lx\n", wincolor
);
86 r
= (wincolor
& 0xff) / 256.0;
87 g
= ((wincolor
>> 8) & 0xff) / 256.0;
88 b
= ((wincolor
>> 16) & 0xff) / 256.0;
90 if(physDev
->pi
->ppd
->ColorDevice
) {
91 pscolor
->type
= PSCOLOR_RGB
;
92 pscolor
->value
.rgb
.r
= r
;
93 pscolor
->value
.rgb
.g
= g
;
94 pscolor
->value
.rgb
.b
= b
;
96 pscolor
->type
= PSCOLOR_GRAY
;
97 /* FIXME configurable */
98 pscolor
->value
.gray
.i
= r
* 0.3 + g
* 0.59 + b
* 0.11;
104 /***********************************************************************
107 COLORREF
PSDRV_SetBkColor( DC
*dc
, COLORREF color
)
109 PSDRV_PDEVICE
*physDev
= (PSDRV_PDEVICE
*)dc
->physDev
;
112 oldColor
= dc
->w
.backgroundColor
;
113 dc
->w
.backgroundColor
= color
;
115 PSDRV_CreateColor(physDev
, &physDev
->bkColor
, color
);
121 /***********************************************************************
124 COLORREF
PSDRV_SetTextColor( DC
*dc
, COLORREF color
)
126 PSDRV_PDEVICE
*physDev
= (PSDRV_PDEVICE
*)dc
->physDev
;
129 oldColor
= dc
->w
.textColor
;
130 dc
->w
.textColor
= color
;
132 PSDRV_CreateColor(physDev
, &physDev
->font
.color
, color
);
133 physDev
->font
.set
= FALSE
;