当前位置:首页 » 安卓系统 » androidbitmapbmp

androidbitmapbmp

发布时间: 2025-07-10 22:55:09

❶ 请问在android 编程,Bitmap 怎么转换成 file

static boolean saveBitmap2file(Bitmap bmp,String filename){
CompressFormat format= Bitmap.CompressFormat.JPEG;
int quality = 100;
OutputStream stream = null;
try {
stream = new FileOutputStream("/sdcard/" + filename);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

return bmp.compress(format, quality, stream);
}

stream = new FileOutputStream("/sdcard/" + filename);
获取要保存到的文件的文件流
bmp.compress(format, quality, stream);
把指定的bitmp压缩到文件中 就是保存在指定文件中 format是文件格式(Bitmap.CompressFormat.JPEG jpeg) quality 是品质(100 就是原质量)
看名字 saveBitmap2file
你要上传的话 就去指定位置取这个file就行 路径的问题 可能有写真机找不到/sdcard/
建议 Environment类取地址 保存和读取时 都用Environment.getXXXX

❷ Android Bitmap 与 Drawable之间的区别和转换

Bitmap - 称作位图,一般位图的文件格式后缀为bmp,当然编码器也有很多如RGB565、RGB888。作为一种逐像素的显示对象执行效率高,但是缺点也很明显存储效率低。我们理解为一种存储对象比较好。

Drawable - 作为Android平下通用的图形对象,它可以装载常用格式的图像,比如GIF、PNG、JPG,当然也支持BMP,当然还提供一些高级的可视化对象,比如渐变、图形等。

A bitmap is a Drawable. A Drawable is not necessarily a bitmap. Like all thumbs are fingers but not all fingers are thumbs.
Bitmap是Drawable . Drawable不一定是Bitmap .就像拇指是指头,但不是所有的指头都是拇指一样.

The API dictates: API规定:

Though usually not visible to the application, Drawables may take a variety of forms: 尽管通常情况下对于应用是不可见的,Drawables 可以采取很多形式:

Bitmap: the simplest Drawable, a PNG or JPEG image. Bitmap: 简单化的Drawable, PNG 或JPEG图像.
Nine Patch: an extension to the PNG format allows it to specify
information about how to stretch it and place things inside of it.
Shape: contains simple drawing commands instead of a raw bitmap, allowing it to resize better in some cases.
Layers: a compound drawable, which draws multiple underlying drawables on top of each other.
States: a compound drawable that selects one of a set of drawables based on its state.
Levels: a compound drawable that selects one of a set of drawables based on its level.
Scale: a compound drawable with a single child drawable, whose overall size is modified based on the current level.

❸ android bitmap怎么转byte数组

java">ByteArrayOutputStreamstream=newByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG,100,stream);
byte[]byteArray=stream.toByteArray();

❹ android中Bitmap存为一张图片

可以用Bitmap.compress函数来把Bitmap对象保存成PNG或JPG文件,然后可以用BitmapFactory把文件中的数据读进来再生成Bitmap对象。
保存的代码大概类似于这样:
try {
FileOutputStream out = new FileOutputStream(filename);
bmp.compress(Bitmap.CompressFormat.PNG, 90, out);
} catch (Exception e) {
e.printStackTrace();
}
具体的可以去查Bitmap和BitmapFactory的帮助文档。

❺ android 加载大量图片速度慢是什么原因,是访问sd卡慢,还是使用bitmap的时候慢

android 加载大量图片速度慢原因一般是访问sd卡慢,SD卡读取速度较慢造成的加载文件速度慢。
加载,汉语词语,字面意思是增加装载量。现多用于计算机相关领域,表示启动程序时文件或信息的载入。
位图文件(Bitmap),扩展名可以是.bmp或者.dib。位图是Windows标准格式图形文件,它将图像定义为由点(像素)组成,每个点可以由多种色彩表示,包括2、4、8、16、24和32位色彩。例如,一幅1024×768分辨率的32位真彩图片,其所占存储字节数为:1024×768×32/8=3072KB
位图文件图像效果好,但是非压缩格式的,需要占用较大存储空间,不利于在网络上传送。jpg格式则恰好弥补了位图文件这个缺点。

热点内容
mysql属于什么数据库 发布:2025-07-12 13:55:52 浏览:166
源码抓捕 发布:2025-07-12 13:47:34 浏览:873
安卓哪里有李小龙 发布:2025-07-12 13:31:49 浏览:439
苹果保存账号密码在哪里找 发布:2025-07-12 13:31:07 浏览:99
东北大学c语言考试题 发布:2025-07-12 13:26:40 浏览:756
sha256在线加密 发布:2025-07-12 13:19:06 浏览:228
vbnet创建数据库连接 发布:2025-07-12 13:15:34 浏览:233
为什么社保卡在社康还要密码 发布:2025-07-12 13:11:42 浏览:812
取随机数php 发布:2025-07-12 12:58:16 浏览:841
如何配置组合音响 发布:2025-07-12 12:53:54 浏览:94