示例#1
0
  @Override
  protected void onDestroy() {

    super.onDestroy();

    if (mBitmap != null) {

      mBitmap.recycle();
    }
  }
示例#2
0
  @TargetApi(Build.VERSION_CODES.DONUT)
  @Override
  public void onCreate(Bundle icicle) {

    super.onCreate(icicle);
    mContentResolver = getContentResolver();

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.cropimage);

    mImageView = (CropImageView) findViewById(R.id.image);

    showStorageToast(this);

    Intent intent = getIntent();
    Bundle extras = intent.getExtras();
    if (extras != null) {

      if (extras.getString(CIRCLE_CROP) != null) {

        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.DONUT) {
          // mImageView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
        }

        mCircleCrop = true;
        mAspectX = 1;
        mAspectY = 1;
      }

      mImagePath = extras.getString(IMAGE_PATH);

      mSaveUri = getImageUri(mImagePath);
      mBitmap = getBitmap(mImagePath);

      if (extras.containsKey(ASPECT_X) && extras.get(ASPECT_X) instanceof Integer) {

        mAspectX = extras.getInt(ASPECT_X);
      } else {

        throw new IllegalArgumentException("aspect_x must be integer");
      }
      if (extras.containsKey(ASPECT_Y) && extras.get(ASPECT_Y) instanceof Integer) {

        mAspectY = extras.getInt(ASPECT_Y);
      } else {

        throw new IllegalArgumentException("aspect_y must be integer");
      }
      mOutputX = extras.getInt(OUTPUT_X);
      mOutputY = extras.getInt(OUTPUT_Y);
      mScale = extras.getBoolean(SCALE, true);
      mScaleUp = extras.getBoolean(SCALE_UP_IF_NEEDED, true);
    }

    if (mBitmap == null) {

      Log.d(TAG, "finish!!!");
      finish();
      return;
    }

    // Make UI fullscreen.
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

    findViewById(R.id.discard)
        .setOnClickListener(
            new View.OnClickListener() {
              public void onClick(View v) {

                setResult(RESULT_CANCELED);
                finish();
              }
            });

    findViewById(R.id.save)
        .setOnClickListener(
            new View.OnClickListener() {
              public void onClick(View v) {

                try {
                  onSaveClicked();
                } catch (Exception e) {
                  finish();
                }
              }
            });
    findViewById(R.id.rotateLeft)
        .setOnClickListener(
            new View.OnClickListener() {
              public void onClick(View v) {

                mBitmap = Util.rotateImage(mBitmap, -90);
                RotateBitmap rotateBitmap = new RotateBitmap(mBitmap);
                mImageView.setImageRotateBitmapResetBase(rotateBitmap, true);
                mRunFaceDetection.run();
              }
            });

    findViewById(R.id.rotateRight)
        .setOnClickListener(
            new View.OnClickListener() {
              public void onClick(View v) {

                mBitmap = Util.rotateImage(mBitmap, 90);
                RotateBitmap rotateBitmap = new RotateBitmap(mBitmap);
                mImageView.setImageRotateBitmapResetBase(rotateBitmap, true);
                mRunFaceDetection.run();
              }
            });
    startFaceDetection();
  }
示例#3
0
  @Override
  protected void onPause() {

    super.onPause();
    BitmapManager.instance().cancelThreadDecoding(mDecodingThreads);
  }