public Bitmap resizedBitmap(Bitmap bitmap, int screenW, int tv_count) {
int width = bitmap.getWidth();
int height = bitmap.getHeight();
int newWidth = screenW / tv_count;
int newHeight = 15;
// calculate the scale - in this case = 0.4f
float scaleWidth = ((float) newWidth) / width;
float scaleHeight = ((float) newHeight) / height;
Matrix matrix = new Matrix();
// resize the bit map
matrix.postScale(scaleWidth, scaleHeight);
Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height,
matrix, true);
return resizedBitmap;
}
时间: 2024-11-06 11:27:46