public class MyView extends View{
Bitmap myBitmap;
Paint paint;
public MyView(Context context, AttributeSet attrs) {
super(context, attrs);
this.initBitmap();
}
public void initBitmap(){
paint = new Paint();
myBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.img); }
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
paint.setAntiAlias(true);
paint.setColor(Color.WHITE);
paint.setTextSize(15);
canvas.drawBitmap(myBitmap, 10, 10, paint); //Saves the current matrix and clip onto a private stack.
//Subsequent calls to translate,scale,rotate,skew,concat or clipRect,clipPath
//will all operate as usual, but when the balancing call to restore() is made,
//those calls will be forgotten, and the settings that existed before the save() will be reinstated(恢复).
//Returns:
//The value to pass to restoreToCount() to balance this save()
int i = canvas.save();
System.out.println("current count -- > " + i); Matrix m1 = new Matrix();
m1.setTranslate(500, 10);
Matrix m2 = new Matrix();
m2.setRotate(15);
Matrix m3 = new Matrix();
m3.setConcat(m1, m2);
m1.setScale(0.8f, 0.8f);
m2.setConcat(m3, m1);
canvas.drawBitmap(myBitmap, m2, paint); //This call balances a previous call to save(), and is used to
//remove all modifications to the matrix/clip state since the last save call.
//It is an error to call restore() more times than save() was called.
canvas.restore();
int j = canvas.save();
System.out.println("current count -- > " + j);
paint.setAlpha(180);
m1.setTranslate(200, 100);
m2.setScale(1.3f, 1.3f);
m2.setConcat(m1, m2);
canvas.drawBitmap(myBitmap, m3, paint); //Restores the paint to its default settings.
paint.reset();
canvas.restore();
paint.setTextSize(40);
paint.setColor(Color.BLUE);
canvas.drawText("图片的宽度:" + myBitmap.getWidth(), 150, 220, paint);
canvas.drawText("图片的高度:" + myBitmap.getHeight(), 150, 300, paint);
paint.reset(); } }

效果图:

 

图形与动画在Android中的实现的更多相关文章

  1. 在Android中显示GIF动画

    gif图动画在android中还是比较常用的,比如像新浪微博中,有很多gif图片,而且展示非常好,所以我也想弄一个.经过我多方的搜索资料和整理,终于弄出来了,其实github上有很多开源的gif的展示 ...

  2. 【转】[置顶] 在Android中显示GIF动画

    gif图动画在Android中还是比较常用的,比如像新浪微博中,有很多gif图片,而且展示非常好,所以我也想弄一个.经过我多方的搜索资料和整理,终于弄出来了,其实github上有很多开源的gif的展示 ...

  3. Android中的动画具体解释系列【2】——飞舞的蝴蝶

    这一篇来使用逐帧动画和补间动画来实现一个小样例,首先我们来看看Android中的补间动画. Android中使用Animation代表抽象的动画类,该类包含以下几个子类: AlphaAnimation ...

  4. Android中的动画详解系列【2】——飞舞的蝴蝶

    这一篇来使用逐帧动画和补间动画来实现一个小例子,首先我们来看看Android中的补间动画. Android中使用Animation代表抽象的动画类,该类包括下面几个子类: AlphaAnimation ...

  5. Android中矢量动画

    Android中矢量动画 Android中用<path> 标签来创建SVG,就好比控制着一支画笔,从一点到一点,动一条线. <path> 标签 支持一下属性 M = (Mx, ...

  6. 初识android中的动画

    动画效果可以大大提高界面的交互效果,因此,动画在移动开发中的应用场景较为普遍.掌握基本的动画效果在成熟的软件开发中不可或缺.除此之外,用户对于动画的接受程度远高于文字和图片,利用动画效果可以加深用户对 ...

  7. Android中的Drawable和动画

    Android中Drawable是一种可以在Canvas上进行绘制抽象的概念,种类很多,常见的颜色和图片都可以是一个Drawable.Drawable有很多种,它们表示一种图像的概念,但是它们又不全是 ...

  8. 【Android】第21章 2D图形和动画

    分类:C#.Android.VS2015: 创建日期:2016-03-19 一.简介 Android系统定义了一系列独立的图形处理类,其中,2D图形处理类分别位于以下命名空间: Android.Gra ...

  9. Android中自定义View和自定义动画

    Android FrameWork 层给我们提供了很多界面组件,但是在实际的商业开发中这些组件往往并不能完全满足我们的需求,这时候我们就需要自定义我们自己的视图和动画. 我们要重写系统的View就必须 ...

随机推荐

  1. word2vec 构建中文词向量

    词向量作为文本的基本结构——词的模型,以其优越的性能,受到自然语言处理领域研究人员的青睐.良好的词向量可以达到语义相近的词在词向量空间里聚集在一起,这对后续的文本分类,文本聚类等等操作提供了便利,本文 ...

  2. 了解Web的相关知识

    一.WWW基础 WWW(world wide web, 万维网)是Internet上基于客户端/服务器体系结构的分布式多平台的超文本超媒体信息服务系统.它利用超文本(hypertext).超媒体(hy ...

  3. Lesson 15 Secrecy in industry

    Why is secrecy particularly important in the chemical industries? Two factors weigh heavily against ...

  4. crm系统和e_store商场的比较总结

    e_store用了:Java.Servlet.JSP.Oracle.JQuery.Mybatis,tomcat技术 crm用了 :Java.JSP.Oracle.JQuery,Mybatis,spri ...

  5. Android开发之显示分辨率及单位

    Android 各种屏幕分辨率: VGA:         Video Graphics Array,即:显示绘图矩阵,相当于640×480 像素: HVGA:       Half-size VGA ...

  6. 【PAT甲级】1014 Waiting in Line (30 分)(队列维护)

    题面: 输入四个正整数N,M,K,Q(N<=20,M<=10,K,Q<=1000),N为银行窗口数量,M为黄线内最大人数,K为需要服务的人数,Q为查询次数.输入K个正整数,分别代表每 ...

  7. MySQL : INSERT INTO SELECT

    INSERT INTO wx_announcement_push ( title, content, STATUS, del_flag, user_login_name ) SELECT '大家好', ...

  8. Python中from scipy.misc import imread报错的原因?

    from scipy.misc import imread 报错 查询后其原因是from scipy.misc import imread,imwrite 等方法已经被弃用,Python已经将imre ...

  9. 事件驱动的TCP协议Socket通信

    事件驱动的TCP协议Socket通信 介绍 常规的Socket通信案例一般都是在某个线程中建立连接,然后用一个while(true)循环判断是或否有数据传输,但是这种方法有局限性. 1.收到消息在处理 ...

  10. Linux 运维常用命令

    参考: https://segmentfault.com/a/1190000009745139 http://blog.51cto.com/xuqq999/774714 .查看有多少个IP访问: aw ...