Program: 142165
Project: 142165
Buggy source:
/** 
 * Attempt to inflate an image source into a bitmap whose final dimensions are based upon 2 factors: 1) The application of a scaling factor, which is derived from the relative values of the target density declared by the app and the current device's actual density 2) The absolute dimensions of the bounding container into which this image is being inflated (may just be the screen dimens)
 * @return the bitmap, or null if none could be created from the source
 */
public static Bitmap getBitmapScaledForNativeDensity(DisplayMetrics metrics,String imageFilepath,int containerHeight,int containerWidth,int targetDensity){
  BitmapFactory.Options o=new BitmapFactory.Options();
  o.inJustDecodeBounds=true;
  o.inScaled=false;
  BitmapFactory.decodeFile(imageFilepath,o);
  int imageHeight=o.outHeight;
  int imageWidth=o.outWidth;
  Log.i("String_Node_Str","String_Node_Str" + imageHeight + "String_Node_Str"+ imageWidth);
  double scaleFactor=computeInflationScaleFactor(metrics,targetDensity);
  int calculatedHeight=Math.round((float)(imageHeight * scaleFactor));
  int calculatedWidth=Math.round((float)(imageWidth * scaleFactor));
  Log.i("String_Node_Str","String_Node_Str" + calculatedHeight + "String_Node_Str"+ calculatedWidth);
  int boundingHeight=Math.min(containerHeight,calculatedHeight);
  int boundingWidth=Math.min(containerWidth,calculatedWidth);
  if (boundingHeight < imageHeight || boundingWidth < imageWidth) {
    return getBitmapScaledToContainer(imageFilepath,boundingHeight,boundingWidth);
  }
 else {
    return attemptBoundedScaleUp(imageFilepath,calculatedHeight,calculatedWidth,containerHeight,containerWidth);
  }
}

Fixed version (ground truth):
/** 
 * Attempt to inflate an image source into a bitmap whose final dimensions are based upon 2 factors: 1) The application of a scaling factor, which is derived from the relative values of the target density declared by the app and the current device's actual density 2) The absolute dimensions of the bounding container into which this image is being inflated (may just be the screen dimens)
 * @return the bitmap, or null if none could be created from the source
 */
public static Bitmap getBitmapScaledForNativeDensity(DisplayMetrics metrics,String imageFilepath,int containerHeight,int containerWidth,int targetDensity){
  BitmapFactory.Options o=new BitmapFactory.Options();
  o.inJustDecodeBounds=true;
  o.inScaled=false;
  BitmapFactory.decodeFile(imageFilepath,o);
  int imageHeight=o.outHeight;
  int imageWidth=o.outWidth;
  Log.i("String_Node_Str","String_Node_Str" + imageHeight + "String_Node_Str"+ imageWidth);
  double scaleFactor=computeInflationScaleFactor(metrics,targetDensity);
  int calculatedHeight=Math.round((float)(imageHeight * scaleFactor));
  int calculatedWidth=Math.round((float)(imageWidth * scaleFactor));
  Log.i("String_Node_Str","String_Node_Str" + calculatedHeight + "String_Node_Str"+ calculatedWidth);
  if (containerHeight < imageHeight || calculatedHeight < imageHeight) {
    return getBitmapScaledDownExact(imageFilepath,imageHeight,imageWidth,calculatedHeight,calculatedWidth,containerHeight,containerWidth);
  }
 else {
    return attemptBoundedScaleUp(imageFilepath,calculatedHeight,calculatedWidth,containerHeight,containerWidth);
  }
}