Re: [R] Using tcltk to display jpeg images

From: Philippe Grosjean <phgrosjean_at_sciviews.org>
Date: Tue 23 Aug 2005 - 23:12:48 EST

Jonathan Williams wrote:
> Thank you,
>
> I am running R 2.1.1 via Windows XP.
>
> Sorry, you will realise how little I know about this because I
> did not know that the operating system would make a difference!

No problems. Indeed, you have to install BINARIES of the img tcl package. One solution is to install a Tcl/Tk distribution that includes already that package. ActiveTcl is the one that comes to mind immediatelly. Here is the procedure to use it:

You know that you are using ActiveTcl, and not the Tcl package provided with R because the icon of that window is changed from a red "Tk" to the   brown plume that is the icon of ActiveState.

You should read also the R for Windows FAQ 3.6.

Finally, when it works, there is another (and perhaps simpler) way to load the Img tcl package, using the Tcl version distributed with R. You just have to specify: addTclPath("c:/tcl/lib"). So, you can start R normally (using the default Tcl distributed with it), and do:  > library(tcltk)
Loading Tcl/Tk interface ... done
 > addTclPath("c:/xtra/tcl/lib") # This is how you gain access to the ActiveTcl library!

 > R.base.dir <- system.file()
 > setwd(paste(R.base.dir,"/../../doc/html",sep=""))
 > tt <- tktoplevel()
 > tclRequire("Img")

<Tcl> 1.3
 > image1 <- tclVar()
 > tkcmd("image","create","photo",image1,file="logo.jpg") <Tcl> ::RTcl1
 > imgAsLabel <- tklabel(tt,image=image1,bg="white")  > tkpack(imgAsLabel)
<Tcl>

Note that you can relocate the /lib subdir of ActiveTcl, or only /lib/Img1.3 and use AddTclPath() to access it at the new location. This way, you don't have to install ActiveTcl on all the computers where you want to use Img. You just need to copy /lib/Img1.3 there and use AddTclPath(). However, take care of the ActiveState license that constrains you to download their software from their web site and to register. So, you can only use this method for multiple installations on your own computers... but not for redistribution!

Best,

Philippe Grosjean

..............................................<}))><........
  ) ) ) ) )
( ( ( ( ( Prof. Philippe Grosjean
  ) ) ) ) )
( ( ( ( ( Numerical Ecology of Aquatic Systems   ) ) ) ) ) Mons-Hainaut University, Pentagone (3D08) ( ( ( ( ( Academie Universitaire Wallonie-Bruxelles   ) ) ) ) ) 8, av du Champ de Mars, 7000 Mons, Belgium ( ( ( ( (
  ) ) ) ) ) phone: + 32.65.37.34.97, fax: + 32.65.37.30.54 ( ( ( ( ( email: Philippe.Grosjean@umh.ac.be   ) ) ) ) )
( ( ( ( ( web: http://www.umh.ac.be/~econum   ) ) ) ) ) http://www.sciviews.org ( ( ( ( (
..............................................................

>
> Jonathan
>
> -----Original Message-----
> From: Philippe Grosjean [mailto:phgrosjean@sciviews.org]
> Sent: 23 August 2005 10:19
> To: Jonathan Williams
> Cc: Ethz. Ch
> Subject: Re: [R] Using tcltk to display jpeg images
>
>
> Hello,
>
> You have to tell us on which platform you want to install the Tcl img
> package. If it is Windows, I can help.
> Best,
>
> Philippe
>
> ..............................................<}))><........
> ) ) ) ) )
> ( ( ( ( ( Prof. Philippe Grosjean
> ) ) ) ) )
> ( ( ( ( ( Numerical Ecology of Aquatic Systems
> ) ) ) ) ) Mons-Hainaut University, Pentagone (3D08)
> ( ( ( ( ( Academie Universitaire Wallonie-Bruxelles
> ) ) ) ) ) 8, av du Champ de Mars, 7000 Mons, Belgium
> ( ( ( ( (
> ) ) ) ) ) phone: + 32.65.37.34.97, fax: + 32.65.37.30.54
> ( ( ( ( ( email: Philippe.Grosjean@umh.ac.be
> ) ) ) ) )
> ( ( ( ( ( web: http://www.umh.ac.be/~econum
> ) ) ) ) ) http://www.sciviews.org
> ( ( ( ( (
> ..............................................................
>
> Jonathan Williams wrote:
>

>>Dear R Helpers,
>>
>>Does anyone know how to use tcltk to display jpeg images? The manual says
>>that
>>one must use Tk_PhotoCreateImageFormat to register the jpeg image handler.
>>The
>>"ActiveTcl User Guide"
>>(http://support.serv.ch/lang/tcl/img/doc/img-jpeg.html)
>>says:-
>>
>>"The package img::jpeg is a sub-package of Img. It can be loaded as a part
>>of the complete
>>Img support, via package require Img, or on its own, via package require
>>img::jpeg"
>>
>>I downloaded the tkimg1.3 file from
>>http://kent.dl.sourceforge.net/sourceforge/tkimg/tkimg1.3.zip,
>>but I cannot figure out how to 'build' the files to link them to R.
>>
>>Would someone be so kind as to tell me how to do this? Better still, does
>>anyone have an R routine
>>that will do it, since I have no experience of this kind of programming.
>>
>>Thanks, in advance,
>>
>>Jonathan Williams
>>
>>______________________________________________
>>R-help@stat.math.ethz.ch mailing list
>>https://stat.ethz.ch/mailman/listinfo/r-help
>>PLEASE do read the posting guide!

>
> http://www.R-project.org/posting-guide.html
>
>>

>
>
>

>

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Aug 23 23:18:52 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 15:44:04 EST