[gs-cvs] rev 7162 - trunk/gs/lib
alexcher at ghostscript.com
alexcher at ghostscript.com
Sat Nov 4 09:05:23 PST 2006
Author: alexcher
Date: 2006-11-04 09:05:22 -0800 (Sat, 04 Nov 2006)
New Revision: 7162
Modified:
trunk/gs/lib/gs_cspace.ps
trunk/gs/lib/gs_indxd.ps
Log:
Change attributes of the array form of the device color spaces.
Fix a bug in HSB to RGB conversion introduced in rev. 7124.
Simplify equality testing of color spaces: names match corresponding
array forms, all other match when color space arrays are equal.
Accept float value as a color value for an indexed color space.
Fixes CET 09-06.PS and many other test cases.
DIFFERENCES:
Progression in colorcir.ps compared to a revs. 7124..7161
Modified: trunk/gs/lib/gs_cspace.ps
===================================================================
--- trunk/gs/lib/gs_cspace.ps 2006-11-04 15:23:19 UTC (rev 7161)
+++ trunk/gs/lib/gs_cspace.ps 2006-11-04 17:05:22 UTC (rev 7162)
@@ -237,7 +237,14 @@
userdict /.cspace_util 80 dict put
.cspace_util begin
+
+% Global, read-only, unpacked, array-form device color spaces
%
+/DeviceGray_array /DeviceGray 1 array astore readonly def
+/DeviceRGB_array /DeviceRGB 1 array astore readonly def
+/DeviceCMYK_array /DeviceCMYK 1 array astore readonly def
+
+%
% Colorspacedict is initially in .cspace_util; it is copied to level2dict
% in the Level 2 initialization code to retain compatibility with
% earlier implementations.
@@ -387,9 +394,8 @@
% NB: This should come prior to the redefinition of setcolorspace, and
% must use an array operand.
%
-[ /DeviceGray ] setcolorspace
+//DeviceGray_array setcolorspace
-
%
% <c1> ... <cn> setcolor -
%
@@ -461,22 +467,18 @@
%
/_setcolorspace
{
- {
- % see if the operand space is the same as the current space
- currentcolorspace dup length 1 eq
- {
- 0 get
- 2 index dup type dup /arraytype eq exch /packedarraytype eq or
- {
- dup length 1 eq
- { 0 get }
- if
- }
- if
+ { % See if the operand space is the same as the current space.
+ % The test is intentionaly conservative to meet CET 09-06.
+ 1 index % [/new] bool [/new]
+ type /nametype eq
+ { currentcolorspace 0 get % [/new] bool /old
+ 2 index eq % [/new] bool bool
}
- { 2 index }
+ { currentcolorspace % [/new] bool [/old]
+ 2 index eq % [/new] bool eq
+ }
ifelse
- eq and dup
+ and dup
{
%
% If PDFfile is defined on the dictionary stack, this is a
@@ -532,7 +534,7 @@
%
%
/initgraphics
- { initgraphics [ /DeviceGray ] cvlit forcesetcolorspace }
+ { initgraphics //DeviceGray_array forcesetcolorspace }
.bind systemdict begin odef end
systemdict /setcolorspace .undef
@@ -551,7 +553,7 @@
%
/setgray
{
- { [ /DeviceGray ] cvlit //setcolorspace //setcolor }
+ { //DeviceGray_array //setcolorspace //setcolor }
stopped
{ /setgray .systemvar $error /errorname get signalerror }
if
@@ -560,7 +562,7 @@
/setrgbcolor
{
- { [ /DeviceRGB ] cvlit //setcolorspace //setcolor }
+ { //DeviceRGB_array //setcolorspace //setcolor }
stopped
{ /setrgbcolor .systemvar $error /errorname get signalerror }
if
@@ -572,7 +574,7 @@
pop
/setcmykcolor
{
- { [ /DeviceCMYK ] cvlit //setcolorspace //setcolor }
+ { //DeviceCMYK_array //setcolorspace //setcolor }
stopped
{ /setcmykcolor .systemvar $error /errorname get signalerror }
if
@@ -925,21 +927,21 @@
/.hsb_2_rgb
{
- 3 { 0.0 max 1.0 min 3 1 roll } repeat
- 1.0 2 index sub 1 index mul % (1 - s) * br
- 3 -1 roll 2 index mul 6.0 mul % 6 * s * br
- 4 -1 roll % stack: <br> <(1 - s) * br> <6 * s * br> <h>
+ 3 { 0.0 max 1.0 min 3 1 roll } repeat % h s b
+ 1.0 2 index sub 1 index mul % h s b (1-s)*b
+ 3 -1 roll 2 index mul 6.0 mul % h b (1-s)*b 6*s*b
+ 4 -1 roll % b (1-s)*b=nm 6*s*b=md h
% array of procedures for the 7 hue cases
{
- % 0 ==> r >= g >= b
- { mul 1 index add exch }
+ % 0 ==> r >= g >= b % b nm md h
+ { mul 1 index add exch }
% 1 ==> g >= r >= b
{ //.f1_3 exch sub mul 1 index add 3 1 roll }
% 2 ==> g >= b >= r
- { //.f1_3 mul 1 index add 3 1 roll exch 3 -1 roll }
+ { //.f1_3 sub mul 1 index add 3 1 roll exch 3 -1 roll }
% 3 ==> b >= g >= r
{ //.f2_3 exch sub mul 1 index add 3 -1 roll }
@@ -955,7 +957,7 @@
% the calculations.
{ pop pop dup }
}
- 1 index 6.0 mul cvi % (int)(6 * h)
+ 1 index 6.0 mul cvi % b (1-s)*b 6*s*b h {} int(6*h)
get exec
}
bind def
@@ -984,5 +986,9 @@
}
bind systemdict begin odef end
+currentdict /DeviceGray_array .undef
+currentdict /DeviceRGB_array .undef
+currentdict /DeviceCMYK_array .undef
+
end % .cspace_util
.setglobal
Modified: trunk/gs/lib/gs_indxd.ps
===================================================================
--- trunk/gs/lib/gs_indxd.ps 2006-11-04 15:23:19 UTC (rev 7161)
+++ trunk/gs/lib/gs_indxd.ps 2006-11-04 17:05:22 UTC (rev 7162)
@@ -176,7 +176,8 @@
}
bind
- /cs_prepare_color //validate_1
+ % Adobe implementations accept floating point values
+ /cs_prepare_color { //validate_1 exec cvi } bind
%
% Adobe implementations always execute a lookup procedure when setcolor
More information about the gs-cvs
mailing list