Class: Rixmap::Format::PNG::Chunk::PLTEChunk
- Defined in:
- lib/rixmap/format/png/chunk.rb
Overview
PLTパレットチャンク
Constant Summary collapse
- TYPE =
PLTEチャンクタイプ
'PLTE'- LAYOUT =
pack用PLTEチャンクデータレイアウト
'C*'
Instance Method Summary collapse
-
#[](offset) ⇒ Array
指定番号のカラーデータ (3バイト) を取得します.
-
#[]=(offset, rgb) ⇒ Object
指定番号のカラーデータを更新します.
-
#initialize ⇒ PLTEChunk
constructor
A new instance of PLTEChunk.
- #pack ⇒ Object
- #unpack ⇒ Object
Methods inherited from BaseChunk
#copysafe?, #data, #data=, #optional?, #private?, #standard?, #type
Constructor Details
#initialize ⇒ PLTEChunk
Returns a new instance of PLTEChunk.
174 175 176 177 |
# File 'lib/rixmap/format/png/chunk.rb', line 174 def initialize() @colors = [] super(PLTEChunk::TYPE) end |
Instance Method Details
#[](offset) ⇒ Array
指定番号のカラーデータ (3バイト) を取得します.
データオフセットではなく、3バイトごとに区切られたカラーのオフセットであることに注意.
185 186 187 |
# File 'lib/rixmap/format/png/chunk.rb', line 185 def [](offset) return @colors[offset * 3, 3] end |
#[]=(offset, rgb) ⇒ Object
指定番号のカラーデータを更新します.
193 194 195 |
# File 'lib/rixmap/format/png/chunk.rb', line 193 def []=(offset, rgb) @colors[offset * 3, 3] = rgb end |
#pack ⇒ Object
197 198 199 |
# File 'lib/rixmap/format/png/chunk.rb', line 197 def pack() @data = @colors.pack(PLTEChunk::LAYOUT) end |
#unpack ⇒ Object
201 202 203 |
# File 'lib/rixmap/format/png/chunk.rb', line 201 def unpack() @colors = @data.unpack(PLTEChunk::LAYOUT) end |