zoukankan      html  css  js  c++  java
  • 反色效果函数

    // 反色效果函数
    public static Bitmap chageToInvert(Bitmap bitmap) {
    int width = bitmap.getWidth();
    int height = bitmap.getHeight();

    int colorArray[] = new int[width * height];
    int r, g, b, index;
    bitmap.getPixels(colorArray, 0, width, 0, 0, width, height);
    for (int y = 0; y < height; y++) {
    for (int x = 0; x < width; x++) {
    index = y * width + x;
    r = (colorArray[index] >> 16) & 0xff;
    g = (colorArray[index] >> 8) & 0xff;
    b = colorArray[index] & 0xff;
    colorArray[index] = 0xff000000 | (r << 16) | (g << 8) | b;

    r = (255-(int)(colorArray[index]& 0x00FF0000) >>> 16);
    g = (255-(int)(colorArray[index]& 0x0000FF00) >>> 8);
    b = (255-(int)(colorArray[index] & 0x000000FF));

    colorArray[index] = (255 << 24) + (r << 16) + (g << 8) + b;
    }
    }
    Bitmap returnBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
    returnBitmap.setPixels(colorArray, 0, width, 0, 0, width, height);

    return returnBitmap;
    }

  • 相关阅读:
    oracle DBA 常用表和视图
    oracle 索引聚簇表的工作原理
    二进制手表
    二分查找
    二分查找
    排列硬币
    将每个元素替换为右侧最大元素
    搜索插入位置----二分查找
    合并两个有序数组
    在Nuxt遇到的坑
  • 原文地址:https://www.cnblogs.com/clarence/p/3837430.html
Copyright © 2011-2022 走看看