Java 图像的镜像反射
嗨,所以我必须对我画的画进行镜像。必须有两张图片。一个法线和右下方的第二个作为镜像反射。我不知道如何画第二幅画并翻转它Java 图像的镜像反射,java,image,Java,Image,嗨,所以我必须对我画的画进行镜像。必须有两张图片。一个法线和右下方的第二个作为镜像反射。我不知道如何画第二幅画并翻转它 public static void main(String[] args) throws FileNotFoundException { String path ="C:/Users/Desktop/Snow.ppm"; FileReader fReader = new FileReader(path); Scanner inFile = new Sc
public static void main(String[] args) throws FileNotFoundException {
String path ="C:/Users/Desktop/Snow.ppm";
FileReader fReader = new FileReader(path);
Scanner inFile = new Scanner(fReader);
String p3=inFile.nextLine();
String program=inFile.nextLine();
int rows=inFile.nextInt();
int cols=inFile.nextInt();
int maxValue=inFile.nextInt();
int[][] red = new int [rows][cols];
int[][] green = new int [rows][cols];
int[][] blue = new int [rows][cols];
for (int c = 0; c<cols;c++){
for(int r =0; r<rows; r++){
red[r][c]=inFile.nextInt();
green[r][c]=inFile.nextInt();
blue[r][c]=inFile.nextInt();
}
}
inFile.close();
BufferedImage img = new BufferedImage(rows, cols, BufferedImage.TYPE_3BYTE_BGR);
for (int c = 0; c<cols;c++){
for(int r =0; r<rows; r++){
int rgb = red[r][c];
rgb=(rgb<<8)+green[r][c];
rgb=(rgb<<8)+blue[r][c];
img.setRGB(r, c, rgb);
}
}
JLabel jLabel=new JLabel(new ImageIcon(img));
JPanel jPanel=new JPanel();
jPanel.add(jLabel);
JFrame r = new JFrame();
r.setSize(rows+100, cols+100);
r.add(jPanel);
r.setVisible(true);
}
publicstaticvoidmain(字符串[]args)抛出FileNotFoundException{
String path=“C:/Users/Desktop/Snow.ppm”;
FileReader fReader=新的FileReader(路径);
扫描仪填充=新扫描仪(fReader);
字符串p3=infle.nextLine();
字符串程序=infle.nextLine();
int rows=infle.nextInt();
int cols=infle.nextInt();
int maxValue=infle.nextInt();
int[][]红色=新int[行][cols];
int[][]绿色=新的int[行][cols];
int[][]蓝色=新的int[行][cols];
对于(int c=0;cYou想要处理水平(或者可能垂直)翻转图像。我们可以帮助您,但我们(或者至少我)对任何GUI代码都不感兴趣。您只需反转一维的遍历方向即可相应地翻转图像。