Re: help debugging noob code - converting binary data to images...



success, had to fill in a few blanks with some more googling, here is
the finished script (used all for loops this time, saved a few more
lines):

==========

#!/usr/local/bin/python

import string
import Image, ImageDraw

size = 2

im = Image.new("1",[8*size,8*size],1)
draw = ImageDraw.Draw(im)

cset = open("chargen","r")


for cchar in range(0, 512, 1):
for charline in range(0, 8, 1):
x = cset.read(1)
ch = ord(x)
for position in range(0, 8, 1):
if ch & ( 2 ** position ):
xp = (7-position)*size
yp = charline*size
draw.rectangle(((xp,yp),(xp+size-1,yp+size-1)),
fill=0 )
outfile = "/home/mydir/work/char"+string.zfill(cchar,3)+".png"
im.save(outfile,"png")
draw.rectangle(((0,0),(size*8,size*8)),fill=1)

im.show()

==========

It does the variable sizes like I wanted and it now sure is fast.

If I wanted to display an image without saving how do I do that, on
the image module it does not pop up a canvas.. the im.show() on the
bottom does not seem to work.

Thanks again!
.



Relevant Pages

  • Loop row selection copy with blank spaces
    ... The code I have loops through a column of dates that have blank spaces ... two or more of the same date between the blanks. ... Dim i As Integer ... SkipBlanks:= _ ...
    (microsoft.public.excel.programming)
  • Re: Maximum value of matrix
    ... There is no need to nest the loops. ... Just fill in the blanks: ... % Returns the maximum value in an array. ...
    (comp.soft-sys.matlab)