Re: raster (PIL)

2009-07-23 Thread Peter Otten
superpollo wrote: > Peter Otten wrote: >> superpollo wrote: >> >> >>>Peter Otten wrote: >>>... >>> im.convert("1").save(sys.stdout, "PNG") >>> >>>... >>> >>>a q about pil: >>> >>>im.convert("1") >>> >>>is different from: >>> >>>im2 = im.convert("1") >>> >>>right? >>> >>>in the former im is c

Re: raster (PIL)

2009-07-23 Thread superpollo
Peter Otten wrote: superpollo wrote: Peter Otten wrote: ... im.convert("1").save(sys.stdout, "PNG") ... a q about pil: im.convert("1") is different from: im2 = im.convert("1") right? in the former im is changed (the method applies to im) but in the latter im is unchanged (first im is

Re: raster (PIL)

2009-07-23 Thread Peter Otten
superpollo wrote: > Peter Otten wrote: > ... >> im.convert("1").save(sys.stdout, "PNG") > ... > > a q about pil: > > im.convert("1") > > is different from: > > im2 = im.convert("1") > > right? > > in the former im is changed (the method applies to im) but in the latter > im is unchanged (fir

Re: raster (PIL)

2009-07-23 Thread Diez B. Roggisch
superpollo wrote: > Diez B. Roggisch wrote: >> superpollo wrote: > ... >>>high = len(raster_lines) >>>wide = len(raster_lines[0]) >>>bytes_in_a_row = wide/bits_in_a_byte >> >> >> This will give you the wrong result if not divideable by bits_in_a_byte. >> > > then maybe: > > #!/usr/bin/env pyt

Re: raster (PIL)

2009-07-23 Thread superpollo
Peter Otten wrote: ... im.convert("1").save(sys.stdout, "PNG") ... a q about pil: im.convert("1") is different from: im2 = im.convert("1") right? in the former im is changed (the method applies to im) but in the latter im is unchanged (first im is copied unto im2 and then the method is a

Re: raster (PIL)

2009-07-23 Thread superpollo
Peter Otten wrote: ... Here's a different approach: ... raster_string = ... width = raster_string.index("\n") height = raster_string.count("\n") your approach has a funny side-effect: try to remove just one zero from the first line of the raster ;-) bye -- http://mail.python.org/mailman/l

Re: raster (PIL)

2009-07-23 Thread superpollo
Peter Otten wrote: superpollo wrote: i wrote a program which transforms a string of zeroes ando ones into a png file. ... any suggestions for improvement? ... Here's a different approach: ... The idea is to move the bit-twiddling from python to code written in C, pointless for such a tin

Re: raster (PIL)

2009-07-23 Thread superpollo
Diez B. Roggisch wrote: superpollo wrote: ... high = len(raster_lines) wide = len(raster_lines[0]) bytes_in_a_row = wide/bits_in_a_byte This will give you the wrong result if not divideable by bits_in_a_byte. then maybe: #!/usr/bin/env python import Image import sys bits_in_a_byte = 8 r

Re: raster (PIL)

2009-07-23 Thread Peter Otten
superpollo wrote: > i wrote a program which transforms a string of zeroes ando ones into a > png file. > > #!/usr/bin/env python > import Image > import sys > bits_in_a_byte = 8 > raster_string = """\ > > 0010010000101000 > 0010010010101000

Re: raster (PIL)

2009-07-23 Thread Diez B. Roggisch
superpollo wrote: > hi. > > i wrote a program which transforms a string of zeroes ando ones into a > png file. > > #!/usr/bin/env python > import Image > import sys > bits_in_a_byte = 8 > raster_string = """\ > > 0010010000101000 > 00100100101