Class: Rixmap::Format::PNG::Chunk::BaseChunk

Inherits:
Object
  • Object
show all
Defined in:
lib/rixmap/format/png/chunk.rb

Overview

PNGチャンクベースクラス

Direct Known Subclasses

IDATChunk, IENDChunk, IHDRChunk, PLTEChunk

Instance Method Summary collapse

Constructor Details

#initialize(type, data = nil) ⇒ BaseChunk

チャンクを初期化します.

Parameters:

  • type (String)

    チャンクタイプ

  • data (String) (defaults to: nil)

    チャンクデータ



40
41
42
43
44
45
# File 'lib/rixmap/format/png/chunk.rb', line 40

def initialize(type, data = nil)
  @type = type
  @data = nil

  self.data = data unless data.nil?
end

Instance Method Details

#copysafe?Boolean

コピー安全なチャンクかどうかを返します.

Returns:

  • (Boolean)

    コピー安全なチャンクならtrue



95
96
97
# File 'lib/rixmap/format/png/chunk.rb', line 95

def copysafe?()
  return (@type[3].ord & 0x20) != 0
end

#dataString

チャンクデータを返します.

Returns:

  • (String)

    チャンクデータ



57
58
59
60
# File 'lib/rixmap/format/png/chunk.rb', line 57

def data()
  self.pack()
  return @data
end

#data=(data) ⇒ Object

チャンクデータを更新します.

Parameters:

  • data (String)

    チャンクデータ



65
66
67
68
69
# File 'lib/rixmap/format/png/chunk.rb', line 65

def data=(data)
  @data = data
  self.unpack()
  return nil
end

#optional?Boolean

補助チャンクかどうかを返します.

Returns:

  • (Boolean)

    補助チャンクならtrue



74
75
76
# File 'lib/rixmap/format/png/chunk.rb', line 74

def optional?()
  return (@type[0].ord & 0x20) != 0
end

#private?Boolean

プライベートチャンクかどうかを返します.

Returns:

  • (Boolean)

    プライベートチャンクならtrue



81
82
83
# File 'lib/rixmap/format/png/chunk.rb', line 81

def private?()
  return (@type[1].ord & 0x20) != 0
end

#standard?Boolean

標準チャンクかどうかを返します.

Returns:

  • (Boolean)

    標準チャンクならtrue



88
89
90
# File 'lib/rixmap/format/png/chunk.rb', line 88

def standard?()
  return (@type[2].ord & 0x20) == 0
end

#typeString

チャンクタイプを返します.

Returns:

  • (String)

    チャンクタイプ



50
51
52
# File 'lib/rixmap/format/png/chunk.rb', line 50

def type()
  return @type
end