Class: PSD::Header
- Inherits:
-
Object
- Object
- PSD::Header
- Defined in:
- lib/psd/header.rb
Constant Summary collapse
- MODES =
All of the color modes are stored internally as a short from 0-15. This is a mapping of that value to a human-readable name.
[ 'Bitmap', 'GrayScale', 'IndexedColor', 'RGBColor', 'CMYKColor', 'HSLColor', 'HSBColor', 'Multichannel', 'Duotone', 'LabColor', 'Gray16', 'RGB48', 'Lab48', 'CMYK64', 'DeepMultichannel', 'Duotone16' ].freeze
Instance Attribute Summary collapse
-
#channels ⇒ Object
readonly
Returns the value of attribute channels.
-
#cols ⇒ Object
(also: #width)
readonly
Returns the value of attribute cols.
-
#depth ⇒ Object
readonly
Returns the value of attribute depth.
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#rows ⇒ Object
(also: #height)
readonly
Returns the value of attribute rows.
-
#sig ⇒ Object
readonly
Returns the value of attribute sig.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #big? ⇒ Boolean
- #cmyk? ⇒ Boolean
-
#initialize(file) ⇒ Header
constructor
A new instance of Header.
- #mode_name ⇒ Object
- #parse! ⇒ Object
- #rgb? ⇒ Boolean
Constructor Details
#initialize(file) ⇒ Header
Returns a new instance of Header.
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/psd/header.rb', line 29 def initialize(file) @file = file @sig = nil @version = nil @channels = nil @rows = nil @cols = nil @depth = nil @mode = nil end |
Instance Attribute Details
#channels ⇒ Object (readonly)
Returns the value of attribute channels.
3 4 5 |
# File 'lib/psd/header.rb', line 3 def channels @channels end |
#cols ⇒ Object (readonly) Also known as: width
Returns the value of attribute cols.
3 4 5 |
# File 'lib/psd/header.rb', line 3 def cols @cols end |
#depth ⇒ Object (readonly)
Returns the value of attribute depth.
3 4 5 |
# File 'lib/psd/header.rb', line 3 def depth @depth end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
3 4 5 |
# File 'lib/psd/header.rb', line 3 def mode @mode end |
#rows ⇒ Object (readonly) Also known as: height
Returns the value of attribute rows.
3 4 5 |
# File 'lib/psd/header.rb', line 3 def rows @rows end |
#sig ⇒ Object (readonly)
Returns the value of attribute sig.
3 4 5 |
# File 'lib/psd/header.rb', line 3 def sig @sig end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
3 4 5 |
# File 'lib/psd/header.rb', line 3 def version @version end |
Instance Method Details
#big? ⇒ Boolean
62 63 64 |
# File 'lib/psd/header.rb', line 62 def big? version == 2 end |
#cmyk? ⇒ Boolean
70 71 72 |
# File 'lib/psd/header.rb', line 70 def cmyk? mode == 4 end |
#mode_name ⇒ Object
58 59 60 |
# File 'lib/psd/header.rb', line 58 def mode_name MODES[@mode] end |
#parse! ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/psd/header.rb', line 41 def parse! @sig = @file.read_string(4) @version = @file.read_ushort # Reserved bytes, must be 0 @file.seek 6, IO::SEEK_CUR @channels = @file.read_ushort @rows = @file.read_uint @cols = @file.read_uint @depth = @file.read_ushort @mode = @file.read_ushort color_data_len = @file.read_uint @file.seek color_data_len, IO::SEEK_CUR end |
#rgb? ⇒ Boolean
66 67 68 |
# File 'lib/psd/header.rb', line 66 def rgb? mode == 3 end |