android 位图存储sd卡,Android将创建的位图保存到SD卡上的目录

博主创建了位图,想将其保存到某个目录。文中给出了从文件输入流获取位图、调整位图大小的代码,最后表示想把调整后的位图_bitmapScaled保存到SD卡文件夹中,主要围绕Android位图存储到SD卡展开。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

我创建了一个位图,现在我想将该位图保存到某个目录中。谁能告诉我这是怎么做的。谢谢

FileInputStream in;

BufferedInputStream buf;

try {

in = new FileInputStream("/mnt/sdcard/dcim/Camera/2010-11-16_18-57-18_989.jpg");

buf = new BufferedInputStream(in);

Bitmap _bitmapPreScale = BitmapFactory.decodeStream(buf);

int oldWidth = _bitmapPreScale.getWidth();

int oldHeight = _bitmapPreScale.getHeight();

int newWidth = 2592;

int newHeight = 1936;

float scaleWidth = ((float) newWidth) / oldWidth;

float scaleHeight = ((float) newHeight) / oldHeight;

Matrix matrix = new Matrix();

// resize the bit map

matrix.postScale(scaleWidth, scaleHeight);

Bitmap _bitmapScaled = Bitmap.createBitmap(_bitmapPreScale, 0, 0,  oldWidth, oldHeight, matrix, true);

(我想将_bitmapScaled保存到SD卡上的文件夹中)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值