Re: help debugging noob code - converting binary data to images...
- From: larry@xxxxxxxxxxxxxxxxx
- Date: Sun, 29 Jun 2008 20:47:01 -0700 (PDT)
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!
.
- References:
- Prev by Date: Re: pixel colour on screen
- Next by Date: List Performance
- Previous by thread: Re: help debugging noob code - converting binary data to images...
- Next by thread: What is "@" used for ?
- Index(es):
Relevant Pages
|