0

挿入した画像の全体的な色を変更するプログラムをPygameで作成しています。正常に動作しますが、画像の特定の部分(黒のみ)を変更したいと思います。すべての黒いピクセルの色を別の色に変更する方法はありますか?

私はすでに、他のいくつかと同様にを使用してみましsurface.set_at()surface.get_at()。助けてください?:)

4

1 に答える 1

2

PixelArrayを試してみるべきかもしれません

ドキュメントから:

PixelArray.replace

Replaces the passed color in the PixelArray with another one.
PixelArray.replace (color, repcolor, distance=0, weights=(0.299, 0.587, 0.114)): Return None
Replaces the pixels with the passed color in the PixelArray by changing them them to the passed replacement color.
于 2012-06-25T22:01:57.453 に答える