WEB开发网
开发学院手机开发Android 开发 Android 画图学习总结类的简介 阅读

Android 画图学习总结类的简介

 2010-05-29 03:03:00 来源:WEB开发网   
核心提示:BitmapDrawable(Bitmap bitmap)BitmapDrawable(String filepath)BitmapDrawable(InputStream is)void draw(Canvas canvas)Draw in its bounds (set via setBounds) respect

BitmapDrawable(Bitmap bitmap)

BitmapDrawable(String filepath)

BitmapDrawable(InputStream is)

void draw(Canvas canvas)Draw in its bounds (set via setBounds) respecting optional effects such as alpha (set via setAlpha) and color filter (set via setColorFilter).

final Bitmap getBitmap()

final Paint getPaint()

Drawable是个抽象类,在BitmapDrawable中我们就看到位图的具体操作,在仔细看下BitmapDrawable的构造函数,我们就会发现与Resource中的openRawResource()接口是相对应的,就可以通过以下方法来获取位图:

Resources r = this.getContext().getResources();

Inputstream is = r.openRawResource(R.drawable.my_background_image);

BitmapDrawable bmpDraw = new BitmapDrawable(is);

Bitmap bmp = bmpDraw.getBitmap();

关于Drawable深入的学习与理解,请阅读Android画图学习总结(三)——Drawable

然后,看几个常用的辅助类

Paint

数据包package:android.graphics

Android SDK中的简介:The Paint class holds the style and color information about how to draw geometries, text and bitmaps. 主要就是定义:画刷的样式,画笔的大小/颜色等。

Typeface

数据包 package:android.graphics

Android SDK中的简介:The Typeface class specifies the typeface and intrinsic style of a font. 主要就是定义:字体。

最后,核心类显示资源

数据包package:android.graphics

主要类:Canvas

Android SDK中的简介:The Canvas class holds the “draw” calls. To draw something, you need 4 basic components: A Bitmap to hold the pixels, a Canvas to host the draw calls (writing into the bitmap), a drawing primitive (e.g. Rect, Path, text, Bitmap), and a paint (to describe the colors and styles for the drawing).

按照结构的功能,将主要接口分为以下3部分:

boolean clipXXXX()Region区域操作:

DIFFERENCE

INTERSECT

REPLACE

Tags:Android 画图 学习

编辑录入:coldstar [复制链接] [打 印]
赞助商链接