nus-yam/ex-repair huggingface dataset:
Program: 38479
Project: 38479
Buggy source:
public boolean hasModifications(){
  if (mScaleFactor != 1.0f) {
    return true;
  }
  if (mRotation != 0) {
    return true;
  }
  if (mStraightenRotation != 0) {
    return true;
  }
  if (!mCropBounds.equals(mPhotoBounds)) {
    return true;
  }
  if (!mFlip.equals(FLIP.NONE)) {
    return true;
  }
  return false;
}

Fixed version (ground truth):
public boolean hasModifications(){
  if (mScaleFactor != 1.0f) {
    return true;
  }
  if (mRotation != 0) {
    return true;
  }
  if (mStraightenRotation != 0) {
    return true;
  }
  Rect cropBounds=new Rect();
  mCropBounds.roundOut(cropBounds);
  Rect photoBounds=new Rect();
  mPhotoBounds.roundOut(photoBounds);
  if (!cropBounds.equals(photoBounds)) {
    return true;
  }
  if (!mFlip.equals(FLIP.NONE)) {
    return true;
  }
  return false;
}
Program: 38480
Project: 38480
Buggy source:
protected void saveAndSetPreset(){
  ImagePreset lastHistoryItem=getHistory().getLast();
  if (lastHistoryItem != null && lastHistoryItem.historyName().equalsIgnoreCase(getName())) {
    getImagePreset().setGeometry(mLocalGeometry);
    resetImageCaches(this);
  }
 else {
    ImagePreset copy=new ImagePreset(getImagePreset());
    copy.setGeometry(mLocalGeometry);
    copy.setHistoryName(getName());
    copy.setIsFx(false);
    setImagePreset(copy,true);
  }
  invalidate();
}

Fixed version (ground truth):
public void saveAndSetPreset(){
  ImagePreset lastHistoryItem=getHistory().getLast();
  if (lastHistoryItem != null && lastHistoryItem.historyName().equalsIgnoreCase(getName())) {
    getImagePreset().setGeometry(mLocalGeometry);
    resetImageCaches(this);
  }
 else {
    ImagePreset copy=new ImagePreset(getImagePreset());
    copy.setGeometry(mLocalGeometry);
    copy.setHistoryName(getName());
    copy.setIsFx(false);
    setImagePreset(copy,true);
  }
  invalidate();
}
Program: 38482
Project: 38482
Buggy source:
protected void saveAndSetPreset(){
  ImagePreset lastHistoryItem=getHistory().getLast();
  if (lastHistoryItem != null && lastHistoryItem.historyName().equalsIgnoreCase(getName())) {
    getImagePreset().setGeometry(mLocalGeometry);
    resetImageCaches(this);
  }
 else {
    ImagePreset copy=new ImagePreset(getImagePreset());
    copy.setGeometry(mLocalGeometry);
    copy.setHistoryName(getName());
    copy.setIsFx(false);
    setImagePreset(copy,true);
  }
  invalidate();
}

Fixed version (ground truth):
public void saveAndSetPreset(){
  ImagePreset lastHistoryItem=getHistory().getLast();
  if (lastHistoryItem != null && lastHistoryItem.historyName().equalsIgnoreCase(getName())) {
    getImagePreset().setGeometry(mLocalGeometry);
    resetImageCaches(this);
  }
 else {
    ImagePreset copy=new ImagePreset(getImagePreset());
    copy.setGeometry(mLocalGeometry);
    copy.setHistoryName(getName());
    copy.setIsFx(false);
    setImagePreset(copy,true);
  }
  invalidate();
}
Program: 38483
Project: 38483
Buggy source:
@Override public Bitmap apply(Bitmap bitmap,float scaleFactor,boolean highQuality){
  Rect cropBounds=new Rect(0,0,bitmap.getWidth(),bitmap.getHeight());
  RectF crop=mGeometry.getCropBounds(bitmap);
  if (crop.width() > 0 && crop.height() > 0)   crop.roundOut(cropBounds);
  Bitmap temp=null;
  if (mGeometry.hasSwitchedWidthHeight()) {
    temp=Bitmap.createBitmap(cropBounds.height(),cropBounds.width(),mConfig);
  }
 else {
    temp=Bitmap.createBitmap(cropBounds.width(),cropBounds.height(),mConfig);
  }
  Matrix drawMatrix=buildMatrix(crop);
  Canvas canvas=new Canvas(temp);
  Paint paint=new Paint();
  paint.setAntiAlias(true);
  paint.setFilterBitmap(true);
  paint.setDither(true);
  canvas.drawBitmap(bitmap,drawMatrix,paint);
  return temp;
}

Fixed version (ground truth):
@Override public Bitmap apply(Bitmap bitmap,float scaleFactor,boolean highQuality){
  Rect cropBounds=new Rect(0,0,bitmap.getWidth(),bitmap.getHeight());
  RectF crop=mGeometry.getCropBounds(bitmap);
  if (crop.width() > 0 && crop.height() > 0)   crop.roundOut(cropBounds);
  Bitmap temp=null;
  if (mGeometry.hasSwitchedWidthHeight()) {
    temp=Bitmap.createBitmap(cropBounds.height(),cropBounds.width(),mConfig);
  }
 else {
    temp=Bitmap.createBitmap(cropBounds.width(),cropBounds.height(),mConfig);
  }
  RectF rp=mGeometry.getPhotoBounds();
  RectF rc=mGeometry.getPreviewCropBounds();
  Matrix drawMatrix=mGeometry.buildTotalXform(rp.width(),rp.height(),rc.width(),rc.height(),rc.left,rc.top,mGeometry.getRotation(),mGeometry.getStraightenRotation(),bitmap.getWidth() / rp.width(),null);
  Canvas canvas=new Canvas(temp);
  Paint paint=new Paint();
  paint.setAntiAlias(true);
  paint.setFilterBitmap(true);
  paint.setDither(true);
  canvas.drawBitmap(bitmap,drawMatrix,paint);
  return temp;
}
Program: 38484
Project: 38484
Buggy source:
public Matrix buildTotalXform(float pwidth,float pheight,float cwidth,float cheight,float cleft,float ctop,float rotation,float straighten,float scale,RectF dst){
  Matrix m=getFlipMatrix(pwidth,pheight);
  m.postRotate(rotation + straighten,pwidth / 2,pheight / 2);
  Matrix m1=new Matrix();
  m1.setRotate(rotation,pwidth / 2,pheight / 2);
  RectF crop=new RectF(cleft,ctop,cleft + cwidth,ctop + cheight);
  if (!m1.mapRect(crop))   return null;
  if (dst != null)   dst.set(crop);
  m.postTranslate(-crop.left,-crop.top);
  m.postScale(scale,scale);
  return m;
}

Fixed version (ground truth):
public Matrix buildTotalXform(float pwidth,float pheight,float cwidth,float cheight,float cleft,float ctop,float rotation,float straighten,float scale,RectF dst){
  float s_pwidth=pwidth * scale;
  float s_pheight=pheight * scale;
  Matrix m=getFlipMatrix(s_pwidth,s_pheight);
  m.postRotate(rotation + straighten,s_pwidth / 2,s_pheight / 2);
  Matrix m1=getFlipMatrix(s_pwidth,s_pheight);
  m1.postRotate(rotation,s_pwidth / 2,s_pheight / 2);
  RectF crop=new RectF(cleft * scale,ctop * scale,(cleft + cwidth) * scale,(ctop + cheight) * scale);
  if (!m1.mapRect(crop))   return null;
  if (dst != null)   dst.set(crop);
  m.postTranslate(-crop.left,-crop.top);
  return m;
}
Program: 38485
Project: 38485
Buggy source:
@Override public Bitmap apply(Bitmap bitmap,float scaleFactor,boolean highQuality){
  Rect cropBounds=new Rect(0,0,bitmap.getWidth(),bitmap.getHeight());
  RectF crop=mGeometry.getCropBounds(bitmap);
  if (crop.width() > 0 && crop.height() > 0)   crop.roundOut(cropBounds);
  Bitmap temp=null;
  if (mGeometry.hasSwitchedWidthHeight()) {
    temp=Bitmap.createBitmap(cropBounds.height(),cropBounds.width(),mConfig);
  }
 else {
    temp=Bitmap.createBitmap(cropBounds.width(),cropBounds.height(),mConfig);
  }
  Matrix drawMatrix=buildMatrix(crop);
  Canvas canvas=new Canvas(temp);
  canvas.drawBitmap(bitmap,drawMatrix,new Paint());
  return temp;
}

Fixed version (ground truth):
@Override public Bitmap apply(Bitmap bitmap,float scaleFactor,boolean highQuality){
  Rect cropBounds=new Rect(0,0,bitmap.getWidth(),bitmap.getHeight());
  RectF crop=mGeometry.getCropBounds(bitmap);
  if (crop.width() > 0 && crop.height() > 0)   crop.roundOut(cropBounds);
  Bitmap temp=null;
  if (mGeometry.hasSwitchedWidthHeight()) {
    temp=Bitmap.createBitmap(cropBounds.height(),cropBounds.width(),mConfig);
  }
 else {
    temp=Bitmap.createBitmap(cropBounds.width(),cropBounds.height(),mConfig);
  }
  Matrix drawMatrix=buildMatrix(crop);
  Canvas canvas=new Canvas(temp);
  Paint paint=new Paint();
  paint.setAntiAlias(true);
  paint.setFilterBitmap(true);
  paint.setDither(true);
  canvas.drawBitmap(bitmap,drawMatrix,paint);
  return temp;
}
Program: 38486
Project: 38486
Buggy source:
@Override protected void drawShape(Canvas canvas,Bitmap image){
  gPaint.setAntiAlias(true);
  gPaint.setFilterBitmap(true);
  gPaint.setDither(true);
  gPaint.setARGB(255,255,255,255);
  if (mFirstDraw) {
    cropSetup();
    mFirstDraw=false;
  }
  float rotation=getLocalRotation();
  drawTransformedBitmap(canvas,image,gPaint,true);
  gPaint.setARGB(255,125,255,128);
  gPaint.setStrokeWidth(3);
  gPaint.setStyle(Paint.Style.STROKE);
  drawStraighten(canvas,gPaint);
  RectF scaledCrop=unrotatedCropBounds();
  int decoded_moving=decoder(movingEdges,rotation);
  canvas.save();
  canvas.rotate(rotation,mCenterX,mCenterY);
  boolean notMoving=decoded_moving == 0;
  if (((decoded_moving & MOVE_TOP) != 0) || notMoving) {
    drawIndicator(canvas,cropIndicator,scaledCrop.centerX(),scaledCrop.top);
  }
  if (((decoded_moving & MOVE_BOTTOM) != 0) || notMoving) {
    drawIndicator(canvas,cropIndicator,scaledCrop.centerX(),scaledCrop.bottom);
  }
  if (((decoded_moving & MOVE_LEFT) != 0) || notMoving) {
    drawIndicator(canvas,cropIndicator,scaledCrop.left,scaledCrop.centerY());
  }
  if (((decoded_moving & MOVE_RIGHT) != 0) || notMoving) {
    drawIndicator(canvas,cropIndicator,scaledCrop.right,scaledCrop.centerY());
  }
  canvas.restore();
}

Fixed version (ground truth):
@Override protected void drawShape(Canvas canvas,Bitmap image){
  gPaint.setAntiAlias(true);
  gPaint.setFilterBitmap(true);
  gPaint.setDither(true);
  gPaint.setARGB(255,255,255,255);
  if (mFirstDraw) {
    cropSetup();
    mFirstDraw=false;
  }
  float rotation=getLocalRotation();
  drawTransformedBitmap(canvas,image,gPaint,true);
  gPaint.setColor(mBorderColor);
  gPaint.setStrokeWidth(3);
  gPaint.setStyle(Paint.Style.STROKE);
  drawStraighten(canvas,gPaint);
  RectF scaledCrop=unrotatedCropBounds();
  drawRuleOfThird(canvas,scaledCrop);
  int decoded_moving=decoder(movingEdges,rotation);
  canvas.save();
  canvas.rotate(rotation,mCenterX,mCenterY);
  boolean notMoving=decoded_moving == 0;
  if (((decoded_moving & MOVE_TOP) != 0) || notMoving) {
    drawIndicator(canvas,cropIndicator,scaledCrop.centerX(),scaledCrop.top);
  }
  if (((decoded_moving & MOVE_BOTTOM) != 0) || notMoving) {
    drawIndicator(canvas,cropIndicator,scaledCrop.centerX(),scaledCrop.bottom);
  }
  if (((decoded_moving & MOVE_LEFT) != 0) || notMoving) {
    drawIndicator(canvas,cropIndicator,scaledCrop.left,scaledCrop.centerY());
  }
  if (((decoded_moving & MOVE_RIGHT) != 0) || notMoving) {
    drawIndicator(canvas,cropIndicator,scaledCrop.right,scaledCrop.centerY());
  }
  canvas.restore();
}
Program: 38487
Project: 38487
Buggy source:
public ImageCrop(Context context,AttributeSet attrs){
  super(context,attrs);
  Resources resources=context.getResources();
  cropIndicator=resources.getDrawable(R.drawable.camera_crop);
  indicatorSize=(int)resources.getDimension(R.dimen.crop_indicator_size);
  int borderColor=Color.argb(128,255,255,255);
  borderPaint=new Paint();
  borderPaint.setStyle(Paint.Style.STROKE);
  borderPaint.setColor(borderColor);
  borderPaint.setStrokeWidth(2f);
}

Fixed version (ground truth):
public ImageCrop(Context context,AttributeSet attrs){
  super(context,attrs);
  Resources resources=context.getResources();
  cropIndicator=resources.getDrawable(R.drawable.camera_crop);
  indicatorSize=(int)resources.getDimension(R.dimen.crop_indicator_size);
  borderPaint=new Paint();
  borderPaint.setStyle(Paint.Style.STROKE);
  borderPaint.setColor(mBorderColor);
  borderPaint.setStrokeWidth(2f);
}
Program: 38488
Project: 38488
Buggy source:
@Override public Bitmap apply(Bitmap bitmap,float scaleFactor,boolean highQuality){
  Rect cropBounds=new Rect(0,0,bitmap.getWidth(),bitmap.getHeight());
  RectF crop=mGeometry.getCropBounds(bitmap);
  if (crop.width() > 0 && crop.height() > 0)   crop.roundOut(cropBounds);
  Bitmap temp=null;
  if (mGeometry.hasSwitchedWidthHeight()) {
    temp=Bitmap.createBitmap(cropBounds.height(),cropBounds.width(),mConfig);
  }
 else {
    temp=Bitmap.createBitmap(cropBounds.width(),cropBounds.height(),mConfig);
  }
  Matrix drawMatrix=buildMatrix(crop);
  Canvas canvas=new Canvas(temp);
  canvas.drawBitmap(bitmap,drawMatrix,new Paint());
  return temp;
}

Fixed version (ground truth):
@Override public Bitmap apply(Bitmap bitmap,float scaleFactor,boolean highQuality){
  Rect cropBounds=new Rect(0,0,bitmap.getWidth(),bitmap.getHeight());
  RectF crop=mGeometry.getCropBounds(bitmap);
  if (crop.width() > 0 && crop.height() > 0)   crop.roundOut(cropBounds);
  Bitmap temp=null;
  if (mGeometry.hasSwitchedWidthHeight()) {
    temp=Bitmap.createBitmap(cropBounds.height(),cropBounds.width(),mConfig);
  }
 else {
    temp=Bitmap.createBitmap(cropBounds.width(),cropBounds.height(),mConfig);
  }
  Matrix drawMatrix=buildMatrix(crop);
  Canvas canvas=new Canvas(temp);
  Paint paint=new Paint();
  paint.setAntiAlias(true);
  paint.setFilterBitmap(true);
  paint.setDither(true);
  canvas.drawBitmap(bitmap,drawMatrix,paint);
  return temp;
}
Program: 38489
Project: 38489
Buggy source:
@Override protected void drawShape(Canvas canvas,Bitmap image){
  gPaint.setAntiAlias(true);
  gPaint.setFilterBitmap(true);
  gPaint.setDither(true);
  gPaint.setARGB(255,255,255,255);
  if (mFirstDraw) {
    cropSetup();
    mFirstDraw=false;
  }
  float rotation=getLocalRotation();
  drawTransformedBitmap(canvas,image,gPaint,true);
  gPaint.setARGB(255,125,255,128);
  gPaint.setStrokeWidth(3);
  gPaint.setStyle(Paint.Style.STROKE);
  drawStraighten(canvas,gPaint);
  RectF scaledCrop=unrotatedCropBounds();
  int decoded_moving=decoder(movingEdges,rotation);
  canvas.save();
  canvas.rotate(rotation,mCenterX,mCenterY);
  boolean notMoving=decoded_moving == 0;
  if (((decoded_moving & MOVE_TOP) != 0) || notMoving) {
    drawIndicator(canvas,cropIndicator,scaledCrop.centerX(),scaledCrop.top);
  }
  if (((decoded_moving & MOVE_BOTTOM) != 0) || notMoving) {
    drawIndicator(canvas,cropIndicator,scaledCrop.centerX(),scaledCrop.bottom);
  }
  if (((decoded_moving & MOVE_LEFT) != 0) || notMoving) {
    drawIndicator(canvas,cropIndicator,scaledCrop.left,scaledCrop.centerY());
  }
  if (((decoded_moving & MOVE_RIGHT) != 0) || notMoving) {
    drawIndicator(canvas,cropIndicator,scaledCrop.right,scaledCrop.centerY());
  }
  canvas.restore();
}

Fixed version (ground truth):
@Override protected void drawShape(Canvas canvas,Bitmap image){
  gPaint.setAntiAlias(true);
  gPaint.setFilterBitmap(true);
  gPaint.setDither(true);
  gPaint.setARGB(255,255,255,255);
  if (mFirstDraw) {
    cropSetup();
    mFirstDraw=false;
  }
  float rotation=getLocalRotation();
  drawTransformedBitmap(canvas,image,gPaint,true);
  gPaint.setColor(mBorderColor);
  gPaint.setStrokeWidth(3);
  gPaint.setStyle(Paint.Style.STROKE);
  drawStraighten(canvas,gPaint);
  RectF scaledCrop=unrotatedCropBounds();
  drawRuleOfThird(canvas,scaledCrop);
  int decoded_moving=decoder(movingEdges,rotation);
  canvas.save();
  canvas.rotate(rotation,mCenterX,mCenterY);
  boolean notMoving=decoded_moving == 0;
  if (((decoded_moving & MOVE_TOP) != 0) || notMoving) {
    drawIndicator(canvas,cropIndicator,scaledCrop.centerX(),scaledCrop.top);
  }
  if (((decoded_moving & MOVE_BOTTOM) != 0) || notMoving) {
    drawIndicator(canvas,cropIndicator,scaledCrop.centerX(),scaledCrop.bottom);
  }
  if (((decoded_moving & MOVE_LEFT) != 0) || notMoving) {
    drawIndicator(canvas,cropIndicator,scaledCrop.left,scaledCrop.centerY());
  }
  if (((decoded_moving & MOVE_RIGHT) != 0) || notMoving) {
    drawIndicator(canvas,cropIndicator,scaledCrop.right,scaledCrop.centerY());
  }
  canvas.restore();
}
Program: 38490
Project: 38490
Buggy source:
public ImageCrop(Context context,AttributeSet attrs){
  super(context,attrs);
  Resources resources=context.getResources();
  cropIndicator=resources.getDrawable(R.drawable.camera_crop);
  indicatorSize=(int)resources.getDimension(R.dimen.crop_indicator_size);
  int borderColor=Color.argb(128,255,255,255);
  borderPaint=new Paint();
  borderPaint.setStyle(Paint.Style.STROKE);
  borderPaint.setColor(borderColor);
  borderPaint.setStrokeWidth(2f);
}

Fixed version (ground truth):
public ImageCrop(Context context,AttributeSet attrs){
  super(context,attrs);
  Resources resources=context.getResources();
  cropIndicator=resources.getDrawable(R.drawable.camera_crop);
  indicatorSize=(int)resources.getDimension(R.dimen.crop_indicator_size);
  borderPaint=new Paint();
  borderPaint.setStyle(Paint.Style.STROKE);
  borderPaint.setColor(mBorderColor);
  borderPaint.setStrokeWidth(2f);
}
Program: 38491
Project: 38491
Buggy source:
@Override protected void onStateResult(int requestCode,int resultCode,Intent data){
  mHasActivityResult=true;
switch (requestCode) {
case REQUEST_EDIT:
    setCurrentPhotoByIntent(data);
  break;
case REQUEST_CROP:
if (resultCode == Activity.RESULT_OK) {
  setCurrentPhotoByIntent(data);
}
break;
case REQUEST_CROP_PICASA:
{
if (resultCode == Activity.RESULT_OK) {
Context context=mActivity.getAndroidContext();
String message=context.getString(R.string.crop_saved,context.getString(R.string.folder_download));
Toast.makeText(context,message,Toast.LENGTH_SHORT).show();
}
break;
}
case REQUEST_SLIDESHOW:
{
if (data == null) break;
String path=data.getStringExtra(SlideshowPage.KEY_ITEM_PATH);
int index=data.getIntExtra(SlideshowPage.KEY_PHOTO_INDEX,0);
if (path != null) {
mModel.setCurrentPhoto(Path.fromString(path),index);
}
}
}
}

Fixed version (ground truth):
@Override protected void onStateResult(int requestCode,int resultCode,Intent data){
  mHasActivityResult=true;
switch (requestCode) {
case REQUEST_EDIT:
    setCurrentPhotoByIntent(data);
  break;
case REQUEST_CROP:
if (resultCode == Activity.RESULT_OK) {
  setCurrentPhotoByIntent(data);
}
break;
case REQUEST_CROP_PICASA:
{
if (resultCode == Activity.RESULT_OK) {
Context context=mActivity.getAndroidContext();
String message=context.getString(R.string.crop_saved,context.getString(R.string.folder_edited_online_photos));
Toast.makeText(context,message,Toast.LENGTH_SHORT).show();
}
break;
}
case REQUEST_SLIDESHOW:
{
if (data == null) break;
String path=data.getStringExtra(SlideshowPage.KEY_ITEM_PATH);
int index=data.getIntExtra(SlideshowPage.KEY_PHOTO_INDEX,0);
if (path != null) {
mModel.setCurrentPhoto(Path.fromString(path),index);
}
}
}
}
Program: 38492
Project: 38492
Buggy source:
@Override protected void onStateResult(int requestCode,int resultCode,Intent data){
  mHasActivityResult=true;
switch (requestCode) {
case REQUEST_EDIT:
    setCurrentPhotoByIntent(data);
  break;
case REQUEST_CROP:
if (resultCode == Activity.RESULT_OK) {
  setCurrentPhotoByIntent(data);
}
break;
case REQUEST_CROP_PICASA:
{
if (resultCode == Activity.RESULT_OK) {
Context context=mActivity.getAndroidContext();
String message=context.getString(R.string.crop_saved,context.getString(R.string.folder_download));
Toast.makeText(context,message,Toast.LENGTH_SHORT).show();
}
break;
}
case REQUEST_SLIDESHOW:
{
if (data == null) break;
String path=data.getStringExtra(SlideshowPage.KEY_ITEM_PATH);
int index=data.getIntExtra(SlideshowPage.KEY_PHOTO_INDEX,0);
if (path != null) {
mModel.setCurrentPhoto(Path.fromString(path),index);
}
}
}
}

Fixed version (ground truth):
@Override protected void onStateResult(int requestCode,int resultCode,Intent data){
  mHasActivityResult=true;
switch (requestCode) {
case REQUEST_EDIT:
    setCurrentPhotoByIntent(data);
  break;
case REQUEST_CROP:
if (resultCode == Activity.RESULT_OK) {
  setCurrentPhotoByIntent(data);
}
break;
case REQUEST_CROP_PICASA:
{
if (resultCode == Activity.RESULT_OK) {
Context context=mActivity.getAndroidContext();
String message=context.getString(R.string.crop_saved,context.getString(R.string.folder_edited_online_photos));
Toast.makeText(context,message,Toast.LENGTH_SHORT).show();
}
break;
}
case REQUEST_SLIDESHOW:
{
if (data == null) break;
String path=data.getStringExtra(SlideshowPage.KEY_ITEM_PATH);
int index=data.getIntExtra(SlideshowPage.KEY_PHOTO_INDEX,0);
if (path != null) {
mModel.setCurrentPhoto(Path.fromString(path),index);
}
}
}
}
Program: 38493
Project: 38493
Buggy source:
@Override public Bitmap apply(Bitmap bitmap,float scaleFactor,boolean highQuality){
  Rect cropBounds=new Rect(0,0,bitmap.getWidth(),bitmap.getHeight());
  RectF crop=mGeometry.getCropBounds(bitmap);
  if (crop.width() > 0 && crop.height() > 0)   crop.roundOut(cropBounds);
  Bitmap temp=null;
  if (mGeometry.hasSwitchedWidthHeight()) {
    temp=Bitmap.createBitmap(cropBounds.height(),cropBounds.width(),mConfig);
  }
 else {
    temp=Bitmap.createBitmap(cropBounds.width(),cropBounds.height(),mConfig);
  }
  Matrix drawMatrix=buildMatrix(crop);
  Canvas canvas=new Canvas(temp);
  canvas.drawBitmap(bitmap,drawMatrix,new Paint());
  return temp;
}

Fixed version (ground truth):
@Override public Bitmap apply(Bitmap bitmap,float scaleFactor,boolean highQuality){
  Rect cropBounds=new Rect(0,0,bitmap.getWidth(),bitmap.getHeight());
  RectF crop=mGeometry.getCropBounds(bitmap);
  if (crop.width() > 0 && crop.height() > 0)   crop.roundOut(cropBounds);
  Bitmap temp=null;
  if (mGeometry.hasSwitchedWidthHeight()) {
    temp=Bitmap.createBitmap(cropBounds.height(),cropBounds.width(),mConfig);
  }
 else {
    temp=Bitmap.createBitmap(cropBounds.width(),cropBounds.height(),mConfig);
  }
  RectF rp=mGeometry.getPhotoBounds();
  RectF rc=mGeometry.getPreviewCropBounds();
  Matrix drawMatrix=mGeometry.buildTotalXform(rp.width(),rp.height(),rc.width(),rc.height(),rc.left,rc.top,mGeometry.getRotation(),mGeometry.getStraightenRotation(),bitmap.getWidth() / rp.width(),null);
  Canvas canvas=new Canvas(temp);
  canvas.drawBitmap(bitmap,drawMatrix,new Paint());
  return temp;
}
Program: 38494
Project: 38494
Buggy source:
@Override protected void onStateResult(int requestCode,int resultCode,Intent data){
  mHasActivityResult=true;
switch (requestCode) {
case REQUEST_EDIT:
    setCurrentPhotoByIntent(data);
  break;
case REQUEST_CROP:
if (resultCode == Activity.RESULT_OK) {
  setCurrentPhotoByIntent(data);
}
break;
case REQUEST_CROP_PICASA:
{
if (resultCode == Activity.RESULT_OK) {
Context context=mActivity.getAndroidContext();
String message=context.getString(R.string.crop_saved,context.getString(R.string.folder_download));
Toast.makeText(context,message,Toast.LENGTH_SHORT).show();
}
break;
}
case REQUEST_SLIDESHOW:
{
if (data == null) break;
String path=data.getStringExtra(SlideshowPage.KEY_ITEM_PATH);
int index=data.getIntExtra(SlideshowPage.KEY_PHOTO_INDEX,0);
if (path != null) {
mModel.setCurrentPhoto(Path.fromString(path),index);
}
}
}
}

Fixed version (ground truth):
@Override protected void onStateResult(int requestCode,int resultCode,Intent data){
  mHasActivityResult=true;
switch (requestCode) {
case REQUEST_EDIT:
    setCurrentPhotoByIntent(data);
  break;
case REQUEST_CROP:
if (resultCode == Activity.RESULT_OK) {
  setCurrentPhotoByIntent(data);
}
break;
case REQUEST_CROP_PICASA:
{
if (resultCode == Activity.RESULT_OK) {
Context context=mActivity.getAndroidContext();
String message=context.getString(R.string.crop_saved,context.getString(R.string.folder_edited_online_photos));
Toast.makeText(context,message,Toast.LENGTH_SHORT).show();
}
break;
}
case REQUEST_SLIDESHOW:
{
if (data == null) break;
String path=data.getStringExtra(SlideshowPage.KEY_ITEM_PATH);
int index=data.getIntExtra(SlideshowPage.KEY_PHOTO_INDEX,0);
if (path != null) {
mModel.setCurrentPhoto(Path.fromString(path),index);
}
}
}
}
Program: 38495
Project: 38495
Buggy source:
@Override public Bitmap apply(Bitmap bitmap,float scaleFactor,boolean highQuality){
  Rect cropBounds=new Rect(0,0,bitmap.getWidth(),bitmap.getHeight());
  RectF crop=mGeometry.getCropBounds(bitmap);
  if (crop.width() > 0 && crop.height() > 0)   crop.roundOut(cropBounds);
  Bitmap temp=null;
  if (mGeometry.hasSwitchedWidthHeight()) {
    temp=Bitmap.createBitmap(cropBounds.height(),cropBounds.width(),mConfig);
  }
 else {
    temp=Bitmap.createBitmap(cropBounds.width(),cropBounds.height(),mConfig);
  }
  Matrix drawMatrix=buildMatrix(crop);
  Canvas canvas=new Canvas(temp);
  canvas.drawBitmap(bitmap,drawMatrix,new Paint());
  return temp;
}

Fixed version (ground truth):
@Override public Bitmap apply(Bitmap bitmap,float scaleFactor,boolean highQuality){
  Rect cropBounds=new Rect(0,0,bitmap.getWidth(),bitmap.getHeight());
  RectF crop=mGeometry.getCropBounds(bitmap);
  if (crop.width() > 0 && crop.height() > 0)   crop.roundOut(cropBounds);
  Bitmap temp=null;
  if (mGeometry.hasSwitchedWidthHeight()) {
    temp=Bitmap.createBitmap(cropBounds.height(),cropBounds.width(),mConfig);
  }
 else {
    temp=Bitmap.createBitmap(cropBounds.width(),cropBounds.height(),mConfig);
  }
  RectF rp=mGeometry.getPhotoBounds();
  RectF rc=mGeometry.getPreviewCropBounds();
  Matrix drawMatrix=mGeometry.buildTotalXform(rp.width(),rp.height(),rc.width(),rc.height(),rc.left,rc.top,mGeometry.getRotation(),mGeometry.getStraightenRotation(),bitmap.getWidth() / rp.width(),null);
  Canvas canvas=new Canvas(temp);
  canvas.drawBitmap(bitmap,drawMatrix,new Paint());
  return temp;
}
Program: 38496
Project: 38496
Buggy source:
@Override public Bitmap apply(Bitmap bitmap,float scaleFactor,boolean highQuality){
  Rect cropBounds=new Rect(0,0,bitmap.getWidth(),bitmap.getHeight());
  RectF c=mGeometry.getCropBounds();
  if (c != null && c.width() > 0 && c.height() > 0)   c.roundOut(cropBounds);
  Bitmap temp=null;
  if (mGeometry.hasSwitchedWidthHeight()) {
    temp=Bitmap.createBitmap(cropBounds.height(),cropBounds.width(),mConfig);
  }
 else {
    temp=Bitmap.createBitmap(cropBounds.width(),cropBounds.height(),mConfig);
  }
  Matrix drawMatrix=buildMatrix(c);
  Canvas canvas=new Canvas(temp);
  canvas.drawBitmap(bitmap,drawMatrix,new Paint());
  return temp;
}

Fixed version (ground truth):
@Override public Bitmap apply(Bitmap bitmap,float scaleFactor,boolean highQuality){
  Rect cropBounds=new Rect(0,0,bitmap.getWidth(),bitmap.getHeight());
  RectF crop=mGeometry.getCropBounds(bitmap);
  if (crop.width() > 0 && crop.height() > 0)   crop.roundOut(cropBounds);
  Bitmap temp=null;
  if (mGeometry.hasSwitchedWidthHeight()) {
    temp=Bitmap.createBitmap(cropBounds.height(),cropBounds.width(),mConfig);
  }
 else {
    temp=Bitmap.createBitmap(cropBounds.width(),cropBounds.height(),mConfig);
  }
  Matrix drawMatrix=buildMatrix(crop);
  Canvas canvas=new Canvas(temp);
  canvas.drawBitmap(bitmap,drawMatrix,new Paint());
  return temp;
}
Program: 38497
Project: 38497
Buggy source:
public RectF getCropBounds(){
  return new RectF(mCropBounds);
}

Fixed version (ground truth):
public RectF getCropBounds(Bitmap bitmap){
  float scale=1.0f;
  if (mPhotoBounds.width() > 0) {
    scale=bitmap.getWidth() / mPhotoBounds.width();
  }
  return new RectF(mCropBounds.left * scale,mCropBounds.top * scale,mCropBounds.right * scale,mCropBounds.bottom * scale);
}
Program: 38498
Project: 38498
Buggy source:
protected RectF getLocalCropBounds(){
  return mLocalGeometry.getCropBounds();
}

Fixed version (ground truth):
protected RectF getLocalCropBounds(){
  return mLocalGeometry.getPreviewCropBounds();
}
Program: 38499
Project: 38499
Buggy source:
@Override public Bitmap apply(Bitmap bitmap,float scaleFactor,boolean highQuality){
  Rect cropBounds=new Rect(0,0,bitmap.getWidth(),bitmap.getHeight());
  RectF c=mGeometry.getCropBounds();
  if (c != null && c.width() > 0 && c.height() > 0)   c.roundOut(cropBounds);
  Bitmap temp=null;
  if (mGeometry.hasSwitchedWidthHeight()) {
    temp=Bitmap.createBitmap(cropBounds.height(),cropBounds.width(),mConfig);
  }
 else {
    temp=Bitmap.createBitmap(cropBounds.width(),cropBounds.height(),mConfig);
  }
  Matrix drawMatrix=buildMatrix(c);
  Canvas canvas=new Canvas(temp);
  canvas.drawBitmap(bitmap,drawMatrix,new Paint());
  return temp;
}

Fixed version (ground truth):
@Override public Bitmap apply(Bitmap bitmap,float scaleFactor,boolean highQuality){
  Rect cropBounds=new Rect(0,0,bitmap.getWidth(),bitmap.getHeight());
  RectF crop=mGeometry.getCropBounds(bitmap);
  if (crop.width() > 0 && crop.height() > 0)   crop.roundOut(cropBounds);
  Bitmap temp=null;
  if (mGeometry.hasSwitchedWidthHeight()) {
    temp=Bitmap.createBitmap(cropBounds.height(),cropBounds.width(),mConfig);
  }
 else {
    temp=Bitmap.createBitmap(cropBounds.width(),cropBounds.height(),mConfig);
  }
  Matrix drawMatrix=buildMatrix(crop);
  Canvas canvas=new Canvas(temp);
  canvas.drawBitmap(bitmap,drawMatrix,new Paint());
  return temp;
}
Program: 38500
Project: 38500
Buggy source:
public RectF getCropBounds(){
  return new RectF(mCropBounds);
}

Fixed version (ground truth):
public RectF getCropBounds(Bitmap bitmap){
  float scale=1.0f;
  if (mPhotoBounds.width() > 0) {
    scale=bitmap.getWidth() / mPhotoBounds.width();
  }
  return new RectF(mCropBounds.left * scale,mCropBounds.top * scale,mCropBounds.right * scale,mCropBounds.bottom * scale);
}
Program: 38501
Project: 38501
Buggy source:
protected RectF getLocalCropBounds(){
  return mLocalGeometry.getCropBounds();
}

Fixed version (ground truth):
protected RectF getLocalCropBounds(){
  return mLocalGeometry.getPreviewCropBounds();
}
Program: 38502
Project: 38502
Buggy source:
private void onBitmapRegionDecoderAvailable(BitmapRegionDecoder regionDecoder){
  if (regionDecoder == null) {
    Toast.makeText(this,R.string.fail_to_load_image,Toast.LENGTH_SHORT).show();
    finish();
    return;
  }
  mRegionDecoder=regionDecoder;
  mUseRegionDecoder=true;
  mState=STATE_LOADED;
  BitmapFactory.Options options=new BitmapFactory.Options();
  int width=regionDecoder.getWidth();
  int height=regionDecoder.getHeight();
  options.inSampleSize=BitmapUtils.computeSampleSize(width,height,BitmapUtils.UNCONSTRAINED,BACKUP_PIXEL_COUNT);
  mBitmap=regionDecoder.decodeRegion(new Rect(0,0,width,height),options);
  mCropView.setDataModel(new TileImageViewAdapter(mBitmap,regionDecoder),mMediaItem.getFullImageRotation());
  if (mDoFaceDetection) {
    mCropView.detectFaces(mBitmap);
  }
 else {
    mCropView.initializeHighlightRectangle();
  }
}

Fixed version (ground truth):
private void onBitmapRegionDecoderAvailable(BitmapRegionDecoder regionDecoder){
  if (regionDecoder == null) {
    Toast.makeText(this,R.string.fail_to_load_image,Toast.LENGTH_SHORT).show();
    finish();
    return;
  }
  mRegionDecoder=regionDecoder;
  mUseRegionDecoder=true;
  mState=STATE_LOADED;
  BitmapFactory.Options options=new BitmapFactory.Options();
  int width=regionDecoder.getWidth();
  int height=regionDecoder.getHeight();
  options.inSampleSize=BitmapUtils.computeSampleSize(width,height,BitmapUtils.UNCONSTRAINED,BACKUP_PIXEL_COUNT);
  mBitmap=regionDecoder.decodeRegion(new Rect(0,0,width,height),options);
  mBitmapScreenNail=new BitmapScreenNail(mBitmap);
  TileImageViewAdapter adapter=new TileImageViewAdapter();
  adapter.setScreenNail(mBitmapScreenNail,width,height);
  adapter.setRegionDecoder(regionDecoder);
  mCropView.setDataModel(adapter,mMediaItem.getFullImageRotation());
  if (mDoFaceDetection) {
    mCropView.detectFaces(mBitmap);
  }
 else {
    mCropView.initializeHighlightRectangle();
  }
}
Program: 38503
Project: 38503
Buggy source:
private void uploadScreenNail(int offset){
  int index=mCurrentIndex + offset;
  if (index < mActiveStart || index >= mActiveEnd)   return;
  MediaItem item=getItem(index);
  if (item == null)   return;
  ImageEntry e=mImageCache.get(item.getPath());
  if (e == null)   return;
  ScreenNail s=e.screenNail;
  if (s instanceof BitmapScreenNail) {
    TiledTexture t=((BitmapScreenNail)s).getTexture();
    if (t != null && !t.isReady())     mUploader.addTexture(t);
  }
}

Fixed version (ground truth):
private void uploadScreenNail(int offset){
  int index=mCurrentIndex + offset;
  if (index < mActiveStart || index >= mActiveEnd)   return;
  MediaItem item=getItem(index);
  if (item == null)   return;
  ImageEntry e=mImageCache.get(item.getPath());
  if (e == null)   return;
  ScreenNail s=e.screenNail;
  if (s instanceof TiledScreenNail) {
    TiledTexture t=((TiledScreenNail)s).getTexture();
    if (t != null && !t.isReady())     mUploader.addTexture(t);
  }
}
Program: 38504
Project: 38504
Buggy source:
private void updateCurrentIndex(int index){
  if (mCurrentIndex == index)   return;
  mCurrentIndex=index;
  updateSlidingWindow();
  MediaItem item=mData[index % DATA_CACHE_SIZE];
  mItemPath=item == null ? null : item.getPath();
  updateImageCache();
  updateImageRequests();
  updateTileProvider();
  updateScreenNailUploadQueue();
  if (mDataListener != null) {
    mDataListener.onPhotoChanged(index,mItemPath);
  }
  fireDataChange();
}

Fixed version (ground truth):
private void updateCurrentIndex(int index){
  if (mCurrentIndex == index)   return;
  mCurrentIndex=index;
  updateSlidingWindow();
  MediaItem item=mData[index % DATA_CACHE_SIZE];
  mItemPath=item == null ? null : item.getPath();
  updateImageCache();
  updateImageRequests();
  updateTileProvider();
  if (mDataListener != null) {
    mDataListener.onPhotoChanged(index,mItemPath);
  }
  fireDataChange();
}
Program: 38505
Project: 38505
Buggy source:
private ScreenNail newPlaceholderScreenNail(MediaItem item){
  int width=item.getWidth();
  int height=item.getHeight();
  return new BitmapScreenNail(width,height);
}

Fixed version (ground truth):
private ScreenNail newPlaceholderScreenNail(MediaItem item){
  int width=item.getWidth();
  int height=item.getHeight();
  return new TiledScreenNail(width,height);
}
Program: 38506
Project: 38506
Buggy source:
private void updateScreenNail(Path path,Future<ScreenNail> future){
  ImageEntry entry=mImageCache.get(path);
  ScreenNail screenNail=future.get();
  if (entry == null || entry.screenNailTask != future) {
    if (screenNail != null)     screenNail.recycle();
    return;
  }
  entry.screenNailTask=null;
  if (entry.screenNail instanceof BitmapScreenNail) {
    BitmapScreenNail original=(BitmapScreenNail)entry.screenNail;
    screenNail=original.combine(screenNail);
  }
  if (screenNail == null) {
    entry.failToLoad=true;
  }
 else {
    entry.failToLoad=false;
    entry.screenNail=screenNail;
  }
  for (int i=-SCREEN_NAIL_MAX; i <= SCREEN_NAIL_MAX; ++i) {
    if (path == getPath(mCurrentIndex + i)) {
      if (i == 0)       updateTileProvider(entry);
      mPhotoView.notifyImageChange(i);
      break;
    }
  }
  updateImageRequests();
  updateScreenNailUploadQueue();
}

Fixed version (ground truth):
private void updateScreenNail(Path path,Future<ScreenNail> future){
  ImageEntry entry=mImageCache.get(path);
  ScreenNail screenNail=future.get();
  if (entry == null || entry.screenNailTask != future) {
    if (screenNail != null)     screenNail.recycle();
    return;
  }
  entry.screenNailTask=null;
  if (entry.screenNail instanceof TiledScreenNail) {
    TiledScreenNail original=(TiledScreenNail)entry.screenNail;
    screenNail=original.combine(screenNail);
  }
  if (screenNail == null) {
    entry.failToLoad=true;
  }
 else {
    entry.failToLoad=false;
    entry.screenNail=screenNail;
  }
  for (int i=-SCREEN_NAIL_MAX; i <= SCREEN_NAIL_MAX; ++i) {
    if (path == getPath(mCurrentIndex + i)) {
      if (i == 0)       updateTileProvider(entry);
      mPhotoView.notifyImageChange(i);
      break;
    }
  }
  updateImageRequests();
  updateScreenNailUploadQueue();
}
Program: 38507
Project: 38507
Buggy source:
private void updateImageCache(){
  HashSet<Path> toBeRemoved=new HashSet<Path>(mImageCache.keySet());
  for (int i=mActiveStart; i < mActiveEnd; ++i) {
    MediaItem item=mData[i % DATA_CACHE_SIZE];
    if (item == null)     continue;
    Path path=item.getPath();
    ImageEntry entry=mImageCache.get(path);
    toBeRemoved.remove(path);
    if (entry != null) {
      if (Math.abs(i - mCurrentIndex) > 1) {
        if (entry.fullImageTask != null) {
          entry.fullImageTask.cancel();
          entry.fullImageTask=null;
        }
        entry.fullImage=null;
        entry.requestedFullImage=MediaObject.INVALID_DATA_VERSION;
      }
      if (entry.requestedScreenNail != item.getDataVersion()) {
        if (entry.screenNail instanceof BitmapScreenNail) {
          BitmapScreenNail s=(BitmapScreenNail)entry.screenNail;
          s.updatePlaceholderSize(item.getWidth(),item.getHeight());
        }
      }
    }
 else {
      entry=new ImageEntry();
      mImageCache.put(path,entry);
    }
  }
  for (  Path path : toBeRemoved) {
    ImageEntry entry=mImageCache.remove(path);
    if (entry.fullImageTask != null)     entry.fullImageTask.cancel();
    if (entry.screenNailTask != null)     entry.screenNailTask.cancel();
    if (entry.screenNail != null)     entry.screenNail.recycle();
  }
}

Fixed version (ground truth):
private void updateImageCache(){
  HashSet<Path> toBeRemoved=new HashSet<Path>(mImageCache.keySet());
  for (int i=mActiveStart; i < mActiveEnd; ++i) {
    MediaItem item=mData[i % DATA_CACHE_SIZE];
    if (item == null)     continue;
    Path path=item.getPath();
    ImageEntry entry=mImageCache.get(path);
    toBeRemoved.remove(path);
    if (entry != null) {
      if (Math.abs(i - mCurrentIndex) > 1) {
        if (entry.fullImageTask != null) {
          entry.fullImageTask.cancel();
          entry.fullImageTask=null;
        }
        entry.fullImage=null;
        entry.requestedFullImage=MediaObject.INVALID_DATA_VERSION;
      }
      if (entry.requestedScreenNail != item.getDataVersion()) {
        if (entry.screenNail instanceof TiledScreenNail) {
          TiledScreenNail s=(TiledScreenNail)entry.screenNail;
          s.updatePlaceholderSize(item.getWidth(),item.getHeight());
        }
      }
    }
 else {
      entry=new ImageEntry();
      mImageCache.put(path,entry);
    }
  }
  for (  Path path : toBeRemoved) {
    ImageEntry entry=mImageCache.remove(path);
    if (entry.fullImageTask != null)     entry.fullImageTask.cancel();
    if (entry.screenNailTask != null)     entry.screenNailTask.cancel();
    if (entry.screenNail != null)     entry.screenNail.recycle();
  }
  updateScreenNailUploadQueue();
}
Program: 38508
Project: 38508
Buggy source:
private void transitionFromAlbumPageIfNeeded(){
  TransitionStore transitions=mActivity.getTransitionStore();
  int albumPageTransition=transitions.get(KEY_ALBUMPAGE_TRANSITION,MSG_ALBUMPAGE_NONE);
  if (albumPageTransition == MSG_ALBUMPAGE_NONE && mAppBridge != null && mRecenterCameraOnResume) {
    mCurrentIndex=0;
    mPhotoView.resetToFirstPicture();
  }
 else {
    int resumeIndex=transitions.get(KEY_INDEX_HINT,-1);
    if (resumeIndex >= 0) {
      if (mInCameraRoll) {
        resumeIndex++;
      }
      if (resumeIndex < mMediaSet.getMediaItemCount()) {
        mCurrentIndex=resumeIndex;
        mModel.moveTo(mCurrentIndex);
      }
    }
  }
  if (albumPageTransition == MSG_ALBUMPAGE_RESUMED) {
    mPhotoView.setFilmMode(mStartInFilmstrip || mAppBridge != null);
  }
 else   if (albumPageTransition == MSG_ALBUMPAGE_PICKED) {
    mPhotoView.setFilmMode(false);
  }
  mFadeOutTexture=transitions.get(PreparePageFadeoutTexture.KEY_FADE_TEXTURE);
  if (mFadeOutTexture != null) {
    mBackgroundFade.start();
    BitmapScreenNail.disableDrawPlaceholder();
    mOpenAnimationRect=albumPageTransition == MSG_ALBUMPAGE_NONE ? (Rect)mData.getParcelable(KEY_OPEN_ANIMATION_RECT) : (Rect)transitions.get(KEY_OPEN_ANIMATION_RECT);
    mPhotoView.setOpenAnimationRect(mOpenAnimationRect);
    mBackgroundFade.start();
  }
}

Fixed version (ground truth):
private void transitionFromAlbumPageIfNeeded(){
  TransitionStore transitions=mActivity.getTransitionStore();
  int albumPageTransition=transitions.get(KEY_ALBUMPAGE_TRANSITION,MSG_ALBUMPAGE_NONE);
  if (albumPageTransition == MSG_ALBUMPAGE_NONE && mAppBridge != null && mRecenterCameraOnResume) {
    mCurrentIndex=0;
    mPhotoView.resetToFirstPicture();
  }
 else {
    int resumeIndex=transitions.get(KEY_INDEX_HINT,-1);
    if (resumeIndex >= 0) {
      if (mInCameraRoll) {
        resumeIndex++;
      }
      if (resumeIndex < mMediaSet.getMediaItemCount()) {
        mCurrentIndex=resumeIndex;
        mModel.moveTo(mCurrentIndex);
      }
    }
  }
  if (albumPageTransition == MSG_ALBUMPAGE_RESUMED) {
    mPhotoView.setFilmMode(mStartInFilmstrip || mAppBridge != null);
  }
 else   if (albumPageTransition == MSG_ALBUMPAGE_PICKED) {
    mPhotoView.setFilmMode(false);
  }
  mFadeOutTexture=transitions.get(PreparePageFadeoutTexture.KEY_FADE_TEXTURE);
  if (mFadeOutTexture != null) {
    mBackgroundFade.start();
    TiledScreenNail.disableDrawPlaceholder();
    mOpenAnimationRect=albumPageTransition == MSG_ALBUMPAGE_NONE ? (Rect)mData.getParcelable(KEY_OPEN_ANIMATION_RECT) : (Rect)transitions.get(KEY_OPEN_ANIMATION_RECT);
    mPhotoView.setOpenAnimationRect(mOpenAnimationRect);
    mBackgroundFade.start();
  }
}
Program: 38509
Project: 38509
Buggy source:
@Override protected void renderBackground(GLCanvas view){
  if (mFadeOutTexture != null) {
    if (mBackgroundFade.calculate(AnimationTime.get()))     invalidate();
    if (!mBackgroundFade.isActive()) {
      mFadeOutTexture=null;
      mOpenAnimationRect=null;
      BitmapScreenNail.enableDrawPlaceholder();
    }
 else {
      float fadeAlpha=mBackgroundFade.get();
      if (fadeAlpha < 1f) {
        view.clearBuffer(getBackgroundColor());
        view.setAlpha(fadeAlpha);
      }
      mFadeOutTexture.draw(view,0,0);
      view.setAlpha(1f - fadeAlpha);
      return;
    }
  }
  view.clearBuffer(getBackgroundColor());
}

Fixed version (ground truth):
@Override protected void renderBackground(GLCanvas view){
  if (mFadeOutTexture != null) {
    if (mBackgroundFade.calculate(AnimationTime.get()))     invalidate();
    if (!mBackgroundFade.isActive()) {
      mFadeOutTexture=null;
      mOpenAnimationRect=null;
      TiledScreenNail.enableDrawPlaceholder();
    }
 else {
      float fadeAlpha=mBackgroundFade.get();
      if (fadeAlpha < 1f) {
        view.clearBuffer(getBackgroundColor());
        view.setAlpha(fadeAlpha);
      }
      mFadeOutTexture.draw(view,0,0);
      view.setAlpha(1f - fadeAlpha);
      return;
    }
  }
  view.clearBuffer(getBackgroundColor());
}
Program: 38510
Project: 38510
Buggy source:
@Override public void pause(){
  Future<?> task=mTask;
  task.cancel();
  task.waitDone();
  if (task.get() == null) {
    mTask=null;
  }
}

Fixed version (ground truth):
@Override public void pause(){
  Future<?> task=mTask;
  task.cancel();
  task.waitDone();
  if (task.get() == null) {
    mTask=null;
  }
  if (mBitmapScreenNail != null) {
    mBitmapScreenNail.recycle();
    mBitmapScreenNail=null;
  }
}
Program: 38511
Project: 38511
Buggy source:
public int getSupportedOperations(boolean getAll){
  return 0;
}

Fixed version (ground truth):
public int getSupportedOperations(boolean getAll){
  return getSupportedOperations();
}
Program: 38512
Project: 38512
Buggy source:
public int getSupportedOperations(boolean getAll){
  return 0;
}

Fixed version (ground truth):
public int getSupportedOperations(boolean getAll){
  return getSupportedOperations();
}
Program: 38513
Project: 38513
Buggy source:
public int getSupportedOperations(boolean getAll){
  return 0;
}

Fixed version (ground truth):
public int getSupportedOperations(boolean getAll){
  return getSupportedOperations();
}
Program: 38514
Project: 38514
Buggy source:
private void onBitmapRegionDecoderAvailable(BitmapRegionDecoder regionDecoder){
  if (regionDecoder == null) {
    Toast.makeText(this,R.string.fail_to_load_image,Toast.LENGTH_SHORT).show();
    finish();
    return;
  }
  mRegionDecoder=regionDecoder;
  mUseRegionDecoder=true;
  mState=STATE_LOADED;
  BitmapFactory.Options options=new BitmapFactory.Options();
  int width=regionDecoder.getWidth();
  int height=regionDecoder.getHeight();
  options.inSampleSize=BitmapUtils.computeSampleSize(width,height,BitmapUtils.UNCONSTRAINED,BACKUP_PIXEL_COUNT);
  mBitmap=regionDecoder.decodeRegion(new Rect(0,0,width,height),options);
  mCropView.setDataModel(new TileImageViewAdapter(mBitmap,regionDecoder),mMediaItem.getFullImageRotation());
  if (mDoFaceDetection) {
    mCropView.detectFaces(mBitmap);
  }
 else {
    mCropView.initializeHighlightRectangle();
  }
}

Fixed version (ground truth):
private void onBitmapRegionDecoderAvailable(BitmapRegionDecoder regionDecoder){
  if (regionDecoder == null) {
    Toast.makeText(this,R.string.fail_to_load_image,Toast.LENGTH_SHORT).show();
    finish();
    return;
  }
  mRegionDecoder=regionDecoder;
  mUseRegionDecoder=true;
  mState=STATE_LOADED;
  BitmapFactory.Options options=new BitmapFactory.Options();
  int width=regionDecoder.getWidth();
  int height=regionDecoder.getHeight();
  options.inSampleSize=BitmapUtils.computeSampleSize(width,height,BitmapUtils.UNCONSTRAINED,BACKUP_PIXEL_COUNT);
  mBitmap=regionDecoder.decodeRegion(new Rect(0,0,width,height),options);
  mBitmapScreenNail=new BitmapScreenNail(mBitmap);
  TileImageViewAdapter adapter=new TileImageViewAdapter();
  adapter.setScreenNail(mBitmapScreenNail,width,height);
  adapter.setRegionDecoder(regionDecoder);
  mCropView.setDataModel(adapter,mMediaItem.getFullImageRotation());
  if (mDoFaceDetection) {
    mCropView.detectFaces(mBitmap);
  }
 else {
    mCropView.initializeHighlightRectangle();
  }
}
Program: 38515
Project: 38515
Buggy source:
private void uploadScreenNail(int offset){
  int index=mCurrentIndex + offset;
  if (index < mActiveStart || index >= mActiveEnd)   return;
  MediaItem item=getItem(index);
  if (item == null)   return;
  ImageEntry e=mImageCache.get(item.getPath());
  if (e == null)   return;
  ScreenNail s=e.screenNail;
  if (s instanceof BitmapScreenNail) {
    TiledTexture t=((BitmapScreenNail)s).getTexture();
    if (t != null && !t.isReady())     mUploader.addTexture(t);
  }
}

Fixed version (ground truth):
private void uploadScreenNail(int offset){
  int index=mCurrentIndex + offset;
  if (index < mActiveStart || index >= mActiveEnd)   return;
  MediaItem item=getItem(index);
  if (item == null)   return;
  ImageEntry e=mImageCache.get(item.getPath());
  if (e == null)   return;
  ScreenNail s=e.screenNail;
  if (s instanceof TiledScreenNail) {
    TiledTexture t=((TiledScreenNail)s).getTexture();
    if (t != null && !t.isReady())     mUploader.addTexture(t);
  }
}
Program: 38516
Project: 38516
Buggy source:
private void updateCurrentIndex(int index){
  if (mCurrentIndex == index)   return;
  mCurrentIndex=index;
  updateSlidingWindow();
  MediaItem item=mData[index % DATA_CACHE_SIZE];
  mItemPath=item == null ? null : item.getPath();
  updateImageCache();
  updateImageRequests();
  updateTileProvider();
  updateScreenNailUploadQueue();
  if (mDataListener != null) {
    mDataListener.onPhotoChanged(index,mItemPath);
  }
  fireDataChange();
}

Fixed version (ground truth):
private void updateCurrentIndex(int index){
  if (mCurrentIndex == index)   return;
  mCurrentIndex=index;
  updateSlidingWindow();
  MediaItem item=mData[index % DATA_CACHE_SIZE];
  mItemPath=item == null ? null : item.getPath();
  updateImageCache();
  updateImageRequests();
  updateTileProvider();
  if (mDataListener != null) {
    mDataListener.onPhotoChanged(index,mItemPath);
  }
  fireDataChange();
}
Program: 38517
Project: 38517
Buggy source:
private ScreenNail newPlaceholderScreenNail(MediaItem item){
  int width=item.getWidth();
  int height=item.getHeight();
  return new BitmapScreenNail(width,height);
}

Fixed version (ground truth):
private ScreenNail newPlaceholderScreenNail(MediaItem item){
  int width=item.getWidth();
  int height=item.getHeight();
  return new TiledScreenNail(width,height);
}
Program: 38518
Project: 38518
Buggy source:
private void updateScreenNail(Path path,Future<ScreenNail> future){
  ImageEntry entry=mImageCache.get(path);
  ScreenNail screenNail=future.get();
  if (entry == null || entry.screenNailTask != future) {
    if (screenNail != null)     screenNail.recycle();
    return;
  }
  entry.screenNailTask=null;
  if (entry.screenNail instanceof BitmapScreenNail) {
    BitmapScreenNail original=(BitmapScreenNail)entry.screenNail;
    screenNail=original.combine(screenNail);
  }
  if (screenNail == null) {
    entry.failToLoad=true;
  }
 else {
    entry.failToLoad=false;
    entry.screenNail=screenNail;
  }
  for (int i=-SCREEN_NAIL_MAX; i <= SCREEN_NAIL_MAX; ++i) {
    if (path == getPath(mCurrentIndex + i)) {
      if (i == 0)       updateTileProvider(entry);
      mPhotoView.notifyImageChange(i);
      break;
    }
  }
  updateImageRequests();
  updateScreenNailUploadQueue();
}

Fixed version (ground truth):
private void updateScreenNail(Path path,Future<ScreenNail> future){
  ImageEntry entry=mImageCache.get(path);
  ScreenNail screenNail=future.get();
  if (entry == null || entry.screenNailTask != future) {
    if (screenNail != null)     screenNail.recycle();
    return;
  }
  entry.screenNailTask=null;
  if (entry.screenNail instanceof TiledScreenNail) {
    TiledScreenNail original=(TiledScreenNail)entry.screenNail;
    screenNail=original.combine(screenNail);
  }
  if (screenNail == null) {
    entry.failToLoad=true;
  }
 else {
    entry.failToLoad=false;
    entry.screenNail=screenNail;
  }
  for (int i=-SCREEN_NAIL_MAX; i <= SCREEN_NAIL_MAX; ++i) {
    if (path == getPath(mCurrentIndex + i)) {
      if (i == 0)       updateTileProvider(entry);
      mPhotoView.notifyImageChange(i);
      break;
    }
  }
  updateImageRequests();
  updateScreenNailUploadQueue();
}