Raw images

Tuvas tuvas21 at gmail.com
Wed Dec 21 00:46:11 EST 2005


Well, it's a custum-built camera, so it's not standard by any means.
That being the case, I know it's exact format, which is as follows. It
is a stream of 16 bit numbers, each representing a point on a grid. The
grid is define in a seporate way, outside of the format, but is given a
number of rows and columns. From these, an image is defined. I simply
need to take this stream, which I converted to a giant string, and
display it in the form of a picture. What I've tried to do is as
follows:

1. Read string
2. Form an array by combining 2 chars together.
3. Divide by 256 so as to have a 8 bit number, which PIL likes alot
better than a 16 bit number. The string is called data.
4. Use im = Image.fromstring('L', (xsize, ysize), data) to create image
5.Use
        im.thumbnail((700,700))
        image=ImageTk.BitmapImage(im)
        pic=canvas.create_image(1,1,anchor="nw",image=image,tag="pic")
        canvas.addtag_withtag("pic",pic)

There seems to be a problem with the last line, but no picture is
displayed without it. That isn't related to the problem I'm having, but
I also need to fix it. The problem is it won't display the image, it
seems to display nothing. Any ideas as to why? I've tried using
PhotoImage, with the same result. Perhaps it's the thumbnail command, I
don't know if it has problems if you try to make a thumbnail larger
than the picture, but I would presume there's a way around this. Ideas?
Thanks!




More information about the Python-list mailing list