Android: Compressing images creates black borders on left and top margin

自作多情 提交于 2019-12-06 15:44:53
Mina Samy

I believe the problem comes from this line:

canvas.drawBitmap(bmp, middleX - bmp.getWidth() / 2, middleY - bmp.getHeight() / 2, new Paint(Paint.FILTER_BITMAP_FLAG));

You're losing the precision by dividing by the integer 2.

try something like this:

 canvas.drawBitmap(bmp, middleX - (float)bmp.getWidth() / 2.0f, middleY - (float)bmp.getHeight() / 2.0f, new Paint(Paint.FILTER_BITMAP_FLAG));
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!