0
我遇到了一个让图像翻转的问题。我的程序应该显示默认图像和翻转的图像。我认为,如果我可以用原始图片的(宽度为1,高度为1)替换翻转图片的(0,0)像素,它就可以工作,但不会得到original image,我会得到this。如何让我的图像翻转?
这里是我的代码:
import java.awt.Color;
public class Horizontal {
public static void main(String[] args)
{
Picture source = new Picture(args[0]);//name of picture.
Picture flip = new Picture(source.width(), source.height());//sets the width and height of source
for (int i =0; i < source.width(); i++)
{
int w = 1;
int sw = source.width()-w;
for (int j = 0; j < source.width(); j++)
{
int h=1;
int sh = source.height()-h;
Color SourceColor = source.get(sw,sh);// return the the color pixel of (sw,sh)
flip.set(i, j, SourceColor);//suppose to replace the (i,j) pixel of flip with source's (sw,sh) pixel
h++;
}
w++;
}
source.show();// shows the original image
flip.show(); // shows flipped version of image
}
}
您的图片被打破......无法看到它的样子 – Chanckjh
好了,现在就来试试吧。 – iii
这通常使用一些'AffineTransfroem'实例来完成,如下所示(例如)[this answer](http://stackoverflow.com/questions/13742365/how-do-i-flip-an-image-horizontally -flip与 - glreadpixels-的BufferedImage-和O/13756357#13756357)。顺便说一句 - 什么是“图片”类,它来自哪里?为了更快地获得更好的帮助,请发布[SSCCE](http://sscce.org/)。 –