zoukankan      html  css  js  c++  java
  • ColorFilter类

     

    以前没用到过LightingColorFilter这个类 ,google了下
    @Override
     protected void onDraw(Canvas canvas) {
      
      int mul = 0xFFFFFF00; //remove BLUE component
      int add = 0x0000FF00; //set GREEN full
      LightingColorFilter lightingColorFilter = new LightingColorFilter(mul, add);
      
      Paint MyPaint_Normal = new Paint();
      Paint MyPaint_Lighting = new Paint();
      MyPaint_Lighting.setColorFilter(lightingColorFilter);
         
         Bitmap myBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
         canvas.drawBitmap(myBitmap, 400, 100, MyPaint_Normal);
         canvas.drawBitmap(myBitmap, 500, 100, MyPaint_Lighting);
         
     };
    因为是基于三基色配色方案来改的,
    而且
    0xFFFFFF00  0x表示16进制数,前两个ff表示的是透明度,00-ff,接下来两个ff表示红R,00-ff,后面两个ff表示绿G,00-ff,最后两个ff表示蓝B,00-ff,
    所以呢
    int mul = 0xFFFFFF00; //remove BLUE component           移除蓝色B部分,可以根据三基色配色图看
    int add = 0x0000FF00; //set GREEN full                  绿色的填满,差不多就这个意思了。。。
    具体的还可以去测试下
    
    
    float[] colorMatrix = { 
        1, 0, 0, 0, 0, //red
        0, 0, 0, 0, 0, //green
        0, 0, 0, 0, 0, //blue
        0, 0, 0, 1, 0 //alpha  
      };
      
      Paint MyPaint = new Paint();
      ColorFilter colorFilter = new ColorMatrixColorFilter(colorMatrix);
         MyPaint.setColorFilter(colorFilter);
         
         Bitmap myBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
         canvas.drawBitmap(myBitmap, 100, 100, MyPaint);
     };
    这个画出来的效果就是红色和黑色了,因为不透明,这个是color矩阵的用法
  • 相关阅读:
    第1年4月22日 IBInspectable巧妙用法 cornerRadius
    第1年4月15日
    第1年4月9日 Domain: com.apple.dt.MobileDeviceErrorDomain
    第1年4月7日 活体检测
    GPS 波段信号范围
    tomcat远程调试
    JdbcTemplate或hibernate动态建表
    jdk动态代理失效,事务自调用失效
    Tomcat 访问静态资源出现中文乱码解决办法(转)
    SQL Server 查看死锁进程(转)
  • 原文地址:https://www.cnblogs.com/krislight1105/p/3748350.html
Copyright © 2011-2022 走看看