title: Switching zxing barcode scanner to portrait mode
body: <p>I am following this issue (<a href="http://code.google.com/p/zxing/issues/detail?id=178" rel="nofollow noreferrer">http://code.google.com/p/zxing/issues/detail?id=178</a>) and followed the instructions of the comment #46 but no luck with samsung galaxy s 2.</p>
  
  <p>I've recorded the image that it receives after making the rotation in DecodeHandler.java
  and a strange thing happens. The image appears to be corrected rotated, but it has like a green filter over it (please check file below).</p>
  
  <p><img src="https://i.stack.imgur.com/55rJJ.jpg" alt="enter image description here"></p>
  
  <p>Anyone experienced this or have a solution for this?</p>
  
  <pre><code>byte[] rotatedData = new byte[data.length];
  for (int y = 0; y &lt; height; y++) {
      for (int x = 0; x &lt; width; x++)
          rotatedData[x * height + height - y - 1] = data[x + y * width];
  }
  int tmp = width; // Here we are swapping, that's the difference to #11
  width = height;
  height = tmp;
  data = rotatedData;
  </code></pre>
  
  <p>PS: Code for writing to file</p>
  
  <ul>
  <li>this code works great if i pass the byte[] before doing the rotation. </li>
  <li>After making the rotation the image go to green </li>
  </ul>
  
  <p>Code</p>
  
  <pre><code> public void writeFile(byte[] data, 
                      String fileName, 
                      int width, int height) 
                      throws IOException{
    FileOutputStream out = new FileOutputStream(fileName);          
    YuvImage im = new YuvImage(data, ImageFormat.NV21, width,
            height, null);
      Rect r = new Rect(0,0,width,height);        
      im.compressToJpeg(r, 100, out);
  
    out.write(data);
    out.close();
  }
  </code></pre>