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;
    }

  • 相关阅读:
    让IE6 IE7 IE8 IE9 IE10 IE11支持Bootstrap的解决方法
    检测到有潜在危险的 Request.Form 值
    jQuery校验
    C#客户端的异步操作
    泛型(一)
    c#面试题汇总
    多线程(下)
    多线程(上)
    线程篇(二)
    线程篇(一)
  • 原文地址:https://www.cnblogs.com/clarence/p/3837430.html
Copyright © 2011-2022 走看看