GPUVideo-android
GPUVideo-android copied to clipboard
Center position WatermarkFilter
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.
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);
}
}
}