Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Printing JPEG files in TCL

18 views
Skip to first unread message

noob

unread,
May 4, 1997, 3:00:00 AM5/4/97
to

Hello, I have encountered a problem printing JPEG and other image files in
tcl. I can print text files with the following proc:

proc print { file } {
set f [open $file r]
set cc [open lpt1 w]

while { ![eof $f] } {
gets $f line
puts $cc $line
}
puts $cc "\ff"

close $cc
close $f
}

But when I try this proc on an image file it just prints drivle. Any
answers appreciated.

no...@bridge.net
no...@usa.net
no...@rox.org


Steve Ball

unread,
May 5, 1997, 3:00:00 AM5/5/97
to

In article c...@skyway.bridge.net, "noob" <no...@usa.net> writes:
>
>Hello, I have encountered a problem printing JPEG and other image files in
>tcl. I can print text files with the following proc:
>
>proc print { file } {
>set f [open $file r]
>set cc [open lpt1 w]
>
>while { ![eof $f] } {
>gets $f line
>puts $cc $line
>}
>puts $cc "\ff"
>
>close $cc
>close $f
>}
>
>But when I try this proc on an image file it just prints drivle. Any
>answers appreciated.

There are two problems.

Firstly, Tcl does not yet handle binary strings, ie. you can't have embedded
NULs in a string. That's because Tcl uses NUL-terminated strings. This should
change starting with Tcl v8.0b1.

Secondly, it still wouldn't work even if Tcl did handle the NUL chars because
you're not decompressing the JPEG image before attempting to print it.
(Unless you have a printer with a built-in JPEG codec, but I've never heard of
one of those!)

Steve Ball
--
Steve Ball, Computer Science Dept., ANU Steve...@tcltk.anu.edu.au
Ph. +61 6 2495146 http://tcltk.anu.edu.au/steve/
Snail-mail: Canberra ACT 0200, AUSTRALIA
He's not the messiah, he's a very naughty boy!

0 new messages