簡體   English   中英

如何在JES中將圖像鏡像到對角線上

[英]How to mirror an image on a diagonal in JES

我是這個網站和jython / python編程的新手。 因此,對於本文中的任何錯誤,我深表歉意。 我的問題:我目前正在Jython程序JES(學生的Jython環境)中學習有關鏡像的問題,並且我有一個問題要求沿對角線鏡像。 經過研究(主要在此站點上),我想出了以下代碼來做到這一點:

 def mirrorDiagonalBlueMotorcyle(pic):
    # Set up source picture & target picture
    height=getHeight(pic)
    width=getWidth(pic)
    newPic=makeEmptyPicture(height,width)
    # Now for the actual mirroring
    mirrorPoint=0
    for x in range(0,width,1):
      for y in range(mirrorPoint,height):
        sourcePixel=getPixel(pic,y,x)
        targetPixel=getPixel(newPic,x,y)
        color=getColor(sourcePixel)
        setColor(targetPixel,color)
        mirrorPoint+= 1
    show(newPic)
    return newPic 

但是,生成的圖像不是鏡像圖像,而是對角線上變白的圖像

如何編寫程序以實際鏡像圖像而不只是鏡像出白色部分?

編輯:這是PM 2Ring告訴我要做的結果: 卸下mirrorPoint之后的摩托車

罪魁禍首是mirrorPoint :它確保僅對角線一側的源圖像區域進行鏡像。 因此,擺脫mirrorPoint東西,並將內部循環更改為

for y in range(0,height):

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM