示例#1
0
  private void preProcessPhotoRetryable(final Uri uri) throws Exception {

    if (_pic != null) {
      _pic.recycle();
    }

    _pic = ImageUtils.getBitmap(this, uri, MAX_PIC_SIZE_BYTES);

    if (_pic != null) {
      createThumb(_pic);
      ImageUtils.writeBitmapToFile(_pic, TEMP_PIC_PATH_ON_DISK);
      _picFile = new File(TEMP_PIC_PATH_ON_DISK);
      _photoSelectionHandler.sendEmptyMessage(EVENT_SEL_PHOTO_WRITTEN_TO_DISK);
    } else {
      throw new Exception("Failed to get photo");
    }
  }
示例#2
0
  private void createThumb(final Bitmap pic) {
    if (_thumb != null) {
      _thumb.recycle();
    }

    MLog.i(TAG, "PhotoChoosingActivity createThumb() before creating thumb..");

    _thumb =
        Bitmap.createScaledBitmap(pic, GmobApp.SCALED_THUMB_SIZE, GmobApp.SCALED_THUMB_SIZE, true);

    MLog.i(TAG, "PhotoChoosingActivity createThumb() created _thumb");

    try {
      ImageUtils.writeBitmapToFile(_thumb, TEMP_THUMB_PATH_ON_DISK);
    } catch (final Exception e) {
      MLog.i(TAG, "", e);
    }
  }
示例#3
0
  /** 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());
  }