/** call this within a thread */ private void createFinalPic() { MLog.i(TAG, "PhotoChoosingActivity createFinalPic() .."); final Bitmap picToBeRecycled = _pic; int newWidth = 0, newHeight = 0; int shorter, longer; if (GmobApp.DISPLAY_METRICS.widthPixels > GmobApp.DISPLAY_METRICS.heightPixels) { longer = GmobApp.DISPLAY_METRICS.widthPixels; shorter = GmobApp.DISPLAY_METRICS.heightPixels; } else { longer = GmobApp.DISPLAY_METRICS.heightPixels; shorter = GmobApp.DISPLAY_METRICS.widthPixels; } /* * If it's a portrait mode oriented photo, then don't allow the height * to be longer than the longest length of the phone * * If it's a landscape mode oriented photo, then don't allow the width * to be longer than the longest length of the phone * * Lastly, we can't keep the original dimensions of the photo, because * it's just too big for mobile viewing. */ if (_pic.getHeight() > _pic.getWidth()) { // it's a portrait mode // picture newWidth = shorter; newHeight = longer; } else { // it's a landscape mode picture newWidth = longer; newHeight = shorter; } /* * lastly, if the photo is actually smaller than the dimensions of the * phone, then just use those dimensions */ if (_pic.getWidth() < newWidth) { newWidth = _pic.getWidth(); } if (_pic.getHeight() < newHeight) { newHeight = _pic.getHeight(); } _pic = ImageUtils.scale(_pic, newWidth, newHeight); if (picToBeRecycled != null && !picToBeRecycled.isRecycled()) { picToBeRecycled.recycle(); } MLog.i( TAG, "PhotoChoosingActivity createFinalPicAndThumb() was successful, pic width=" + _pic.getWidth() + " pic Height=" + _pic.getHeight()); }