Prev: Parsed C++ source code with regsub does not compile on Windows
Next: Running a batch file with the .cmd extension on Windows
From: Harald Oehlmann on 18 Jun 2010 03:08 Is there any way to render text on an image photo ? Using TkImg and a canvas snapshot as the code below has the following drawbacks: - only works when window is really visible, no backround operation - is limited to the current screen size. Unfortunately, I want to render relatively huge font sizes of 72 so this is a crucial limitation - No transparent background possible The final aim is to create an image file with some components. So the example below must be changed by using "image put" after "image create" <code> toplevel .t wm overrideredirect .t 1 wm geometry .t +0+0 pack [canvas .t.c -background $myBgColor\ -width [font measure myFont $myText]\ -height [font metrics myFont -linespace]\ -state disabled -borderwidth 0 -highlightthickness 0] ..t.c create text 0 0 -anchor ne -font myFont -justify left -text $myText\ -disabledfill $Config(FGColor) raise .t tkwait visibility .t.c image create photo outPhoto -format window -data .t.c outPhoto write $mpPath png image delete outPhoto destroy .t </code>
From: Kroc on 18 Jun 2010 03:47 On 18 juin, 09:08, Harald Oehlmann <wortka...(a)yahoo.de> wrote: > Is there any way to render text on an image photo ? You can use LRIText: http://wfr.tcl.tk/1812 -- David Zolli
From: Roy Terry on 18 Jun 2010 19:44
On Jun 18, 12:08 am, Harald Oehlmann <wortka...(a)yahoo.de> wrote: > Is there any way to render text on an image photo ? tkpath (find on the wiki or just google) will let you "draw" on memory "context" and then capture to an image. Also, you can use image commands to capture the contents of a canvas in a window. Not sure it tkpath is avail on non-windows platforms. > > Using TkImg and a canvas snapshot as the code below has the following > drawbacks: > - only works when window is really visible, no backround operation > - is limited to the current screen size. > Unfortunately, I want to render relatively huge font sizes of 72 so > this is a crucial limitation > - No transparent background possible > > The final aim is to create an image file with some components. > So the example below must be changed by using "image put" after "image > create" > > <code> > toplevel .t > wm overrideredirect .t 1 > wm geometry .t +0+0 > pack [canvas .t.c -background $myBgColor\ > -width [font measure myFont $myText]\ > -height [font metrics myFont -linespace]\ > -state disabled -borderwidth 0 -highlightthickness 0] > .t.c create text 0 0 -anchor ne -font myFont -justify left -text > $myText\ > -disabledfill $Config(FGColor) > raise .t > tkwait visibility .t.c > image create photo outPhoto -format window -data .t.c > outPhoto write $mpPath png > image delete outPhoto > destroy .t > </code> |