title: Weird Ascii characters in output of decoding an Encoded image Java
body: <p>I am writing a Image encryption program in which I encode a string inside the image. </p>
  
  <p>I am working with <code>.png</code> images.</p>
  
  <p>Encoding is performed by following steps:</p>
  
  <ul>
  <li>Pixels of the image are stored in a 2D array using getRGB().</li>
  <li>Each Character in the string is converted in to binary form and stored in an array.</li>
  <li>The LSB of every byte of the <code>4byte</code> pixel is changed according to every bit of the binary form of the character. LSB of first byte is at 0th position, LSB of second byte is at 8th position, third byte is at 16th position, and fourth byte is at 24th position.</li>
  <li>After encoding, the modified pixels are written into the original image by using setRGB() method.</li>
  </ul>
  
  <p>For decoding:</p>
  
  <ul>
  <li>Read the pixels of the image using getRGB();</li>
  <li>The reverse method of encoding is applied for retreiving the data.</li>
  <li><p>After every 8th bit, int containing the decoded bits is converted in to character. Then initialized with zero for the other character.</p>
  
  <pre><code>            if((pixels[i][j] &amp; change)==1)  
              {
                  tempText|=1 ;
              }
  
              tempText&lt;&lt;=1;
  </code></pre></li>
  </ul>
  
  <p>Where change is 1,256,65536,16777216 depending on the iteration. Whose 0th,8th,16th and 24th bits are one.</p>
  
  <p>The code compiles fine. But after decoding, I get weird ascii characters in output. I couldn't find the reason for this. So I am consulting experts here.</p>