Program: 130319
Project: 130319
Buggy source:
/** 
 * The comments above are directly from the Grafika library. I shifted a lot of its content to this section so it makes sense to have it as a reminder. This method saves the contents of a Bytebuffer to an output stream, and generates a bitmap from that. It also applies any scaling and rotates/mirrors the image to take into account OpenGL scaling.
 * @param buf must be rewound prior to being passed to this method.Essentially buff must be declared, and GLReadPixels called, then the buffer rewound Then it is ready to be passed to this method. It's important to do these preparation steps in an EGL context, and not on their own. That's why we make sure not to include them here. Maybe not a good idea?
 * @param width
 * @param height
 * @throws IOException
 */
public void saveBitmapFromBuffer(ByteBuffer buf,int width,int height) throws IOException {
  BufferedOutputStream bos=null;
  try {
    Long startTime=System.currentTimeMillis();
    savingMessage();
    bos=new BufferedOutputStream(new FileOutputStream(getPhotoFile().toString()));
    Bitmap bmp=Bitmap.createBitmap(width,height,Bitmap.Config.ARGB_8888);
    bmp.copyPixelsFromBuffer(buf);
    Matrix m=new Matrix();
    m.preScale(-getScale(),getScale());
    m.postRotate(180);
    bmp=Bitmap.createBitmap(bmp,0,0,width,height,m,false);
    bmp.compress(Bitmap.CompressFormat.PNG,50,bos);
    bmp.recycle();
    Log.i("String_Node_Str",String.valueOf(System.currentTimeMillis() - startTime) + "String_Node_Str");
  }
 catch (  IOException e) {
    failedFrameMessage(e.getMessage());
    throw e;
  }
 finally {
    savedMessage();
    if (bos != null) {
      bos.close();
      bos.flush();
    }
  }
  Log.d(TAG,"String_Node_Str" + width + "String_Node_Str"+ height+ "String_Node_Str"+ getPhotoFile().toString()+ "String_Node_Str");
}

Fixed version (ground truth):
/** 
 * The comments above are directly from the Grafika library. I shifted a lot of its content to this section so it makes sense to have it as a reminder. This method saves the contents of a Bytebuffer to an output stream, and generates a bitmap from that. It also applies any scaling and rotates/mirrors the image to take into account OpenGL scaling.
 * @param buf must be rewound prior to being passed to this method.Essentially buff must be declared, and GLReadPixels called, then the buffer rewound Then it is ready to be passed to this method. It's important to do these preparation steps in an EGL context, and not on their own. That's why we make sure not to include them here. Maybe not a good idea?
 * @param width
 * @param height
 * @throws IOException
 */
public void saveBitmapFromBuffer(ByteBuffer buf,int width,int height) throws IOException {
  BufferedOutputStream bos=null;
  try {
    Long startTime=System.currentTimeMillis();
    savingMessage();
    setScreenShotFile();
    bos=new BufferedOutputStream(new FileOutputStream(getScreenShotFile().toString()));
    Bitmap bmp=Bitmap.createBitmap(width,height,Bitmap.Config.ARGB_8888);
    bmp.copyPixelsFromBuffer(buf);
    Matrix m=new Matrix();
    m.preScale(-getScale(),getScale());
    m.postRotate(180);
    bmp=Bitmap.createBitmap(bmp,0,0,width,height,m,false);
    bmp.compress(Bitmap.CompressFormat.PNG,50,bos);
    bmp.recycle();
    Log.i("String_Node_Str",String.valueOf(System.currentTimeMillis() - startTime) + "String_Node_Str");
  }
 catch (  IOException e) {
    failedFrameMessage(e.getMessage());
    throw e;
  }
 finally {
    savedMessage();
    if (bos != null) {
      bos.close();
      bos.flush();
    }
  }
  Log.d(TAG,"String_Node_Str" + width + "String_Node_Str"+ height+ "String_Node_Str"+ getScreenShotFile().toString()+ "String_Node_Str");
}