Class: Mittsu::ImageLoader
- Inherits:
-
Object
- Object
- Mittsu::ImageLoader
- Defined in:
- lib/mittsu/loaders/image_loader.rb
Instance Attribute Summary collapse
-
#manager ⇒ Object
Returns the value of attribute manager.
Instance Method Summary collapse
-
#initialize(manager = DefaultLoadingManager) ⇒ ImageLoader
constructor
A new instance of ImageLoader.
- #load(url, flip: false, flop: false) ⇒ Object
Constructor Details
#initialize(manager = DefaultLoadingManager) ⇒ ImageLoader
Returns a new instance of ImageLoader.
8 9 10 |
# File 'lib/mittsu/loaders/image_loader.rb', line 8 def initialize(manager = DefaultLoadingManager) @manager = manager end |
Instance Attribute Details
#manager ⇒ Object
Returns the value of attribute manager.
6 7 8 |
# File 'lib/mittsu/loaders/image_loader.rb', line 6 def manager @manager end |
Instance Method Details
#load(url, flip: false, flop: false) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/mittsu/loaders/image_loader.rb', line 12 def load(url, flip: false, flop: false) chache_url = "#{url}?flip=#{flip}&flop=#{flop}" cached = Cache.get(url) return cached unless cached.nil? rm_image = Magick::Image.read(url).first rm_image = rm_image.flip if flip rm_image = rm_image.flop if flop rgba_data = rm_image.to_blob { |i| i.format = "RGBA" i.depth = 8 } image = Image.new(rm_image.columns, rm_image.rows, rgba_data) Cache.add(url, image) @manager.item_start(url) image end |