Re: [問題] gen 一張random圖

看板Python作者 (aaa)時間17年前 (2008/03/06 17:05), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串3/3 (看更多)
※ 引述《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
文章代碼(AID): #17pxFJiC (Python)
討論串 (同標題文章)
文章代碼(AID): #17pxFJiC (Python)