文件名称:Android-VieW-Canvas-bitmap
介绍说明--下载内容均来自于网络,请自行研究使用
BitMap、View以及Canvas是我们Ophone程序中常用到的类。本日以feisky的学习笔记呈现,通过实例讲解View&Canvas等等。
1. 从资源中获取位图
可以使用BitmapDrawable或者BitmapFactory来获取资源中的位图。
当然,首先需要获取资源:
Resources res=getResources()
使用BitmapDrawable获取位图
使用BitmapDrawable (InputStream is)构造一个BitmapDrawable;
使用BitmapDrawable类的getBitmap()获取得到位图;
// 读取InputStream并得到位图
InputStream is=res.openRawResource(R.drawable.pic180)
BitmapDrawable bmpDraw=new BitmapDrawable(is)
Bitmap bmp=bmpDraw.getBitmap()
或者采用下面的方式:
-BitMap, View and Canvas is we use class often Ophone program. This day to feisky study notes appear, through the examples explain View&Canvas and so on.
1. Get a bitmap from resources
Can use BitmapDrawable or BitmapFactory to obtain resources of the bitmap.
Of course, we first need to obtain resources:
Resources res = getResources ()
Use BitmapDrawable get a bitmap
Use BitmapDrawable (InputStream is constructing a BitmapDrawable
Use BitmapDrawable kind getBitmap () get get a bitmap
//read InputStream and get a bitmap
InputStream is = res. OpenRawResource (R.d rawable. Pic180)
BitmapDrawable bmpDraw = new BitmapDrawable (is)
Bitmap BMP = bmpDraw. GetBitmap ()
Or use the following ways:
1. 从资源中获取位图
可以使用BitmapDrawable或者BitmapFactory来获取资源中的位图。
当然,首先需要获取资源:
Resources res=getResources()
使用BitmapDrawable获取位图
使用BitmapDrawable (InputStream is)构造一个BitmapDrawable;
使用BitmapDrawable类的getBitmap()获取得到位图;
// 读取InputStream并得到位图
InputStream is=res.openRawResource(R.drawable.pic180)
BitmapDrawable bmpDraw=new BitmapDrawable(is)
Bitmap bmp=bmpDraw.getBitmap()
或者采用下面的方式:
-BitMap, View and Canvas is we use class often Ophone program. This day to feisky study notes appear, through the examples explain View&Canvas and so on.
1. Get a bitmap from resources
Can use BitmapDrawable or BitmapFactory to obtain resources of the bitmap.
Of course, we first need to obtain resources:
Resources res = getResources ()
Use BitmapDrawable get a bitmap
Use BitmapDrawable (InputStream is constructing a BitmapDrawable
Use BitmapDrawable kind getBitmap () get get a bitmap
//read InputStream and get a bitmap
InputStream is = res. OpenRawResource (R.d rawable. Pic180)
BitmapDrawable bmpDraw = new BitmapDrawable (is)
Bitmap BMP = bmpDraw. GetBitmap ()
Or use the following ways:
(系统自动生成,下载前可以参看下载内容)
下载文件列表
Android开发者学习笔记——View、Canvas、bitmap.doc