Sha256: 8c655f50031c199bc2c76a695a40415b3eb3120de8df44f8b953f9d2431eff30

Contents?: true

Size: 881 Bytes

Versions: 7

Compression:

Stored size: 881 Bytes

Contents

class PSD::Image::Mode
  module Greyscale
    private

    def combine_greyscale8_channel
      if channels == 2
        # We have an alpha channel
        @num_pixels.times do |i|
          alpha = @channel_data[i]
          grey = @channel_data[@channel_length + i]

          @pixel_data.push grey, grey, grey, alpha
        end
      else
        @num_pixels.times do |i|
          @pixel_data.push *([@channel_data[i]] * 3), 255
        end
      end
    end

    def combine_greyscale_channel
      if channels == 2
        (0...@num_pixels).step(pixel_step) do |i|
          alpha = @channel_data[i]
          grey = @channel_data[@channel_length + i]

          @pixel_data.push grey, grey, grey, alpha
        end
      else
        (0...@num_pixels).step(pixel_step) do |i|
          @pixel_data.push *([@channel_data[i]] * 3), 255
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
psd-0.4.2 lib/psd/image_modes/greyscale.rb
psd-0.4.1 lib/psd/image_modes/greyscale.rb
psd-0.4.0 lib/psd/image_modes/greyscale.rb
psd-0.3.5 lib/psd/image_modes/greyscale.rb
psd-0.3.4 lib/psd/image_modes/greyscale.rb
psd-0.3.3 lib/psd/image_modes/greyscale.rb
psd-0.3.2 lib/psd/image_modes/greyscale.rb