jp.co.cyberagent.android.gpuimage.GPUImage Java Examples

The following examples show how to use jp.co.cyberagent.android.gpuimage.GPUImage. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GPUFilterUtils.java    From DevUtils with Apache License 2.0 5 votes vote down vote up
/**
 * 获取滤镜后的 Bitmap
 * @param gpuImage       {@link GPUImage}
 * @param gpuImageFilter {@link GPUImageFilter}
 * @return 滤镜后的 Bitmap
 */
public static Bitmap getFilterBitmap(GPUImage gpuImage, GPUImageFilter gpuImageFilter) {
    if (gpuImage != null && gpuImageFilter != null) {
        gpuImage.setFilter(gpuImageFilter);
        return gpuImage.getBitmapWithFilterApplied();
    }
    return null;
}
 
Example #2
Source File: GPUFilterUtils.java    From DevUtils with Apache License 2.0 5 votes vote down vote up
/**
 * 获取滤镜后的 Bitmap
 * @param bitmap         {@link Bitmap}
 * @param gpuImageFilter {@link GPUImageFilter}
 * @return 滤镜后的 Bitmap
 */
public static Bitmap getFilterBitmap(Bitmap bitmap, GPUImageFilter gpuImageFilter) {
    if (bitmap != null && gpuImageFilter != null) {
        GPUImage gpuImage = new GPUImage(DevUtils.getContext());
        gpuImage.setImage(bitmap);
        gpuImage.setFilter(gpuImageFilter);
        return gpuImage.getBitmapWithFilterApplied();
    }
    return null;
}
 
Example #3
Source File: GPUFilterUtils.java    From DevUtils with Apache License 2.0 5 votes vote down vote up
/**
 * 获取滤镜后的 Bitmap
 * @param gpuImage       {@link GPUImage}
 * @param bitmap         {@link Bitmap}
 * @param gpuImageFilter {@link GPUImageFilter}
 * @return 滤镜后的 Bitmap
 */
public static Bitmap getFilterBitmap(GPUImage gpuImage, Bitmap bitmap, GPUImageFilter gpuImageFilter) {
    if (gpuImage != null && bitmap != null && gpuImageFilter != null) {
        gpuImage.setImage(bitmap);
        gpuImage.setFilter(gpuImageFilter);
        return gpuImage.getBitmapWithFilterApplied();
    }
    return null;
}
 
Example #4
Source File: GPUFilterPostprocessor.java    From FrescoUtils with Apache License 2.0 5 votes vote down vote up
@Override public void process(Bitmap dest, Bitmap source) {
  GPUImage gpuImage = new GPUImage(context);
  gpuImage.setImage(source);
  gpuImage.setFilter(filter);
  Bitmap bitmap = gpuImage.getBitmapWithFilterApplied();

  super.process(dest, bitmap);
}
 
Example #5
Source File: GPUFilterTransformation.java    From glide-transformations with Apache License 2.0 5 votes vote down vote up
@Override
protected Bitmap transform(@NonNull Context context, @NonNull BitmapPool pool,
                           @NonNull Bitmap toTransform, int outWidth, int outHeight) {
  GPUImage gpuImage = new GPUImage(context);
  gpuImage.setImage(toTransform);
  gpuImage.setFilter(gpuImageFilter);

  return gpuImage.getBitmapWithFilterApplied();
}
 
Example #6
Source File: GPUFilterPostprocessor.java    From fresco-processors with Apache License 2.0 5 votes vote down vote up
@Override public void process(Bitmap dest, Bitmap source) {
  GPUImage gpuImage = new GPUImage(context);
  gpuImage.setImage(source);
  gpuImage.setFilter(filter);
  Bitmap bitmap = gpuImage.getBitmapWithFilterApplied();

  super.process(dest, bitmap);
}
 
Example #7
Source File: GPUFilterTransformation.java    From picasso-transformations with Apache License 2.0 5 votes vote down vote up
@Override public Bitmap transform(Bitmap source) {
  GPUImage gpuImage = new GPUImage(mContext);
  gpuImage.setImage(source);
  gpuImage.setFilter(mFilter);

  Bitmap bitmap = gpuImage.getBitmapWithFilterApplied();
  source.recycle();

  return bitmap;
}
 
Example #8
Source File: RealtimeCameraPreviewActivity.java    From android-opensource-library-56 with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    setContentView(R.layout.activity_realtime_camera_preview);

    mSurfaceView = (GLSurfaceView) findViewById(R.id.gl_surface_view);
    mGPUImage = new GPUImage(this);
    mGPUImage.setGLSurfaceView(mSurfaceView);

    mSeekBar = (SeekBar) findViewById(R.id.seekBar1);
    mSeekBar.setMax(100);
    mSeekBar.setEnabled(false);
    mSeekBar.setOnSeekBarChangeListener(this);

    // セピア
    mSepia = new GPUImageSepiaFilter();
    // 白黒
    mGray = new GPUImageGrayscaleFilter();
    // シャープ
    // -4.0 to 4.0
    mSharp = new GPUImageSharpenFilter();
    // エッジ
    // 0.0 to 5.0
    mEdge = new GPUImageSobelEdgeDetection();

    findViewById(R.id.sepia).setOnClickListener(this);
    findViewById(R.id.gray).setOnClickListener(this);
    findViewById(R.id.sharp).setOnClickListener(this);
    findViewById(R.id.edge).setOnClickListener(this);
}
 
Example #9
Source File: ImageView.java    From nativescript-image-cache-it with Apache License 2.0 4 votes vote down vote up
private void handleImageFilters(GPUImage gpuImage) {
    handleImageFilters(gpuImage, mFilter);
}
 
Example #10
Source File: GLRender.java    From CameraCompat with MIT License 4 votes vote down vote up
public void setScaleType(GPUImage.ScaleType scaleType) {
    mScaleType = scaleType;
}
 
Example #11
Source File: GLRender.java    From CameraCompat with MIT License 4 votes vote down vote up
private void adjustImageScaling() {
    float outputWidth = mOutputWidth;
    float outputHeight = mOutputHeight;
    if (mRotation == Rotation.ROTATION_270 || mRotation == Rotation.ROTATION_90) {
        outputWidth = mOutputHeight;
        outputHeight = mOutputWidth;
    }

    float ratio1 = outputWidth / mImageWidth;
    float ratio2 = outputHeight / mImageHeight;
    float ratioMax = Math.max(ratio1, ratio2);
    int imageWidthNew = Math.round(mImageWidth * ratioMax);
    int imageHeightNew = Math.round(mImageHeight * ratioMax);

    float ratioWidth = imageWidthNew / outputWidth;
    float ratioHeight = imageHeightNew / outputHeight;

    float[] cube = CUBE;
    float[] textureCords =
            TextureRotationUtil.getRotation(mRotation, mFlipHorizontal, mFlipVertical);
    if (mScaleType == GPUImage.ScaleType.CENTER_CROP) {
        float distHorizontal = (1 - 1 / ratioWidth) / 2;
        float distVertical = (1 - 1 / ratioHeight) / 2;
        textureCords = new float[] {
                addDistance(textureCords[0], distHorizontal),
                addDistance(textureCords[1], distVertical),
                addDistance(textureCords[2], distHorizontal),
                addDistance(textureCords[3], distVertical),
                addDistance(textureCords[4], distHorizontal),
                addDistance(textureCords[5], distVertical),
                addDistance(textureCords[6], distHorizontal),
                addDistance(textureCords[7], distVertical),
        };
    } else {
        cube = new float[] {
                CUBE[0] / ratioHeight, CUBE[1] / ratioWidth, CUBE[2] / ratioHeight,
                CUBE[3] / ratioWidth, CUBE[4] / ratioHeight, CUBE[5] / ratioWidth,
                CUBE[6] / ratioHeight, CUBE[7] / ratioWidth,
        };
    }

    mGLCubeBuffer.clear();
    mGLCubeBuffer.put(cube).position(0);
    mGLTextureBuffer.clear();
    mGLTextureBuffer.put(textureCords).position(0);
}