Class: Exerb::Resource::GroupIcon::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/exerb/resource/group_icon.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, width, height, bit_count, size) ⇒ Entry

Returns a new instance of Entry.



48
49
50
51
52
53
54
# File 'lib/exerb/resource/group_icon.rb', line 48

def initialize(id, width, height, bit_count, size)
  @id        = id
  @widht     = width
  @height    = height
  @bit_count = bit_count
  @size      = size
end

Instance Attribute Details

#bit_countObject

Returns the value of attribute bit_count.



56
57
58
# File 'lib/exerb/resource/group_icon.rb', line 56

def bit_count
  @bit_count
end

#heightObject

Returns the value of attribute height.



56
57
58
# File 'lib/exerb/resource/group_icon.rb', line 56

def height
  @height
end

#idObject

Returns the value of attribute id.



56
57
58
# File 'lib/exerb/resource/group_icon.rb', line 56

def id
  @id
end

#sizeObject

Returns the value of attribute size.



56
57
58
# File 'lib/exerb/resource/group_icon.rb', line 56

def size
  @size
end

#widthObject

Returns the value of attribute width.



56
57
58
# File 'lib/exerb/resource/group_icon.rb', line 56

def width
  @width
end

Instance Method Details

#packObject



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/exerb/resource/group_icon.rb', line 58

def pack
  case @bit_count
  when 4 then cc, bc = 16, 4
  when 8 then cc, bc =  0, 8
  when 24 then cc, bc = 0, 0  # cjc 2015-11-06
  else raise "invalid bit count -- #{@bit_count}"
  end

  icon_dir_entry = Exerb::Win32::Struct::IconResEntry.new
  icon_dir_entry.width        = @widht
  icon_dir_entry.height       = @height
  icon_dir_entry.color_count  = cc
  icon_dir_entry.reserved     = 0
  icon_dir_entry.planes       = 1
  icon_dir_entry.bit_count    = bc
  icon_dir_entry.bytes_in_res = @size
  icon_dir_entry.image_offset = @id

  return icon_dir_entry.pack
end