mercredi 18 janvier 2017

Mirror reflection of the picture Java

Hi so i have to make mirror reflection of my drawn picture. There must be 2 pictures. One normal and the second right below as mirror reflection. I don't know how to draw second picture and flip it.

public static void main(String[] args) throws FileNotFoundException {
    String path ="C:/Users/Nitendo/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);
}

}





Aucun commentaire:

Enregistrer un commentaire