lib/rabbit/image/base.rb in rabbit-2.1.2 vs lib/rabbit/image/base.rb in rabbit-2.1.3

- old
+ new

@@ -1,8 +1,9 @@ require "gdk_pixbuf2" require "rabbit/utils" +require "rabbit/image-data-loader" module Rabbit module ImageManipulable class Base @@ -82,23 +83,20 @@ def normalize_prop_key(key) key.to_s.gsub(/-/, "_") end - def load_by_pixbuf_loader(data) - loader = Gdk::PixbufLoader.new - id = loader.signal_connect("size_prepared") do |l, width, height| - @width = width - @height = height - end + def load_data(data) + loader = ImageDataLoader.new(data) begin - loader.last_write(data) - rescue Gdk::PixbufError - loader.close rescue Gdk::PixbufError + loader.load + rescue ImageLoadError raise ImageLoadError.new("#{@filename}: #{$!.message}") end - loader.signal_handler_disconnect(id) - loader + + @width = loader.width + @height = loader.height + loader.pixbuf end end end end