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.



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

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.



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

def bit_count
  @bit_count
end

#heightObject

Returns the value of attribute height.



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

def height
  @height
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#sizeObject

Returns the value of attribute size.



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

def size
  @size
end

#widthObject

Returns the value of attribute width.



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

def width
  @width
end

Instance Method Details

#packObject



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

def pack
  case @bit_count
  when 1 then cc, bc = 2, 1
  when 4 then cc, bc = 16, 4
  when 8 then cc, bc =  0, 8
  when 24 then cc, bc = 0, 24
  when 32 then cc, bc =  0, 32
  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