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

image create photo -data

4 views
Skip to first unread message

Marc Schneberger

unread,
Mar 9, 1999, 3:00:00 AM3/9/99
to
Hey everbody !

I still have problems with the Tcl command
image create photo -data

If I read e.g. a pgm-file and try to make the picture visible in Tcl/Tk,
it should be possible with the following commands:

set data [open picture.pic r]
image create photo picture -data [read $data]

But everytime I get the following error:

couldn't recognize image data

(It works perfectly with:
image create photo picture -file [file join picture.pgm] )

There must be a possibility to make a picture visible with that
procedure.
Because the same commands with a bmp-file works perfectly as well:

set data [open picture.bmp r]
image create bitmap picture -data [read $data]

If someone knows the answer, I would be very happy.
Thanks in advance

Cheers
MARC


Andreas Kupries

unread,
Mar 9, 1999, 3:00:00 AM3/9/99
to

Marc Schneberger <M.Schn...@dkfz-heidelberg.de> writes:

> I still have problems with the Tcl command
> image create photo -data

> If I read e.g. a pgm-file and try to make the picture visible in Tcl/Tk,
> it should be possible with the following commands:

> set data [open picture.pic r]
> image create photo picture -data [read $data]

The -data option to 'image create photo' expects base64 encoded
information. Please note that this is *not* a separate image format,
but a way of encoding binary information into a printable string.

Base64 is often used to in MIME mail to encode non-text attachments.

You can

* use 'mmencode' from the metamail package (not a tcl package!) to
encode your picture file and then read that:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
set tmp [file join / tmp [pid].pic]
exec mmencode picture.pic -o $tmp

set data [open $tmp r]


image create photo picture -data [read $data]

file delete $tmp

...

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* use Trf (http://www.oche.de/~akupries/soft/trf/index.html) and do

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
package require Trf

set data [open picture.pic r]

image create photo picture -data [base64 -mode encode [read $data]]

...

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

--
Sincerely,
Andreas Kupries <a.ku...@westend.com>
<http://www.westend.com/~kupries/>
-------------------------------------------------------------------------------

0 new messages