public static void saveBitmapToJPG(Bitmap bitmap, File file) throws IOException {
Bitmap newBitmap = Bitmap.createBitmap(bitmap.getWidth(),
bitmap.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(newBitmap);
canvas.drawColor(Color.WHITE);
canvas.drawBitmap(bitmap, 0, 0, null);
OutputStream stream = new FileOutputStream(file);
newBitmap.compress(Bitmap.CompressFormat.JPEG, 80, stream);
stream.close();
}
bitmap图片转换成JPG图片
最新推荐文章于 2024-07-26 14:00:05 发布