利用android Matrix来处理简单图片

82 阅读2分钟

精彩源码:

AChartEngine的简单使用:柱状图、饼状图、折线图

www.eoeandroid.com/thread-1882…

第三方集成之新浪微薄

www.eoeandroid.com/thread-1682…

第三方集成之人人客户端

www.eoeandroid.com/thread-1681…

Matrix是由一个3×3的矩阵组成的,因为涉及到数学中的矩阵概念先不做解释。Matrix已经给我们封装好了一些方法,这里先看看每个方法的效果。

  程序目录如下:

main.xml展示变换前后的图片:


<linearlayout xmlns:android="http://schemas.android.com/apk/res/android"

 

    android:orientation\="vertical"

    android:layout\_width\="fill\_parent"

    android:layout\_height\="fill\_parent"

 

    >

 <imageview

 

    android:layout\_width\="fill\_parent"

    android:layout\_height\="wrap\_content"

    android:src\="@drawable/picture1"

    />

 

  <textview  

    android:layout\_width="fill\_parent"

       android:layout\_height\="wrap\_content"

       android:text\="下图是改变后的效果" />

 

<imageview android:id="@+id/myimage"

 

    android:layout\_width\="fill\_parent"

    android:layout\_height\="wrap\_content"

    android:src\="@drawable/picture1"

 

    />

MainActivity负责利用Matrix处理图片,首先演示图片旋转效果,主要代码:


public void onCreate(Bundle savedInstanceState) {

 

    super.onCreate(savedInstanceState); 

    setContentView(R.layout.main);

 

    ImageView imageView;

 

    Matrix mMatrix \= new Matrix(); 

    imageView \= (ImageView) findViewById(R.id.myimage);

 

    Bitmap bmp \= ((BitmapDrawable) getResources().getDrawable(

 

            R.drawable.picture1)).getBitmap();

        mMatrix.setRotate(60);

 

    Bitmap bm \= Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(),bmp.getHeight(), mMatrix, true);

 

    imageView.setImageBitmap(bm);

 

}

### 最后

其实Android开发的知识点就那么多,面试问来问去还是那么点东西。所以面试没有其他的诀窍,只看你对这些知识点准备的充分程度。so,出去面试时先看看自己复习到了哪个阶段就好。

虽然 Android 没有前几年火热了,已经过去了会四大组件就能找到高薪职位的时代了。这只能说明 Android 中级以下的岗位饱和了,**现在高级工程师还是比较缺少的**,很多高级职位给的薪资真的特别高(钱多也不一定能找到合适的),所以努力让自己成为高级工程师才是最重要的。

> 这里附上上述的面试题相关的几十套字节跳动,京东,小米,腾讯、头条、阿里、美团等公司21年的面试题。把技术点整理成了视频和PDF(实际上比预期多花了不少精力),包含知识脉络 + 诸多细节。

由于篇幅有限,这里以图片的形式给大家展示一小部分。

![](https://p9-xtjj-sign.byteimg.com/tos-cn-i-73owjymdk6/93124674b2bc433180aa557c6e81304e~tplv-73owjymdk6-jj-mark-v1:0:0:0:0:5o6Y6YeR5oqA5pyv56S-5Yy6IEAg55So5oi3MzIxMjA3NDIwNDUy:q75.awebp?rk3s=f64ab15b&x-expires=1771742430&x-signature=lxuoB6e33819O87NHiZJk5rmGn4%3D)

详细整理在GitHub可以见;

**[Android架构视频+BAT面试专题PDF+学习笔记​](https://github.com/a120464/Android-P7/blob/master/Android%E5%BC%80%E5%8F%91%E4%B8%8D%E4%BC%9A%E8%BF%99%E4%BA%9B%EF%BC%9F%E5%A6%82%E4%BD%95%E9%9D%A2%E8%AF%95%E6%8B%BF%E9%AB%98%E8%96%AA%EF%BC%81.md)**

网上学习 Android的资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。希望这份系统化的技术体系对大家有一个方向参考。