public
Description: Fast, Nimble PDF Writer for Ruby
Homepage: http://prawn.majesticseacreature.com
Clone URL: git://github.com/sandal/prawn.git
Set an explicit Decode Array for CMYK jpg images
- see section 4.8.4 of the spec. We're swapping Dmin and Dmax to invert
  colours.
yob (author)
Fri Oct 31 08:32:37 -0700 2008
commit  827887ea2e1ca845a07af46241c83050440ae35e
tree    0a660c4ca4117d40dc34d905ef10a0fae73443dc
parent  0c97cc776ab65adc50e317768a6c3cc246cca9ed
...
140
141
142
 
 
143
144
145
146
 
147
148
149
...
153
154
155
 
 
 
 
 
 
 
 
156
157
158
...
140
141
142
143
144
145
146
147
 
148
149
150
151
...
155
156
157
158
159
160
161
162
163
164
165
166
167
168
0
@@ -140,10 +140,12 @@ module Prawn
0
       color_space = case jpg.channels
0
       when 1
0
         :DeviceGray
0
+      when 3
0
+        :DeviceRGB
0
       when 4
0
         :DeviceCMYK
0
       else
0
-        :DeviceRGB
0
+        raise ArgumentError, 'JPG uses an unsupported number of channels'
0
       end
0
       obj = ref(:Type       => :XObject,
0
           :Subtype          => :Image,
0
@@ -153,6 +155,14 @@ module Prawn
0
           :Width            => jpg.width,
0
           :Height           => jpg.height,
0
           :Length           => data.size ) 
0
+
0
+      # add extra decode params for CMYK images. By swapping the
0
+      # min and max values from the default, we invert the colours. See
0
+      # section 4.8.4 of the spec.
0
+      if color_space == :DeviceCMYK
0
+        obj.data[:Decode] = [ 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0 ]
0
+      end
0
+
0
       obj << data
0
       return obj
0
     end

Comments