<p>我在水平和垂直轴上做了一个镜像。现在我要做对角线。</p>
<p>我做了hori和verti width两个for循环,在hori场景中,循环遍历高度中的所有像素和宽度中的一半像素。然后获取像素的颜色,并将相同的颜色设置为另一侧的像素。从<code>getWidth(pic)</code>到中心。</p>
<p>然后我把镜子放在照片中间。对角线怎么做?</p>
<p>编辑:</p>
<pre><code>img_src = makePicture(pickAFile())
W = getWidth(img_src)
H = getHeight(img_src)
for x in range(W):
for y in range(H):
p = getPixel(img_src, x, y)
colorInSrc = getColor( getPixel(img_src, x, y) )
destPixel = getPixel(img_src, H-y-1, W-x-1)
setColor(destPixel, colorInSrc)
</code></pre>