/** * Full size bitmap. * * @param maxNumberOfPixels the max number of pixels * @param rotateAsNeeded the rotate as needed * @return the bitmap */ public Bitmap fullSizeBitmap(int maxNumberOfPixels, boolean rotateAsNeeded) { Logger.v(TAG, "fullSizeBitmap entry"); int minSideLength = getProperWindowSize(); String path = mUri.getPath(); ParcelFileDescriptor pfdInput = null; try { pfdInput = ParcelFileDescriptor.open(new File(path), ParcelFileDescriptor.MODE_READ_ONLY); } catch (FileNotFoundException e) { Logger.e(TAG, "got exception decoding bitmap "); e.printStackTrace(); } Bitmap bitmap = null; bitmap = makeBitmap(minSideLength, maxNumberOfPixels, null, null, pfdInput, null); if (bitmap != null && rotateAsNeeded) { Bitmap rotatedBitmap = rotate(bitmap, getDegreesRotated()); if (rotatedBitmap != null && rotatedBitmap != bitmap) { Logger.v(TAG, "fullSizeBitmap rotate"); bitmap.recycle(); bitmap = rotatedBitmap; } else { Logger.d(TAG, "fullSizeBitmap no need to roate"); } } Logger.v(TAG, "fullSizeBitmap exit"); return bitmap; }
@Override public void onCreate() { super.onCreate(); AndroidFactory.setApplicationContext(getApplicationContext()); Logger.initialize(getApplicationContext()); Logger.v(TAG, "onCreate() entry"); if (!ApiManager.initialize(getApplicationContext())) { Logger.e(TAG, "onCreate() ApiManager initialization failed!"); } ContactsListManager.initialize(getApplicationContext()); startService(new Intent(this, ApiService.class)); // Init UnreadMessageManager UnreadMessageManager.getInstance(); EmoticonsModelImpl.init(getApplicationContext()); controlRcseComponent(); Logger.v(TAG, "onCreate() exit"); }
/** * Make bitmap. * * @param minSideLength the min side length * @param maxNumOfPixels the max num of pixels * @param uri the uri * @param cr the cr * @param pfd the pfd * @param options the options * @return the bitmap */ private Bitmap makeBitmap( int minSideLength, int maxNumOfPixels, Uri uri, ContentResolver cr, ParcelFileDescriptor pfd, final BitmapFactory.Options options) { Logger.v(TAG, "makeBitmap entry"); if (pfd == null) { Logger.d(TAG, "makeBitmap pfd is null"); return null; } try { BitmapFactory.Options tempOptions = options; if (tempOptions == null) { tempOptions = new BitmapFactory.Options(); } FileDescriptor fd = pfd.getFileDescriptor(); tempOptions.inJustDecodeBounds = true; BitmapFactory.decodeFileDescriptor(fd, null, tempOptions); if (tempOptions.mCancel || tempOptions.outWidth == -1 || tempOptions.outHeight == -1) { return null; } tempOptions.inSampleSize = computeSampleSize(tempOptions, minSideLength, maxNumOfPixels); tempOptions.inJustDecodeBounds = false; // for zoom pan performance enhancement, // load full size bitmap in format RGB_565, with dither option // on tempOptions.inDither = false; tempOptions.inPreferredConfig = Bitmap.Config.ARGB_8888; // options.inDither = true; // options.inPreferredConfig = Bitmap.Config.RGB_565; Logger.v(TAG, "makeBitmap exit"); return BitmapFactory.decodeFileDescriptor(fd, null, tempOptions); } catch (OutOfMemoryError ex) { Logger.e(TAG, "got oom exception"); ex.printStackTrace(); return null; } finally { closeSilently(pfd); } }