cannot load file with GdkPixbuf::Pixbuf.new_from_resource
cedlemo opened this issue · comments
I try to load an image file and create a Pixbuf but I have an error saying that the file doesn't exist:
CURRENT_DIR = File.dirname(__FILE__)
if File.exist?(File.expand_path(CURRENT_DIR + "/gtk-logo-256.png"))
pixbuff = GdkPixbuf::Pixbuf.new_from_resource(File.expand_path(CURRENT_DIR + "/gtk-logo-256.png"))
end
The message error:
/home/cedlemo/.gem/ruby/2.0.0/gems/gir_ffi-0.5.1/lib/gir_ffi/arg_helper.rb:99:in `check_error': The resource at '/home/cedlemo/projets/ruby_ffi_test/gtk3-widget-factory/gtk-logo-256.png' does not exist (RuntimeError)
from (eval):5:in `new_from_resource'
from /home/cedlemo/.gem/ruby/2.0.0/gems/gir_ffi-0.5.1/lib/gir_ffi/class_base.rb:35:in `setup_and_call'
from (eval):3:in `new_from_resource'
from gtk3-widget-factory.rb:55:in `<main>'
What is wrong with my code?
#new_from_resource
does not work with regular files. You need to use #new_from_file
. More info about resources here: http://blogs.gnome.org/alexl/2012/01/26/resources-in-glib/