edge adaptive image steganography based on lsb matching revisited code

24
import java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; import java.awt.Font; import java.awt.Graphics; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.BufferedOutputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.ObjectOutputStream; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; import java.awt.event.*; import java.awt.Graphics; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; import javax.imageio.ImageIO; import javax.swing.JPanel; import javax.swing.BorderFactory; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFileChooser; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.border.TitledBorder; import java.awt.*; import java.io.*; import java.lang.*;

Upload: gangang1988

Post on 14-Oct-2014

132 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Edge Adaptive Image Steganography Based on Lsb Matching Revisited Code

import java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; import java.awt.Font; import java.awt.Graphics; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.BufferedOutputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.ObjectOutputStream; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; import java.awt.event.*; import java.awt.Graphics; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; import javax.imageio.ImageIO; import javax.swing.JPanel; import javax.swing.BorderFactory; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFileChooser; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.border.TitledBorder; import java.awt.*; import java.io.*; import java.lang.*;

Page 2: Edge Adaptive Image Steganography Based on Lsb Matching Revisited Code

import java.net.Socket; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.Random; public class client implements ActionListener{ Font f1 = new Font("Times New Roman", Font.BOLD, 40); Font f2 = new Font("Bell MT", Font.BOLD, 21); Font f3 = new Font("Bell MT", Font.BOLD, 20); Font f5 = new Font("Bell MT", Font.BOLD, 25); BufferedOutputStream bos; public static int key; public static String path1; public static String path2; // JLabel l19=new JLabel("EDGE ADAPTIVE IMAGE STEGANOGRAPHY"); JLabel l= new JLabel("EDGE ADAPTIVE IMAGE STEGANOGRAPHY - CLIENT"); JLabel l1= new JLabel(" SECRET IMAGE "); JLabel l2= new JLabel(" MAIN IMAGE 1 "); JLabel l3= new JLabel(" MAIN IMAGE 2 "); JLabel l4= new JLabel(" MAIN IMAGE 3 "); JLabel l5= new JLabel(); JLabel l6= new JLabel(); JLabel l7= new JLabel(); JLabel l8= new JLabel(); JScrollPane pane1 = new JScrollPane(); JTextField t1 = new JTextField(); JTextField t2 = new JTextField(); JTextField t3 = new JTextField(); JTextField t4 = new JTextField(); JButton BROWSE1 = new JButton("BROWSE"); JButton BROWSE2 = new JButton("BROWSE"); JButton BROWSE3 = new JButton("BROWSE"); JButton BROWSE4 = new JButton("BROWSE"); JButton HIDEIMAGE = new JButton("HIDE IMAGE"); JButton SEND = new JButton("SEND"); JButton EXIT = new JButton("EXIT");

Page 3: Edge Adaptive Image Steganography Based on Lsb Matching Revisited Code

public JFrame jf; public Container c; client() { jf = new JFrame(" CLIENT FORM "); c = jf.getContentPane(); c.setBackground(new Color(250,170,50)); c.setLayout(null); jf.setSize(1024,730); jf.show(); //l19.setBounds(350,10,700,100); l.setBounds(50,20,12000,100); l.setFont(f1); l.setForeground(Color.cyan); //l19.setForeground(Color.BLACK); c.add(l); //c.add(l19); TitledBorder leftBorder1 = BorderFactory.createTitledBorder(""); leftBorder1.setTitleJustification(TitledBorder.CENTER); leftBorder1.setTitleFont(f3); l6.setBorder(leftBorder1); l6.setBounds(40,100,950,570); leftBorder1.setTitleColor(Color.cyan); c.add(l6); l1.setBounds(140,160,200,40); l1.setFont(f3); l1.setForeground(Color.blue); c.add(l1); t1.setBounds(340,165,240,25); t1.setForeground(Color.magenta); c.add(t1); BROWSE1.setBounds(600,170,100,20); BROWSE1.setForeground(Color.WHITE); BROWSE1.setBackground(new Color(159,25,10)); c.add(BROWSE1); l2.setBounds(150,230,200,40); l2.setFont(f3); l2.setForeground(Color.blue); c.add(l2); t2.setBounds(340,235,240,25); t2.setForeground(Color.magenta); c.add(t2); BROWSE2.setBounds(600,240,100,20); BROWSE2.setForeground(Color.WHITE);

Page 4: Edge Adaptive Image Steganography Based on Lsb Matching Revisited Code

BROWSE2.setBackground(new Color(159,25,10)); c.add(BROWSE2); l3.setBounds(150,300,200,40); l3.setFont(f3); l3.setForeground(Color.blue); c.add(l3); t3.setBounds(340,305,240,25); t3.setForeground(Color.magenta); c.add(t3); BROWSE3.setBounds(600,310,100,20); BROWSE3.setForeground(Color.WHITE); BROWSE3.setBackground(new Color(159,25,10)); c.add(BROWSE3); l4.setBounds(150,370,200,40); l4.setFont(f3); l4.setForeground(Color.blue); c.add(l4); t4.setBounds(340,375,240,25); t4.setForeground(Color.magenta); c.add(t4); BROWSE4.setBounds(600,380,100,20); BROWSE4.setForeground(Color.WHITE); BROWSE4.setBackground(new Color(159,25,10)); c.add(BROWSE4); pane1.setViewportView(l5); pane1.setBounds(750,170,200,200); c.add(pane1); TitledBorder leftBorder2 = BorderFactory.createTitledBorder(""); leftBorder2.setTitleJustification(TitledBorder.CENTER); leftBorder2.setTitleFont(f3); l7.setBorder(leftBorder2); l7.setBounds(250,460,520,170); leftBorder2.setTitleColor(Color.cyan); c.add(l7); HIDEIMAGE.setBounds(300,500,200,30); HIDEIMAGE.setForeground(Color.WHITE); HIDEIMAGE.setFont(f5); HIDEIMAGE.setBackground(new Color(120,10,122)); c.add(HIDEIMAGE); SEND.setBounds(590,500,130,30); SEND.setForeground(Color.WHITE);

Page 5: Edge Adaptive Image Steganography Based on Lsb Matching Revisited Code

SEND.setFont(f5); SEND.setBackground(new Color(120,10,122)); c.add(SEND); EXIT.setBounds(450,570,130,30); EXIT.setForeground(Color.WHITE); EXIT.setFont(f5); EXIT.setBackground(new Color(120,10,122)); c.add(EXIT); jf.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent win) { System.exit(0); } }); BROWSE1.addActionListener(this); BROWSE2.addActionListener(this); BROWSE3.addActionListener(this); BROWSE4.addActionListener(this); HIDEIMAGE.addActionListener(this); SEND.addActionListener(this); EXIT.addActionListener(this); } public void actionPerformed(ActionEvent e) { if (e.getSource()== BROWSE1) { try { JFileChooser chooser = new JFileChooser(); File f = new File(new File("filename.txt").getCanonicalPath()); chooser.setSelectedFile(f); chooser.showOpenDialog(BROWSE1); int retval = chooser.showOpenDialog(BROWSE1); if (retval == JFileChooser.APPROVE_OPTION){ File field = chooser.getSelectedFile(); t1.setText(field.getAbsolutePath()); BufferedImage image = ImageIO.read(field); l5.setIcon(new ImageIcon(image));

Page 6: Edge Adaptive Image Steganography Based on Lsb Matching Revisited Code

} } catch(Exception ee) { System.out.println(ee); } } if (e.getSource()== BROWSE2) { try { JFileChooser chooser = new JFileChooser(); File f = new File(new File("filename.txt").getCanonicalPath()); chooser.setSelectedFile(f); chooser.showOpenDialog(BROWSE2); int retval = chooser.showOpenDialog(BROWSE2); if (retval == JFileChooser.APPROVE_OPTION){ File field = chooser.getSelectedFile(); t2.setText(field.getAbsolutePath()); BufferedImage image = ImageIO.read(field); l5.setIcon(new ImageIcon(image)); } } catch(Exception ee) { System.out.println(ee); } } if (e.getSource()== BROWSE3) { try { JFileChooser chooser = new JFileChooser(); File f = new File(new File("filename.txt").getCanonicalPath()); chooser.setSelectedFile(f); chooser.showOpenDialog(BROWSE3); int retval = chooser.showOpenDialog(BROWSE3); if (retval == JFileChooser.APPROVE_OPTION){ File field = chooser.getSelectedFile(); t3.setText(field.getAbsolutePath());

Page 7: Edge Adaptive Image Steganography Based on Lsb Matching Revisited Code

BufferedImage image = ImageIO.read(field); l5.setIcon(new ImageIcon(image)); } } catch(Exception ee) { System.out.println(ee); } } if (e.getSource()== BROWSE4) { try { JFileChooser chooser = new JFileChooser(); File f = new File(new File("filename.txt").getCanonicalPath()); chooser.setSelectedFile(f); chooser.showOpenDialog(BROWSE4); int retval = chooser.showOpenDialog(BROWSE4); if (retval == JFileChooser.APPROVE_OPTION){ File field = chooser.getSelectedFile(); t4.setText(field.getAbsolutePath()); BufferedImage image = ImageIO.read(field); l5.setIcon(new ImageIcon(image)); } } catch(Exception ee) { System.out.println(ee); } } if (e.getSource()== HIDEIMAGE) { Socket client=null; int Port = 40000 ; try {

Page 8: Edge Adaptive Image Steganography Based on Lsb Matching Revisited Code

client = new Socket("127.0.0.1", Port ); FileInputStream fis = new FileInputStream(t1.getText()); byte[] buffer = new byte[fis.available()]; fis.read(buffer); ObjectOutputStream oos = new ObjectOutputStream(client.getOutputStream()) ; oos.writeObject(buffer); client.close(); } catch (Exception e1) { System.out.println(e); } try { File file = new File(t1.getText()); BufferedImage image1 = ImageIO.read(file); int w1=image1.getWidth(); int h1=image1.getHeight(); String main = null; for(int i=0; i<1; ++i) key = new Random().nextInt(3)+1; if(key == 2) { main = t3.getText(); path1 = t2.getText(); path2 = t4.getText(); } else if(key == 3) { main = t4.getText(); path1 = t2.getText(); path2 = t3.getText(); } else if(key == 1) {

Page 9: Edge Adaptive Image Steganography Based on Lsb Matching Revisited Code

main = t2.getText(); path1 = t3.getText(); path2 = t4.getText(); } int temp1 = main.lastIndexOf("\\"); String temp2 = main.substring(temp1+1,main.length()); File file2 = new File(main); BufferedImage image2 = ImageIO.read(file2); int w2=image2.getWidth(); int h2=image2.getHeight(); if( (w1 == w2) && (h1 == h2) ) { for(int i=0;i<w2;i++) { for(int j=0;j<h2;j++) { int clr = image2.getRGB(i,j); int red = (clr & 0x00ff0000) >> 16 ; int green = (clr & 0x0000ff00) >> 8; int blue = (clr & 0x000000ff); Color c=new Color(red,green,blue); image1.setRGB(i,j,c.getRGB()); } } ImageIO.write(image1,"jpg",new File("HidedImage.jpg")); JOptionPane.showMessageDialog(null, "secret Image Hided Into " +temp2 +" Successfully ","Message",1); } else { JOptionPane.showMessageDialog(null,"Main Images Size Are Notequal to Secret Image, So Cannot Hide Image ,Select another Main Images ","Message",1); } } catch(Exception ee)

Page 10: Edge Adaptive Image Steganography Based on Lsb Matching Revisited Code

{ System.out.println(ee); } client=null; int Port1 = 50000 ; try { client = new Socket("127.0.0.1", Port1 ); //bos = new BufferedOutputStream(client.getOutputStream()); FileInputStream fis = new FileInputStream("HidedImage.jpg"); byte[] buffer = new byte[fis.available()]; fis.read(buffer); ObjectOutputStream oos = new ObjectOutputStream(client.getOutputStream()) ; oos.writeObject(buffer); client.close(); } catch (Exception e1) { System.out.println(e); } try { client.close(); } catch (IOException e1) { e1.printStackTrace(); } } if (e.getSource()== SEND) { Socket client = null; int Port1 = 10000 ;

Page 11: Edge Adaptive Image Steganography Based on Lsb Matching Revisited Code

try { client = new Socket("127.0.0.1", Port1 ); //bos = new BufferedOutputStream(client.getOutputStream()); FileInputStream fis = new FileInputStream("HidedImage.jpg"); byte[] buffer = new byte[fis.available()]; fis.read(buffer); ObjectOutputStream oos = new ObjectOutputStream(client.getOutputStream()) ; oos.writeObject(buffer); client.close(); } catch (Exception e1) { System.out.println(e); } int Port2 = 20000 ; try { client = new Socket("127.0.0.1", Port2 ); //bos = new BufferedOutputStream(client.getOutputStream()); FileInputStream fis = new FileInputStream(path1); byte[] buffer = new byte[fis.available()]; fis.read(buffer); ObjectOutputStream oos = new ObjectOutputStream(client.getOutputStream()) ; oos.writeObject(buffer); client.close(); } catch (Exception e1) { System.out.println(e); } try { client.close();

Page 12: Edge Adaptive Image Steganography Based on Lsb Matching Revisited Code

} catch (IOException e1) { e1.printStackTrace(); } int Port3 = 30000 ; try { client = new Socket("127.0.0.1", Port3 ); //bos = new BufferedOutputStream(client.getOutputStream()); FileInputStream fis = new FileInputStream(path2); byte[] buffer = new byte[fis.available()]; fis.read(buffer); ObjectOutputStream oos = new ObjectOutputStream(client.getOutputStream()) ; oos.writeObject(buffer); JOptionPane.showMessageDialog(null,"Images Sent Successfully ","Message",1); client.close(); } catch (Exception e1) { System.out.println(e); } try { client.close(); } catch (IOException e1) { e1.printStackTrace(); }

Page 13: Edge Adaptive Image Steganography Based on Lsb Matching Revisited Code

} if (e.getSource()== EXIT) { System.exit(0); } } public static void main(String[] args) { new client(); } } /* public class client extends javax.swing.JFrame { /** Creates new form client */ /* public client() { initComponents(); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. * // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents private void initComponents() { setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(0, 400, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(0, 300, Short.MAX_VALUE)

Page 14: Edge Adaptive Image Steganography Based on Lsb Matching Revisited Code

); pack(); }// </editor-fold>//GEN-END:initComponents /** * @param args the command line arguments */ /* public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new client().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables // End of variables declaration//GEN-END:variables }*/ import java.awt.Color; import java.awt.Container; import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.awt.image.BufferedImage; import javax.imageio.ImageIO; import javax.swing.BorderFactory; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JScrollPane; import javax.swing.border.TitledBorder; import java.net.ServerSocket; import java.net.Socket;

Page 15: Edge Adaptive Image Steganography Based on Lsb Matching Revisited Code

public class server implements ActionListener{ Font f1 = new Font("Bell MT", Font.BOLD, 30); Font f2 = new Font("Bell MT", Font.BOLD, 21); Font f3 = new Font("Bell MT", Font.BOLD, 20); Font f5 = new Font("Bell MT", Font.BOLD, 25); BufferedOutputStream bos; public static String main1 ,main2; String desktopPath1 = System.getProperty("user.home") + "/Desktop"; String desktopPath = desktopPath1.replace("\\", "/"); JLabel l1= new JLabel(); JLabel l2= new JLabel(); JLabel l3= new JLabel(); JLabel l4= new JLabel(); JLabel l5= new JLabel(); JLabel l6= new JLabel(); JLabel l7= new JLabel(); JLabel l8= new JLabel(); JLabel l9= new JLabel(); JScrollPane pane1 = new JScrollPane(); JScrollPane pane2 = new JScrollPane(); JScrollPane pane3 = new JScrollPane(); JScrollPane pane4 = new JScrollPane(); JScrollPane pane5 = new JScrollPane(); JButton GETIMAGES = new JButton("TO SHOW IMAGES"); JButton FILTERIMAGES = new JButton("FILTER IMAGES"); JButton GETSECRETIMAGE = new JButton("GET SECRET IMAGE"); JButton EXIT = new JButton("EXIT"); public JFrame jf; public Container c; server() { jf = new JFrame(" SERVER FORM "); c = jf.getContentPane(); c.setBackground(new Color(250,170,50)); c.setLayout(null); jf.setSize(1200,730);

Page 16: Edge Adaptive Image Steganography Based on Lsb Matching Revisited Code

jf.show(); TitledBorder leftBorder1 = BorderFactory.createTitledBorder("EDGE ADAPTIVE IMAGE STEGANOGRAPHY-SERVER "); leftBorder1.setTitleJustification(TitledBorder.CENTER); leftBorder1.setTitleFont(f1); l6.setBorder(leftBorder1); l6.setBounds(40,35,945,650); leftBorder1.setTitleColor(Color.cyan); c.add(l6); TitledBorder leftBorder2 = BorderFactory.createTitledBorder(""); leftBorder2.setTitleJustification(TitledBorder.CENTER); leftBorder2.setTitleFont(f1); l7.setBorder(leftBorder2); l7.setBounds(100,95,800,290); leftBorder2.setTitleColor(Color.cyan); c.add(l7); GETIMAGES.setBounds(350,110,300,30); GETIMAGES.setFont(f5); GETIMAGES.setForeground(Color.WHITE); GETIMAGES.setBackground(new Color(159,25,10)); c.add(GETIMAGES); pane1.setViewportView(l1); pane1.setBounds(150,163,200,200); c.add(pane1); pane2.setViewportView(l2); pane2.setBounds(400,163,200,200); c.add(pane2); pane3.setViewportView(l3); pane3.setBounds(650,163,200,200); c.add(pane3); TitledBorder leftBorder3 = BorderFactory.createTitledBorder(""); leftBorder3.setTitleJustification(TitledBorder.CENTER); leftBorder3.setTitleFont(f1); l8.setBorder(leftBorder3); l8.setBounds(130,400,280,278); leftBorder3.setTitleColor(Color.cyan); c.add(l8); pane4.setViewportView(l4); pane4.setBounds(170,420,200,200);

Page 17: Edge Adaptive Image Steganography Based on Lsb Matching Revisited Code

c.add(pane4); TitledBorder leftBorder4 = BorderFactory.createTitledBorder(""); leftBorder4.setTitleJustification(TitledBorder.CENTER); leftBorder4.setTitleFont(f1); l9.setBorder(leftBorder4); l9.setBounds(430,400,320,278); leftBorder4.setTitleColor(Color.cyan); c.add(l9); pane5.setViewportView(l5); pane5.setBounds(500,415,200,200); c.add(pane5); FILTERIMAGES.setBounds(150,635,250,30); FILTERIMAGES.setFont(f5); FILTERIMAGES.setForeground(Color.WHITE); FILTERIMAGES.setBackground(new Color(120,10,122)); c.add(FILTERIMAGES); GETSECRETIMAGE.setBounds(450,635,290,30); GETSECRETIMAGE.setForeground(Color.WHITE); GETSECRETIMAGE.setFont(f5); GETSECRETIMAGE.setBackground(new Color(120,10,122)); c.add(GETSECRETIMAGE); EXIT.setBounds(780,530,130,30); EXIT.setForeground(Color.WHITE); EXIT.setFont(f5); EXIT.setBackground(new Color(120,10,122)); c.add(EXIT); jf.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent win) { System.exit(0); } }); GETIMAGES.addActionListener(this); FILTERIMAGES.addActionListener(this); GETSECRETIMAGE.addActionListener(this); EXIT.addActionListener(this); int[] ports = new int[] {10000,20000,30000,40000,50000};

Page 18: Edge Adaptive Image Steganography Based on Lsb Matching Revisited Code

for (int i = 0; i < 5; i++) { Thread t = new Thread(new PortListener(ports[i])); t.setName("Listener-" + ports[i]); t.start(); } jf.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent win) { System.exit(0); } }); } class PortListener implements Runnable { ServerSocket server; Socket connection; BufferedReader br = null; int port; public PortListener(int port) { this.port = port; } public void run() { try { server = new ServerSocket(port); while (true) { connection = server.accept(); if(port == 10000) { try{ ObjectInputStream ois = new ObjectInputStream(connection.getInputStream()); byte[] buffer = (byte[])ois.readObject(); FileOutputStream fos = new FileOutputStream(desktopPath+"/Image1.jpg"); fos.write(buffer); connection.close();

Page 19: Edge Adaptive Image Steganography Based on Lsb Matching Revisited Code

} catch(Exception e) { System.out.println(e); } } else if(port == 20000) { try{ ObjectInputStream ois = new ObjectInputStream(connection.getInputStream()); byte[] buffer = (byte[])ois.readObject(); FileOutputStream fos = new FileOutputStream(desktopPath+"/Image2.jpg"); fos.write(buffer); connection.close(); } catch(Exception e) { System.out.println(e); } } else if(port == 30000) { try{ ObjectInputStream ois = new ObjectInputStream(connection.getInputStream()); byte[] buffer = (byte[])ois.readObject(); FileOutputStream fos = new FileOutputStream(desktopPath+"/Image3.jpg"); fos.write(buffer); connection.close(); JOptionPane.showMessageDialog(null, "Images Got Successfully ","Message",1); }

Page 20: Edge Adaptive Image Steganography Based on Lsb Matching Revisited Code

catch(Exception e) { System.out.println(e); } } else if(port == 40000) { try{ ObjectInputStream ois = new ObjectInputStream(connection.getInputStream()); byte[] buffer = (byte[])ois.readObject(); FileOutputStream fos = new FileOutputStream("C:/Documents and Settings/All Users/Documents/My Pictures/Sample Pictures/Image2.jpg"); fos.write(buffer); connection.close(); main2 = "C:/Documents and Settings/All Users/Documents/My Pictures/Sample Pictures/Image2.jpg"; } catch(Exception e) { System.out.println(e); } } else if(port == 50000) { try{ ObjectInputStream ois = new ObjectInputStream(connection.getInputStream()); byte[] buffer = (byte[])ois.readObject(); FileOutputStream fos = new FileOutputStream("C:/Documents and Settings/All Users/Documents/My Pictures/Sample Pictures/Image1.jpg"); fos.write(buffer); connection.close(); main1 = "C:/Documents and Settings/All Users/Documents/My Pictures/Sample Pictures/Image1.jpg"; }

Page 21: Edge Adaptive Image Steganography Based on Lsb Matching Revisited Code

catch(Exception e) { System.out.println(e); } } } } catch (IOException e) { System.out.println(e); } } } public void actionPerformed(ActionEvent e) { if (e.getSource()== GETIMAGES) { l1.setIcon(new ImageIcon("C:/Documents and Settings/All Users/Documents/My Pictures/Sample Pictures/Image1.jpg")); l2.setIcon(new ImageIcon(desktopPath+"/Image2.jpg")); l3.setIcon(new ImageIcon(desktopPath+"/Image3.jpg")); } if (e.getSource()== FILTERIMAGES) { try {

Page 22: Edge Adaptive Image Steganography Based on Lsb Matching Revisited Code

File file = new File(main1); BufferedImage image = ImageIO.read(file); int w=image.getWidth(); int h=image.getHeight(); for(int i=0;i<w;i++) { for(int j=0;j<h;j++) { int clr = image.getRGB(i,j); int red = (clr & 0x00ff0000) >> 16; int green = (clr & 0x0000ff00) >> 8; int blue = (clr & 0x000000ff); Color c=new Color(red,green,blue); image.setRGB(i,j,c.getRGB()); } } ImageIO.write(image,"jpg",new File(desktopPath+"/FilterImage.jpg")); l4.setIcon(new ImageIcon(desktopPath+"/FilterImage.jpg")); JOptionPane.showMessageDialog(null, "Images Filtered Successfully ","Message",1); } catch(Exception ee) { System.out.println(ee); } } if (e.getSource()== GETSECRETIMAGE) { try { File file = new File(main2); BufferedImage image = ImageIO.read(file); int w=image.getWidth();

Page 23: Edge Adaptive Image Steganography Based on Lsb Matching Revisited Code

int h=image.getHeight(); for(int i=0;i<w;i++) { for(int j=0;j<h;j++) { int clr = image.getRGB(i,j); int red = (clr & 0x00ff0000) >> 16 ; int green = (clr & 0x0000ff00) >> 8; int blue = (clr & 0x000000ff); Color c=new Color(red,green,blue); image.setRGB(i,j,c.getRGB()); } } ImageIO.write(image,"jpg",new File(desktopPath+"/SecretImage.jpg")); l5.setIcon(new ImageIcon(desktopPath+"/SecretImage.jpg")); JOptionPane.showMessageDialog(null, "secret Image Got Successfully ","Message",1); } catch(Exception ee) { System.out.println(ee); } } if (e.getSource()== EXIT) { System.exit(0); } } public static void main(String[] args) { new server(); } }

Page 24: Edge Adaptive Image Steganography Based on Lsb Matching Revisited Code

/** * * @author SyS */ /*public class server extends javax.swing.JFrame { /** Creates new form server */ /* public server() { initComponents(); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ /* // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents private void initComponents() { setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(0, 400, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(0, 300, Short.MAX_VALUE) ); pack(); }// </editor-fold>//GEN-END:initComponents /** * @param args the command line arguments */ /* public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new server().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables // End of variables declaration//GEN-END:variables}