下载此文档

关于Android Bitmap知识的整理.doc


文档分类:IT计算机 | 页数:约2页 举报非法文档有奖
1/2
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/2 下载此文档
文档列表 文档介绍
Bitmap
Bitmap是android系统中图像处理的最重要类之一。用它可以显示图像文件的信息,进行图像的剪切、旋转、缩放等操作,并可以指定格式保存图像文件。


如何得到bitmap对象
从资源中获得bitmap对象,两个方法:
通过bitmapfactory,来完成
通过BitmapDrawable(inputStream i).getBitmap() 来完成
Bitmap createBitmap
显示bitmap图像
ImageView iv = (ImageView) findViewById();
(bitmap);
保存图像
public boolean saveBitmapToImage(String filename) {
Bitmap bitmap = null;
CompressFormat format = ;
int quality = 100;
OutputStream os = null;
try {
os = new FileOutputStream("/sdcard/" + filename);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
();
}
return press(format, quality, os);
}
图片缩放
// 图片源
Bitmap bm = (getResources()
.openRawResource());
// 获得图片的宽高
int width = ();
int height = ();
// 设置想要的大小
int newWidth = 320;
int newHeight = 480;
// 计算缩放比例
float scaleWidth = ((float) newWidth) / width;
float scaleHeight = ((float) newHeight) / height;
// 取得想要缩放的matrix参数
Matrix matrix = new Matrix();
(scaleWidth, scaleHeight);
// 得到新的图片
Bit

关于Android Bitmap知识的整理 来自淘豆网m.daumloan.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数2
  • 收藏数0 收藏
  • 顶次数0
  • 上传人wc69885
  • 文件大小0 KB
  • 时间2015-06-02