Program: 150607
Project: 150607
Buggy source:
@Override protected void onCameraResolutionChange(int width,int height){
  if (showBitmap) {
synchronized (bitmapLock) {
      if (bitmap.getWidth() != width || bitmap.getHeight() != height)       bitmap=Bitmap.createBitmap(width,height,Bitmap.Config.ARGB_8888);
      bitmapTmp=ConvertBitmap.declareStorage(bitmap,bitmapTmp);
    }
  }
  int rotatedWidth=width;
  int rotatedHeight=height;
  int rotation=getWindowManager().getDefaultDisplay().getRotation();
  int offsetX=0, offsetY=0;
  if (Surface.ROTATION_0 == rotation || Surface.ROTATION_180 == rotation) {
    rotatedWidth=height;
    rotatedHeight=width;
    offsetX=(rotatedWidth - rotatedHeight) / 2;
    offsetY=(rotatedHeight - rotatedWidth) / 2;
  }
  imageToView.reset();
  float scale=Math.min((float)displayView.getWidth() / rotatedWidth,(float)displayView.getHeight() / rotatedHeight);
  if (scale == 0) {
    Log.e(TAG,"String_Node_Str");
    return;
  }
  imageToView.postRotate(-90 * rotation + mSensorOrientation,width / 2,height / 2);
  imageToView.postTranslate(offsetX,offsetY);
  imageToView.postScale(scale,scale);
  if (stretchToFill) {
    imageToView.postScale(displayView.getWidth() / (rotatedWidth * scale),displayView.getHeight() / (rotatedHeight * scale));
  }
 else {
    imageToView.postTranslate((displayView.getWidth() - rotatedWidth * scale) / 2,(displayView.getHeight() - rotatedHeight * scale) / 2);
  }
  Log.i(TAG,imageToView.toString());
  Log.i(TAG,"String_Node_Str" + scale);
  Log.i(TAG,"String_Node_Str" + width + "String_Node_Str"+ height+ "String_Node_Str"+ displayView.getWidth()+ "String_Node_Str"+ displayView.getHeight());
}

Fixed version (ground truth):
@Override protected void onCameraResolutionChange(int cameraWidth,int cameraHeight){
  if (showBitmap) {
synchronized (bitmapLock) {
      if (bitmap.getWidth() != cameraWidth || bitmap.getHeight() != cameraHeight)       bitmap=Bitmap.createBitmap(cameraWidth,cameraHeight,Bitmap.Config.ARGB_8888);
      bitmapTmp=ConvertBitmap.declareStorage(bitmap,bitmapTmp);
    }
  }
  int rotatedWidth=cameraWidth;
  int rotatedHeight=cameraHeight;
  int rotation=getWindowManager().getDefaultDisplay().getRotation();
  int offsetX=0, offsetY=0;
  if (verbose)   Log.i(TAG,"String_Node_Str" + mSensorOrientation + "String_Node_Str"+ rotation);
  boolean needToRotateView=(Surface.ROTATION_0 == rotation || Surface.ROTATION_180 == rotation) != (mSensorOrientation == 0 || mSensorOrientation == 180);
  if (needToRotateView) {
    rotatedWidth=cameraHeight;
    rotatedHeight=cameraWidth;
    offsetX=(rotatedWidth - rotatedHeight) / 2;
    offsetY=(rotatedHeight - rotatedWidth) / 2;
  }
  imageToView.reset();
  float scale=Math.min((float)viewWidth / rotatedWidth,(float)viewHeight / rotatedHeight);
  if (scale == 0) {
    Log.e(TAG,"String_Node_Str");
    return;
  }
  imageToView.postRotate(-90 * rotation + mSensorOrientation,cameraWidth / 2,cameraHeight / 2);
  imageToView.postTranslate(offsetX,offsetY);
  imageToView.postScale(scale,scale);
  if (stretchToFill) {
    imageToView.postScale(viewWidth / (rotatedWidth * scale),viewHeight / (rotatedHeight * scale));
  }
 else {
    imageToView.postTranslate((viewWidth - rotatedWidth * scale) / 2,(viewHeight - rotatedHeight * scale) / 2);
  }
  Log.i(TAG,imageToView.toString());
  Log.i(TAG,"String_Node_Str" + scale);
  Log.i(TAG,"String_Node_Str" + cameraWidth + "String_Node_Str"+ cameraHeight+ "String_Node_Str"+ viewWidth+ "String_Node_Str"+ viewHeight);
}