From: nagai@... Date: 2003-02-05T00:43:15+09:00 Subject: Re: How to save Tk canvas as picture/create image from canvas? Hi, From: Ralf Subject: Re: How to save Tk canvas as picture/create image from canvas? Date: Tue, 4 Feb 2003 22:13:15 +0900 Message-ID: <3e3fb939$1@epflnews.epfl.ch> > > I thought your Tcl/Tk already supported the option. > > Well, first of all, you must let your Tcl/Tk supports the option. > > If the option is supported by Tcl/Tk ext library, > > you must load the library on your Ruby/Tk by TkPackage module. > > If the Tcl/Tk ext library only add support of new formats, > > probably you don't need to define new classes for Ruby/Tk. > ??? > Sorry, Sir, but you probably can't imagine, how confused a Windows person > can be in a Unix world. > So I spent some time on this, managed (not sure about this) to install tkext, > but now I don't know what to do with it. The tkext test scripts don't run, > because I don't have tix, and I wasn't able to find out how to get it (... > Unix world). No, no, no. In this case, you don't need tcltk-ext library. :-) For testing new image format, I installed Tcl/Tk8.4.1 and Img 1.2.4 (Tk extend library; This supports '-format window'). First, I tested that the Img library works correctly with Tcl/Tk8.4.1. And next, compiled tcltklib with libtcl8.4.so/libtk8.4.so. Now, Tcl/Tk8.4.1 works with Ruby 1.6.8, and the following script (part) works fine. ----------------------------------------- require 'tk' TkPackage.require('Img', '1.2') c = TkCanvas.new.pack ... drawing on the canvas widget .... img = TkPhotoImage.new('format'=>'window', 'data'=>c) img.write('canvas-img.jpeg', 'format'=>'jpeg') ----------------------------------------- Because I failed to compile Img library with Tcl/Tk on my environment, I had to install a new verison of Tcl/Tk. But if your Tcl/Tk is supported by the DLL of Img library on Wndows, you will have no need to compile Tcl/Tk or the library. # You will be able to get Img DLL for Windows on Img developer's web page. I think it is not so difficult. > What is this TkPackage module? It is defined on tk.rb. It supports Tcl's package command which can load dynamic libraries of several Tcl/Tk extend libraries to normal Tcl/Tk. -- Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)