class MyImage
this file is part of manqod manqod is distributed under the CDDL licence the author of manqod is Dobai-Pataky Balint(dpblnt@gmail.com)
Attributes
filename[R]
image_id[R]
pb[R]
Public Class Methods
new(image_id,from_client=false)
click to toggle source
Calls superclass method
# File lib/Common/MyImage.rb, line 7 def initialize(image_id,from_client=false) @image_id=image_id @filename=nil begin row=if from_client then ManqodDB.instance.ccache.get("im[#{image_id}]") else ManqodDB.instance.cache.get("im[#{image_id}]") end if row @filename=row["filename"] a=Array.new row['filedata'].each_byte{|v|a.push(v)} pixdata=Gdk::Pixdata.deserialize(a) @pb=pixdata.to_pixbuf(true) super(pb) else raise end rescue =>e ewarn("cannot load image #{from_client ? "client":""} #{image_id}: #{e}") super(Gtk::Stock::MISSING_IMAGE,Gtk::IconSize::MENU) end end
Public Instance Methods
resize(icon_size_name=nil)
click to toggle source
# File lib/Common/MyImage.rb, line 30 def resize(icon_size_name=nil) new_pb=nil if storage_type==Gtk::Image::PIXBUF && icon_size_name case icon_size_name.class.name when 'Fixnum' then nw,nh =[ icon_size_name,icon_size_name] when 'String' then nw,nh =Gtk::IconSize.lookup(Gtk::IconSize.from_name(icon_size_name)) end new_pb=pb.scale(nw,nh) end edebug("resized from #{pixbuf.height if pb}x#{pixbuf.width if pb} to #{new_pb.height if new_pb}x#{new_pb.width if new_pb}","image") new_pb end
to_s()
click to toggle source
# File lib/Common/MyImage.rb, line 43 def to_s "MyImage{id:#{image_id},name:#{filename}}" end