Sha256: 14410763920128e2213de7ec8966ecfe35c15bde8edd94a10650eafe268288e6

Contents?: true

Size: 1 KB

Versions: 11

Compression:

Stored size: 1 KB

Contents

class PSD
  module ImageMode
    module CMYK
      private

      def set_cmyk_channels
        @channels_info = [
          { id: 0 },
          { id: 1 },
          { id: 2 },
          { id: 3 }
        ]

        @channels_info << {id: -1} if channels == 5
      end

      def combine_cmyk_channel
        cmyk_channels = @channels_info.
          map    { |ch| ch[:id] }.
          reject { |ch| ch < -1 }

        (0...@num_pixels).step(pixel_step) do |i|
          c = m = y = k = 0
          a = 255

          cmyk_channels.each_with_index do |chan, index|
            val = @channel_data[i + (@channel_length * index)]

            case chan
            when -1 then a = val
            when 0 then c = val
            when 1 then m = val
            when 2 then y = val
            when 3 then k = val
            end
          end

          rgb = PSD::Color.cmyk_to_rgb(255 - c, 255 - m, 255 - y, 255 - k)
          @pixel_data.push ChunkyPNG::Color.rgba(*rgb.values, a)
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
psd-3.9.0 lib/psd/image_modes/cmyk.rb
psd-3.8.0 lib/psd/image_modes/cmyk.rb
psd-3.7.0 lib/psd/image_modes/cmyk.rb
psd-3.6.0 lib/psd/image_modes/cmyk.rb
psd-3.5.0 lib/psd/image_modes/cmyk.rb
psd-3.4.0 lib/psd/image_modes/cmyk.rb
psd-3.3.3 lib/psd/image_modes/cmyk.rb
psd-3.3.2 lib/psd/image_modes/cmyk.rb
psd-3.3.1 lib/psd/image_modes/cmyk.rb
psd-3.2.4 lib/psd/image_modes/cmyk.rb
psd-3.2.3 lib/psd/image_modes/cmyk.rb