作者liangjr (aaa)
看板Python
标题Re: [问题] gen 一张random图
时间Thu Mar 6 17:05:22 2008
※ 引述《yungyuc (酷狗喵千代)》之铭言:
: ※ 引述《hardcover (不才)》之铭言:
: : 我想gen一张random的图,
: : 一开始以为只要去读 /dev/random ,产生一个档即可,
: : 但是这样的图开不起来,是没有档头的原因吗?
: : 後来想看看能不能用python,找到一个 PIL(Python Imaging Library ),
: : 但是PIL提供的function好像没有可以对特定的pixel做改变?
: 可以,请详查 :)
: : 如果直接read (f=open('xxx.bmp')) ,拿pixel和random做xor,
: : 但是也不知道档头到哪里? 要怎麽做呢?
: : thanks
from
http://www.pythonware.com/library/pil/handbook/image.htm
im.putpixel(xy, colour)
Modifies the pixel at the given position. The colour is given as a single
numerical value for single-band images, and a tuple for multi-band images.
Note that this method is relatively slow. If you're using 1.1.6, pixel access
objects (see load) provide a faster way to modify the image. If you want to
generate an entire image, it can be more efficient to create a Python list
and use putdata to copy it to the image. For more extensive changes, use
paste or the ImageDraw module instead.
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 76.87.137.215
1F:推 hardcover:谢罗 03/07 02:32