年龄和性别的view
年龄和性别的view应该是根据脸的大小进行缩放,而不是根据ImageView和图片的大小进行缩放吧?
int ageWidth = ageBitmap.getWidth();
int ageHeight = ageBitmap.getHeight();
Log.d("FacePlay", "ageWidth " + ageWidth + " ageHeight " + ageHeight);
if (bitmap.getWidth() < mPhoto.getWidth() && bitmap.getHeight() < mPhoto.getHeight() ) {
float ratio = Math.max(bitmap.getWidth() * 1.0f / mPhoto.getWidth() , bitmap.getHeight() * 1.0f / mPhoto.getHeight());
ageBitmap = Bitmap.createScaledBitmap(ageBitmap, (int)( ageWidth * ratio), (int) (ageHeight * ratio), false);
Log.d("FacePlay", "ageWidth " + ageBitmap.getWidth() + " ageHeight " + ageBitmap.getHeight());
}
canvas.drawBitmap(ageBitmap, x - ageBitmap.getWidth() / 2, y - h/2 - ageBitmap.getHeight(), null);
这样写得到的效果:
麻烦老师看看问题出在哪里?