简体   繁体   中英

Mirror image along y axis

I would like to mirror an image along the y-axis This is the code that i have:

for(int i = 0;i <breite; i ++){
           for(int j = 0; j <hoehe; j++){
                int temp = getRGB(breite-1-i,j);
                setRGB(breite-1-i,j,getRGB(i,j));
                setRGB(i,j,temp);

                   }}

In theory it should work, if I did not mix something up (which i probably did). After i run the code, the picture still remains the same. Any help is appreciated

几乎正确...但是您只需要迭代breite / 2的for循环,否则将其镜像两次,就不会看到任何更改。

for(int i = 0; i <breite/2; i++); for(int j = 0; j<hoehe; j++){ int temp = getRGB(breite-1-i,j); setRGB(breite-1-i,j,getRGB(i,j)); setRGB(i,j,temp); } }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM