Forum: FXRuby writing image into a ruby file

96c1bf3e6e2e7fca41559e4c8911fe46?d=identicon&s=25 Ben Goh (bgoh29)
on 2009-11-13 04:46
hi all,

I remember (very) long time ago, there was some information posted about
loading an image into a ruby file. I am trying to look for the sniplet
of the code but couldn't find anytying. Just wondering if anyone could
help.

This is some of the extract of the code:-

#I am trying to write the content of the icon into an include file.

def loadIcon(file)
begin
    File.open(file, "rb")  do |f|
      icon = FXICOIcon.new(getApp(), f.read)
    end
     icon
    rescue
      raise RuntimeError, "Couldn't load icon: #{file}"
    end
end

#I'm trying load 'Australia-Flag.ico' and store it as a constant
'aus.rb'.
 filename = 'c:\FXRUbySample\Australia-Flag.ico'
 icon75 = loadIcon(filename)

   File.new('c:\FXRubySample\aus.rb', 'wb')
   File.open('c:\FXRubySample\aus.rb','wb') do |f|
     #puts icon75
     f.syswrite icon75
  end

#none of the puts and syswrite works.
This topic is locked and can not be replied to.