title: using imageio.read get wrong pixel values after set pixels
body: <p>My Problem is i take a image then i changed some pixel values then set them to desired location then i write the image then i read the image using ImageIO.read() by using the image object i didn't get the previous values ... so how can i get the previous values</p>
  
  <pre><code>import java.awt.*;
  
  import java.awt.event.*;
  
  import java.awt.image.*;
  
  import java.io.*;
  
  import javax.imageio.*;
  
  import javax.swing.*;
  
  
  public class LoadImageApp extends JFrame implements ActionListener
  
  {
  
        BufferedImage img=null;
    BufferedImage img1=null;
    BufferedImage mask=null;
    BufferedImage rao=null;
        JButton b1;
    int pixel[][];
    int w,h;
    JFileChooser chooser;
    File file;
        public void paint(Graphics g)
        {
           g.drawImage(img,50,50,150,200,this);
       g.drawImage(mask,600,100,150,200,this);
  
        }
  
    public LoadImageApp()
        {  
           super("Image...");
       setSize(800,800);
       setLayout(new FlowLayout());
       b1=new JButton("Select Image");
       b1.setSize(250,20);
       add(b1);
       b1.addActionListener(this);
       setVisible(true);
        }
    public void actionPerformed(ActionEvent ae)
    {
       try
       {  
  
                      chooser = new JFileChooser("C:/Users/Ravi/Desktop");
              chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
                  int returnVal = chooser.showOpenDialog(this);
                  if(returnVal == JFileChooser.APPROVE_OPTION) 
              {
               file=chooser.getSelectedFile();
               img=ImageIO.read(file);
               mask=new BufferedImage(img.getWidth(),img.getHeight(),img.getType());
               repaint();
               img1=img.getSubimage(0,0,100,150);
                  }
              repaint();
              pixel=getPixels(img);
              int i=80,j=50;
              int temp[]={1,1,1,1};
              int temp1=setPixel(temp);
              for(j=0;j&lt;w;j++)
               pixel[i][j]=temp1;
              System.out.println("pixels before.."+pixel[80][3]);
              this.setPixels();//setting pixels....
              ImageIO.write(mask,"jpeg",new File("aft-con.jpeg"));//write the image
  
             BufferedImage next=ImageIO.read(new File("aft-con.jpeg"));
             ord=getPixels(next);//getting the previous values...
             org=getARGB(ord[80][3]);
             System.out.println("pixels before.."+pixel[80][3]);//but it is not same...
  
           }
           catch(Exception e)
           {
              System.out.println("error in action");
           }
     }
     public int setPixel(int rgb[])
     {
          int pixel = (((rgb[0] &amp; 0x0ff)&lt;&lt;24)|((rgb[1] &amp; 0x0ff)&lt;&lt;16)|((rgb[2] &amp; 0x0ff)&lt;&lt;8)|(rgb[3] &amp; 0x0ff));
          return pixel;
     }
     public int[] getARGB(int pixel)
     {
            int rgb[]=new int[4];
            rgb[0] =((pixel &gt;&gt; 24) &amp; 0xff);
            rgb[1] = ((pixel &gt;&gt; 16) &amp; 0xff);
            rgb[2] =((pixel &gt;&gt; 8) &amp; 0xff);
            rgb[3] =((pixel ) &amp; 0xff);
  
             return rgb;
      }
  
      public int[][] getPixels(BufferedImage img)
     { 
        w=img.getWidth();
        h=img.getHeight();
        int pixels[][]=new int[h][w];
  
       int i=0,j=0;
       try
       {
         for(i=0;i&lt;h;i++)
          for(j=0;j&lt;w;j++)
              pixels[i][j]=img.getRGB(j,i);
  
       }
       catch(Exception e)
       {
           System.out.println("i:"+i+" j:"+j);
       }
  
  
       return pixels;
   }
   public void setPixels()
   {
        w=img.getWidth();
        h=img.getHeight();
  
            int i=0,j=0;
        try
        {
         for(i=0;i&lt;h;i++)
           for(j=0;j&lt;w;j++)
           mask.setRGB(j,i,pixel[i][j]);
        }
        catch(Exception e)
        {
                  System.out.println("error at setting pixel");
        }
   }
  
       public static void main(String[] args) 
       {
  
          LoadImageApp f = new LoadImageApp();
              f.addWindowListener(new WindowAdapter(){
              public void windowClosing(WindowEvent e) {
              System.exit(0);
               }
             });
      }
  </code></pre>
  
  <p>}</p>