Re: [問題] gen 一張random圖
※ 引述《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
推
03/07 02:32, , 1F
03/07 02:32, 1F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 3 之 3 篇):
Python 近期熱門文章
PTT數位生活區 即時熱門文章