简体   繁体   English

沿y轴镜像

[英]Mirror image along y axis

I would like to mirror an image along the y-axis This is the code that i have: 我想沿y轴镜像图像这是我的代码:

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); } }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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