Forum: FXRuby writing image into a ruby file

Posted by 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.
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.