Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Images in Canvas

by Crian (Chaplain)
on Nov 26, 2008 at 09:41 UTC ( #726048=note: print w/ replies, xml ) Need Help??


in reply to Images in Canvas

You use my $xpm two times, I think one of that lines should be commented out.

In different to the createBitmap method you do not need to put a @ in front of the image name when using createImage, if I understand "Mastering Perl/TK" the right way.

Perhaps try one of the built in bitmaps first, to be shure to have no problems with the bitmap file, e.g. my $xpm = $drawing->createBitmap(0, 0, -bitmap  => 'info');.

In case of the createImage method, you have to use an object created with the Photo or Bitmap methods.


I tested a little bit and ending with this, perhaps it is a source for an idea for you:

#!/usr/bin/perl use strict; use warnings; use Tk; my $mw = new MainWindow; $mw->geometry('600x600+110+110'); my $drawing = $mw->Canvas( -width => 500, -height => 500, -background => 'white', )->pack(); my $xpm = <<'END'; /* XPM */ static char *test[]={ "32 32 11 1", ". c None", "# c #000000", "h c #004000", "g c #004040", "f c #404000", "e c #808080", "i c #a0a0a4", "c c #c0c000", "d c #ffff00", "b c #ffffc0", "a c #ffffff", "................................", "................................", "................................", "................................", ".............#....###...........", "............#a##.#aba##.........", "...........#aaaa#aaaaaa##.......", "..........#aaaa#aaaaaaaba##.....", ".........#aaaa#aaaaaaaaaaab##...", "........#aaba#aaaaaaabaabaaaa##.", ".......#aaba#baaaaa#baaaaaabaaa#", "......#aaaa#aaaaab#a##baaaaaaa#.", ".....#aaba#aacbba#aaaa##baaab#..", "....#bbaa#abaacc#aaaaaaa##aa#...", "...#bbbb#aaabaa#aaabaaaaaa##....", "..#bbbb#bacaaa#aaaaaaaabaaaa##..", ".#bbbb#bbaacc#aacaaaaaaaaaaaba#.", "#ddbb#bbbbba#aaaaccaaaaaaaaaaaa#", "#edddfgcbbbfaacaaaaccaaaaaaaaa#e", ".#hedddfhcfabaaccaaabccaaaaaa#e.", "...##edddhaacbbaaccbaaaccaab#i..", ".....##e#baaaccabaaccbaabaa#i...", "......##bacbaabccbaaaccabb#e....", "......#bbbbccaabbccaaaaab#i.....", ".....#bbbbbbbccabbaccaab#i......", ".....#ebbbbbbbbccbaabba#i.......", "......##ebbbbbbbbccaabhe........", "........##ebbbbbbbbbb#e.........", "..........##ibbbbbbbhe..........", "............##ebbbb#e...........", "..............#hee#i............", "................##i............."}; END my $bitmap = $mw->Pixmap(-data => $xpm); $drawing->createImage(100, 100, -image => $bitmap); MainLoop();


Comment on Re: Images in Canvas
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://726048]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (11)
As of 2014-07-29 10:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (214 votes), past polls