Class: PSD::Curves
Instance Attribute Summary collapse
-
#curves ⇒ Object
readonly
Returns the value of attribute curves.
Attributes inherited from LayerInfo
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from LayerInfo
Constructor Details
This class inherits a constructor from PSD::LayerInfo
Instance Attribute Details
#curves ⇒ Object (readonly)
Returns the value of attribute curves.
9 10 11 |
# File 'lib/psd/layer/info/curves.rb', line 9 def curves @curves end |
Class Method Details
.should_parse?(key) ⇒ Boolean
5 6 7 |
# File 'lib/psd/layer/info/curves.rb', line 5 def self.should_parse?(key) key == 'curv' end |
Instance Method Details
#parse ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/psd/layer/info/curves.rb', line 11 def parse # Padding, spec is wrong. Maybe Photoshop bug? @file.seek 1, IO::SEEK_CUR # Version @file.seek 2, IO::SEEK_CUR tag = @file.read_int curve_count = 0 # Legacy data, it looks like there are 32 positions # where you can adjust the curve, and there is a chunk # of 32 bytes that determine whether that chunk is set. 32.times do |i| curve_count += 1 if tag & (1 << i) > 0 end @curves = [] curve_count.times do |i| # Before each curve is a channel index count = 0 curve = {} 32.times do |j| if tag & (1 << j) > 0 if count == i curve[:channel_index] = j break end count += 1 end end point_count = @file.read_short curve[:points] = point_count.times.map do { output_value: @file.read_short, input_value: @file.read_short } end @curves << curve end if @file.tell < @section_end - 4 tag = @file.read_string(4) raise "Extra curves key error: #{tag}" if tag != 'Crv ' @file.seek 2, IO::SEEK_CUR curve_count = @file.read_int curve_count.times do curve = { channel_index: @file.read_short } point_count = @file.read_short curve[:points] = point_count.times.map do { output_value: @file.read_short, input_value: @file.read_short } end @curves << curve end end end |