GPUVideo-android icon indicating copy to clipboard operation
GPUVideo-android copied to clipboard

Center position WatermarkFilter

Open poPaTheGuru opened this issue 3 years ago • 1 comments

Using your library in a npm package, placing a fullscreen overlay over a video, all the actual positions are cutting my video (like if i set "LEFT_TOP" the right/bottom video is cut, if i set "RIGHT_BOTTOM" the left/top is cut and so on) and i guess it's a great idea to have a center position, that place the bitmap full width and full height.

poPaTheGuru avatar Mar 23 '21 07:03 poPaTheGuru

Hi @poPaTheGuru you can use what I have tested and it works for me.

public class GlBitmapOverlaySample extends GlOverlayFilter {

    private Bitmap bitmap;

    public GlBitmapOverlaySample(Bitmap bitmap) {
        this.bitmap = bitmap;
    }

    @Override
    protected void drawCanvas(Canvas canvas) {
        if (bitmap != null && !bitmap.isRecycled()) {
            Matrix matrix = new Matrix();

            float scaleWidth = (float) canvas.getWidth() / (float) bitmap.getWidth();
            float scalHeight = (float) canvas.getHeight() / (float) bitmap.getHeight();

            matrix.postScale(scaleWidth, scalHeight, 0, 0);

            canvas.drawBitmap(bitmap, matrix, null);
        }
    }

}

dondell avatar Oct 28 '21 11:10 dondell