Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void displayImage()
- {
- System.out.println("displayImage: " + this.imgPath);
- ImageIcon picture = new ImageIcon(imgPath);
- label = new JLabel("", picture, JLabel.CENTER);
- JFrame frame = new JFrame() ;
- frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- frame.setTitle(this.imgPath);
- JScrollPane scrollPane = new JScrollPane(label) ;
- scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
- scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
- frame.add(scrollPane,BorderLayout.CENTER) ;
- frame.pack();
- frame.setVisible(true);
- }
- public void decodeImage(String img)
- {
- try
- {
- Date date = new Date();
- DateFormat df = new SimpleDateFormat("MMddyyhhmmss");
- this.imgPath = folder+"/"+df.format(date)+".jpg";
- System.out.println("decodeImage: " + this.imgPath);
- Decoder decoder = Base64.getDecoder();
- byte[] decodedBytes = decoder.decode(img);
- FileOutputStream fos;
- fos = new FileOutputStream(imgPath);
- fos.write(decodedBytes);
- fos.close();
- }
- catch (IOException e)
- {
- System.out.println("errore nella decodifica dell'immagine");
- e.printStackTrace();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement