コード例 #1
0
ファイル: GPUImage.java プロジェクト: qtstsq55/Perspective
 /**
  * This sets the scale type of GPUImage. This has to be run before setting the image. If image is
  * set and scale type changed, image needs to be reset.
  *
  * @param scaleType The new ScaleType
  */
 public void setScaleType(ScaleType scaleType) {
   mScaleType = scaleType;
   mRenderer.setScaleType(scaleType);
   mRenderer.deleteImage();
   mCurrentBitmap = null;
   requestRender();
 }
コード例 #2
0
ファイル: GPUImage.java プロジェクト: qtstsq55/Perspective
  /**
   * Gets the given bitmap with current filter applied as a Bitmap.
   *
   * @param bitmap the bitmap on which the current filter should be applied
   * @return the bitmap with filter applied
   */
  public Bitmap getBitmapWithFilterApplied(final Bitmap bitmap) {
    if (mGlSurfaceView != null) {
      mRenderer.deleteImage();
      mRenderer.runOnDraw(
          new Runnable() {

            @Override
            public void run() {
              synchronized (mFilter) {
                mFilter.destroy();
                mFilter.notify();
              }
            }
          });
      synchronized (mFilter) {
        requestRender();
        try {
          mFilter.wait();
        } catch (InterruptedException e) {
          e.printStackTrace();
        }
      }
    }

    GPUImageRenderer renderer = new GPUImageRenderer(mFilter);
    renderer.setRotation(
        Rotation.NORMAL, mRenderer.isFlippedHorizontally(), mRenderer.isFlippedVertically());
    renderer.setScaleType(mScaleType);
    PixelBuffer buffer = new PixelBuffer(bitmap.getWidth(), bitmap.getHeight());
    buffer.setRenderer(renderer);
    renderer.setImageBitmap(bitmap, false);
    Bitmap result = buffer.getBitmap();
    mFilter.destroy();
    renderer.deleteImage();
    buffer.destroy();

    mRenderer.setFilter(mFilter);
    if (mCurrentBitmap != null) {
      mRenderer.setImageBitmap(mCurrentBitmap, false);
    }
    requestRender();

    return result;
  }
コード例 #3
0
ファイル: GPUImage.java プロジェクト: qtstsq55/Perspective
 /** Deletes the current image. */
 public void deleteImage() {
   mRenderer.deleteImage();
   mCurrentBitmap = null;
   requestRender();
 }
コード例 #4
0
ファイル: GPUImage.java プロジェクト: qtstsq55/Perspective
 /**
  * Sets the image on which the filter should be applied.
  *
  * @param bitmap the new image
  */
 public void setImage(final Bitmap bitmap) {
   mCurrentBitmap = bitmap;
   mRenderer.setImageBitmap(bitmap, false);
   requestRender();
 }
コード例 #5
0
ファイル: GPUImage.java プロジェクト: qtstsq55/Perspective
 /**
  * Sets the filter which should be applied to the image which was (or will be) set by
  * setImage(...).
  *
  * @param filter the new filter
  */
 public void setFilter(final GPUImageFilter filter) {
   mFilter = filter;
   mRenderer.setFilter(mFilter);
   requestRender();
 }
コード例 #6
0
 private void setImage(final Bitmap bitmap, final boolean recycle) {
   mRenderer.setImageBitmap(bitmap, recycle);
   requestRender();
 }