# File lib/native_file_types/c64/C64GeosFile.rb, line 74
def to_icon
  canvas = PNG::Canvas.new icon_width, icon_height, PNG::Color::Green

  buffer=icon_bitmap
  icon_height.times do |y|
    row_data=buffer[y*3,3]
    x=0
    row_data.each_byte do |byte|
      8.times do |bit_offset|        
        bitmask=0b10000000>>bit_offset    
#        puts "y #{y} x #{x} byte #{"%08b" % byte} bit #{bit_offset} #{"%08b" % bitmask}"

        if ((byte & bitmask)==bitmask) then
          canvas[x, y]= icon_foreground
        else
          canvas[x, y]= icon_background
        end
        x+=1
      end
    end
  end
  png = PNG.new canvas
  result=png.raw_bytes
  result
end