Skip to content

Commit

Permalink
Documented header
Browse files Browse the repository at this point in the history
  • Loading branch information
meltingice committed Jul 26, 2013
1 parent 7304aef commit 200cc44
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/psd/header.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class PSD
# Describes the Header for the PSD file, which is the first section of the file.
class Header < BinData::Record
endian :big

Expand All @@ -17,6 +18,8 @@ class Header < BinData::Record
uint32 :color_data_len
skip length: :color_data_len

# 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.
MODES = [
'Bitmap',
'GrayScale',
Expand All @@ -36,6 +39,7 @@ class Header < BinData::Record
'Duotone16'
]

# Get the human-readable color mode name.
def mode_name
if mode >= 0 && mode <= 15
MODES[mode]
Expand All @@ -44,10 +48,12 @@ def mode_name
end
end

# Width of the entire document in pixels.
def width
cols
end

# Height of the entire document in pixels.
def height
rows
end
Expand Down

0 comments on commit 200cc44

Please sign in to comment.