Esempio n. 1
0
  /**
   * Highlight cropped bitmap above overlay.
   *
   * @param croppedBitmap Cropped bitmap.
   */
  private void highlightCroppedBitmap(Bitmap croppedBitmap) {
    // - Hide cropper.
    mCropper.setVisibility(View.GONE);

    // - Update cropped image view's location.
    final RectF rect = mCropper.getActualCropRect();
    mCroppedImageView.setPadding((int) rect.left, (int) rect.top, 0, 0);
    ViewGroup.LayoutParams layoutParams = mCroppedImageView.getLayoutParams();
    layoutParams.width = (int) (croppedBitmap.getWidth() + rect.left);
    layoutParams.height = (int) (croppedBitmap.getHeight() + rect.top);
    mCroppedImageView.setLayoutParams(layoutParams);

    // - Display cropped bitmap.
    mCroppedImageView.setImageBitmap(croppedBitmap);
  }
Esempio n. 2
0
 /**
  * Fit croper to preview size.
  *
  * @param ratio Preview's ratio.
  */
 private void fitCropImageView(float ratio) {
   final Bitmap bitmap =
       Bitmap.createBitmap(
           mTextureView.getMeasuredWidth(),
           (int) (mTextureView.getMeasuredWidth() * ratio),
           Bitmap.Config.ARGB_8888);
   mCropper.setImageBitmap(bitmap);
 }
Esempio n. 3
0
 @Click(R.id.snapButton)
 protected void onSnapButtonClicked(final View view) {
   // - Analyze bitmap if internet is enabled.
   if (AndroidUtils.isDataEnabled(getActivity())) {
     mSnapButton.setEnabled(false);
     new AnalyzeAndSearchAsyncTask(
             getActivity(),
             mCropper.getActualCropRect(),
             webView,
             analyzeAndSearchAsyncTaskCallBack)
         .execute(mTextureView.getBitmap());
   } else {
     AndroidUtils.snackEnableData(getActivity(), getView());
   }
 }