zoukankan      html  css  js  c++  java
  • 柔化效果

    //柔化效果
    public static Bitmap changeToSoftness(Bitmap bitmap){
    int width = bitmap.getWidth();
    int height = bitmap.getHeight();
    int dst[] = new int[width*height];
    bitmap.getPixels(dst, 0, width, 0, 0, width, height);

    int R, G, B, pixel;
    int pos, pixColor;
    for(int y=0; y<height; y++){
    for(int x=0; x<width; x++){
    pos = y*width + x;
    pixColor = dst[pos];
    R = Color.red(pixColor); //(color >> 16) & 0xFF
    G = Color.green(pixColor); //(color >> 8) & 0xFF;
    B = Color.blue(pixColor); //color & 0xFF
    pixel = 255 - (255-R)*(255-R)/255;
    if (pixel < 0)
    pixel = -pixel;
    pixel = pixel * R / 256;
    if (pixel > 255)
    pixel = 255;
    R = pixel;

    pixel = 255 - (255-G)*(255-G)/255;
    if (pixel < 0)
    pixel = -pixel;
    pixel = pixel * R / 256;
    if (pixel > 255)
    pixel = 255;
    G = pixel;

    pixel = 255 - (255-B)*(255-B)/255;
    if (pixel < 0)
    pixel = -pixel;
    pixel = pixel * G / 256;
    if (pixel > 255)
    pixel = 255;
    B = pixel;

    dst[pos] = Color.rgb(R, G, B);
    }
    }
    Bitmap processBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    processBitmap.setPixels(dst, 0, width, 0, 0, width, height);

    return processBitmap;
    }

  • 相关阅读:
    python 递归计算阶乘
    python引用
    python3 函数参数
    名片管理系统V0.0.2(函数实现)
    python 之socket语法及相关
    常见模块(一)
    常见模块(二)
    Python之迭代器、生成器、装饰器和递归
    python 之自定义函数
    python 之SET和collections
  • 原文地址:https://www.cnblogs.com/clarence/p/3837485.html
Copyright © 2011-2022 走看看