Android---绘图机制---色彩矩阵分析

图像的色调,饱和度,亮度 这三个属性在图像处理中的使用非常的多.并且封装了API来快速调整这些参数.

ColorMatrix颜色矩阵 系统封装的一个类
主要方法:
色调

hueMatrix.setRotate(int axis,float degree)

第一个参数axis系统分别使用了0.1.2来代表Red.Green.Blue三种颜色的处理,第二个参数就是需要处理的值

饱和度
饱和度为0的时候就是灰色的图像

saturation.setSaturation(0);

亮度
三种颜色等比例混合的时候显示白色,当亮度为0的时候,图像变成了黑色的.

lumMatrix.setScale(r,g,b,a);

矩阵的乘法运算
提供了postConcat()来将矩阵的作用效果混合,从而叠加处理效果.

        ColorMatrix imageMatrix=new ColorMatrix();
        imageMatrix.postConcat(hueMatrix);
        imageMatrix.postConcat(saturation);
        imageMatrix.postConcat(lumMatrix);

Android颜色矩阵——ColorMatrix

模拟4*5的颜色矩阵,改变其中的值.达到想要的效果

4*5矩阵的布局文件

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"
    >
    <ImageView
        android:id="@+id/imageview"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="2" />

    <GridLayout
        android:id="@+id/group"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="3"
        android:columnCount="5"
        android:rowCount="4" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <Button
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:onClick="btnChange"
            android:text="@string/change" />

        <Button
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:onClick="btnReset"
            android:text="@string/reset" />
    </LinearLayout>

</LinearLayout>

未完待续……

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值