zoukankan      html  css  js  c++  java
  • 版画效果函数

    public static Bitmap changeToBlock(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 iPixel = 0;
    int i, j, color, pos;
    for (j = 0; j < height; j++) {
    for (i = 0; i < width; i++) {
    pos = j * width + i;
    color = dst[pos];
    int avg = (Color.red(color) + Color.green(color) + Color.blue(color)) / 3;
    if (avg >= 100)
    iPixel = 255;
    else
    iPixel = 0;

    dst[pos] = Color.rgb(iPixel, iPixel, iPixel);
    }
    }

    Bitmap bmpReturn = Bitmap.createBitmap(width, height,
    Bitmap.Config.RGB_565);
    bmpReturn.setPixels(dst, 0, width, 0, 0, width, height);
    return bmpReturn;
    }

  • 相关阅读:
    php算法之选择排序
    php算法之插入排序
    五分钟读懂UML类图
    ZC_知识点
    JNI_C#
    JNI_Z
    20160419__第1课_第6课
    Hibernate异常_01
    ZC_注意点
    ZC_知识点
  • 原文地址:https://www.cnblogs.com/clarence/p/3837412.html
Copyright © 2011-2022 走看看