Method: Exerb::Resource::Icon.read

Defined in:
lib/exerb/resource/icon.rb

.read(input, width, height, bit_count) ⇒ Object

Raises:



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/exerb/resource/icon.rb', line 31

def self.read(input, width, height, bit_count)
  icon_file  = Exerb::Win32::IconFile.read(input)
  icon_entry = icon_file.entries.find { |entry| entry.width == width && entry.height == height && entry.bit_count == bit_count }
  raise(Exerb::ExerbError, "no such icon #{width}x#{height}x#{bit_count} in #{input}") unless icon_entry

  icon = self.new
  icon.width     = icon_entry.width
  icon.height    = icon_entry.height
  icon.bit_count = icon_entry.bit_count
  icon.value     = icon_entry.value

  return icon
end