Method: TkHTML_File_Viewer#image_cmd

Defined in:
sample/tkextlib/tkHTML/ss.rb

#image_cmd(hs, *args) ⇒ Object



188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'sample/tkextlib/tkHTML/ss.rb', line 188

def image_cmd(hs, *args)
  fn = args[0]

  if @old_imgs.key?(fn)
    return (@images[fn] = @old_imgs.delete(fn))
  end

  begin
    img = TkPhotoImage.new(:file=>fn)
  rescue
    return ((hs)? @@smallgray: @@biggray)
  end

  if hs
    img2 = TkPhotoImage.new
    img2.copy(img, :subsample=>[2,2])
    img.delete
    img = img2
  end

  if img.width * img.height > 20000
    b = TkPhotoImage.new(:width=>img.width, :height=>img.height)
    @big_imgs[b] = img
    img = b
    Tk.after_idle(proc{ move_big_image(b) })
  end

  @images[fn] = img

  img
end