Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Paint created bitmap will not display

Status
Not open for further replies.

IdRatherBOutdoors

Programmer
Dec 20, 2002
5
US
Please see the code below.
I am having problems with showing bitmaps. I don't know
if is a permissions problem or what. I copied and modified the sample code that came with Tcl. The program will read the bitmaps that were furnished in the sample images folder. but when I try to use bitmaps I created with Paint, it errors out. My bmp files are black and white. I can not open the furnished sample files with Paint, so I think it has something to do with how the bitmaps are created.
I am running Tcl 8.4.1, and Tk 8.4.1. I have tried this on my home computer using Window ME, and at work using an NT, Linux and Unix. I'm not sure exactly which versions the work computers are using.
The bitmaps I created are smaller files, mostly about 1K,
and the furnished file are upto 13K. It looks like it can find the files, but can not display them, judging from the output I havegotten from the "puts" statement.

Thanks for any advise you can provide.

#########################################################

# items.tcl --
# RCS: @(#) $Id: items.tcl,v 1.3 2001/06/14 10:56:58 dkf Exp $

set w .items
catch {destroy $w}
toplevel $w
wm title $w "Canvas Item Demonstration"
wm iconname $w "Items"

set c $w.frame.c

button $w.dismiss -text Exit -command "destroy $w"
pack $w.dismiss

frame $w.frame
pack $w.frame -side top -fill both -expand yes

canvas $c -width 20c -height 4c
grid $c -in $w.frame -row 0 -column 0 -rowspan 1 -columnspan 1 -sticky news
grid rowconfig $w.frame 0 -weight 1 -minsize 0
grid columnconfig $w.frame 0 -weight 1 -minsize 0

# set dire D:/TestBitmaps
set dire [file join $tk_library demos images]

set all1 [glob $dire/*.bmp]
set counter 1
set c2 c
foreach name $all1 {
set filename [file tail $name]
puts "$counter $filename"
$c create bitmap $counter$c2 1c -tags item -bitmap @[file join $dire $filename]
incr counter 3
}

#################################

bitmaps show ok, console output below when run as shown

#################################

1 face.bmp
4 flagdown.bmp
7 flagup.bmp
10 gray25.bmp
13 letters.bmp
16 noletter.bmp
19 pattern.bmp
#################################

no bitmaps show, console output below when changing $dire to D:/TestBitmaps

#################################

1 bm1.bmp
error reading bitmap file "D:\TestBitmaps\bm1.bmp"
#################################

console output below when changing $dire to D:/TestBitmaps
and create bitmap statement in foreach loop is commented out

#################################

1 bm1.bmp
4 bm2.bmp
7 bmap.bmp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top