当前位置: 首页>>代码示例>>Java>>正文


Java ColorMatrix.postConcat方法代码示例

本文整理汇总了Java中android.graphics.ColorMatrix.postConcat方法的典型用法代码示例。如果您正苦于以下问题:Java ColorMatrix.postConcat方法的具体用法?Java ColorMatrix.postConcat怎么用?Java ColorMatrix.postConcat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.graphics.ColorMatrix的用法示例。


在下文中一共展示了ColorMatrix.postConcat方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: rotateColor

import android.graphics.ColorMatrix; //导入方法依赖的package包/类
private int rotateColor(int color, float rad) {
    float deg = rad * 180 / 3.1415927f;
    int r = Color.red(color);
    int g = Color.green(color);
    int b = Color.blue(color);

    ColorMatrix cm = new ColorMatrix();
    ColorMatrix tmp = new ColorMatrix();

    cm.setRGB2YUV();
    tmp.setRotate(0, deg);
    cm.postConcat(tmp);
    tmp.setYUV2RGB();
    cm.postConcat(tmp);

    final float[] a = cm.getArray();

    int ir = floatToByte(a[0] * r + a[1] * g + a[2] * b);
    int ig = floatToByte(a[5] * r + a[6] * g + a[7] * b);
    int ib = floatToByte(a[10] * r + a[11] * g + a[12] * b);

    return Color.argb(Color.alpha(color), pinToByte(ir),
            pinToByte(ig), pinToByte(ib));
}
 
开发者ID:Edward-Yung,项目名称:Mu-Retargeter-1.0,代码行数:25,代码来源:ColorPickerDialog.java

示例2: handleImageEffect

import android.graphics.ColorMatrix; //导入方法依赖的package包/类
public static Bitmap handleImageEffect(Bitmap bm, float lum) {
    Bitmap bmp = Bitmap.createBitmap(bm.getWidth(), bm.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bmp);
    Paint paint = new Paint();

    ColorMatrix lumMatrix = new ColorMatrix();
    lumMatrix.setScale(lum, lum, lum, 1);

    ColorMatrix imageMatrix = new ColorMatrix();
    imageMatrix.postConcat(lumMatrix);

    paint.setColorFilter(new ColorMatrixColorFilter(imageMatrix));
    canvas.drawBitmap(bm, 0, 0, paint);

    return bmp;
}
 
开发者ID:EggUncle,项目名称:XposedNavigationBar,代码行数:17,代码来源:ImageUtil.java

示例3: setBackground

import android.graphics.ColorMatrix; //导入方法依赖的package包/类
public static void setBackground(View v, Bitmap bm) {

        if (bm == null) {
            v.setBackgroundResource(0);
            return;
        }

        int vwidth = v.getWidth()/4;
        int vheight = v.getHeight()/4;
        int bwidth = bm.getWidth();
        int bheight = bm.getHeight();
        float scalex = (float) vwidth / bwidth;
        float scaley = (float) vheight / bheight;
        float scale = Math.max(scalex, scaley) * 1.3f;

        Bitmap.Config config = Bitmap.Config.ARGB_8888;
        Bitmap bg = Bitmap.createBitmap(vwidth, vheight, config);
        Canvas c = new Canvas(bg);
        Paint paint = new Paint();
        paint.setAntiAlias(true);
        paint.setFilterBitmap(true);
        ColorMatrix greymatrix = new ColorMatrix();
        greymatrix.setSaturation(0);
        ColorMatrix darkmatrix = new ColorMatrix();
        darkmatrix.setScale(1f, 1f, 1f, .1f);
        greymatrix.postConcat(darkmatrix);
        ColorFilter filter = new ColorMatrixColorFilter(greymatrix);
        paint.setColorFilter(filter);
        Matrix matrix = new Matrix();
        matrix.setTranslate(-bwidth/2, -bheight/2); // move bitmap center to origin
        matrix.postRotate(10);
        matrix.postScale(scale, scale);
        matrix.postTranslate(vwidth/2, vheight/2);  // Move bitmap center to view center
        c.drawBitmap(bm, matrix, paint);
        v.setBackgroundDrawable(new BitmapDrawable(bg));
    }
 
开发者ID:archos-sa,项目名称:aos-MediaLib,代码行数:37,代码来源:Utils.java

示例4: rotateColor

import android.graphics.ColorMatrix; //导入方法依赖的package包/类
private int rotateColor(int color, float rad) {
	float deg = rad * 180 / 3.1415927f;
	int r = Color.red(color);
	int g = Color.green(color);
	int b = Color.blue(color);

	ColorMatrix cm = new ColorMatrix();
	ColorMatrix tmp = new ColorMatrix();

	cm.setRGB2YUV();
	tmp.setRotate(0, deg);
	cm.postConcat(tmp);
	tmp.setYUV2RGB();
	cm.postConcat(tmp);

	final float[] a = cm.getArray();

	int ir = floatToByte(a[0] * r + a[1] * g + a[2] * b);
	int ig = floatToByte(a[5] * r + a[6] * g + a[7] * b);
	int ib = floatToByte(a[10] * r + a[11] * g + a[12] * b);

	return Color.argb(Color.alpha(color), pinToByte(ir), pinToByte(ig),
			pinToByte(ib));
}
 
开发者ID:iOffice1,项目名称:iOffice,代码行数:25,代码来源:ColorPickerView.java

示例5: handleImageEffect

import android.graphics.ColorMatrix; //导入方法依赖的package包/类
/**
 * 调整照片的色调,饱和度,亮度
 * MID_VALUE = 177; // 进度条的中间值
 * @param bm 原图
 * @param hue 色调 = (进度条进度 - MID_VALUE) * 1.0F / MIN_VALUE * 180
 * @param saturation 饱和度 = 进度条进度 * 1.0F / MIN_VALUE;
 * @param lum 亮度 = 进度条进度 * 1.0F / MIN_VALUE;
 * @return 调整后的图片
 */
public static Bitmap handleImageEffect(Bitmap bm, int hue, int saturation, int lum) {
    Bitmap bitmap = Bitmap.createBitmap(bm.getWidth(), bm.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);

    ColorMatrix hueMatrix = new ColorMatrix();
    hueMatrix.setRotate(0,hue);
    hueMatrix.setRotate(1,hue);
    hueMatrix.setRotate(2, hue);

    ColorMatrix saturationMatrix = new ColorMatrix();
    saturationMatrix.setSaturation(saturation);

    ColorMatrix lumMatrix = new ColorMatrix();
    lumMatrix.setScale(lum,lum,lum,1);

    ColorMatrix imageMatrix = new ColorMatrix();
    imageMatrix.postConcat(hueMatrix);
    imageMatrix.postConcat(saturationMatrix);
    imageMatrix.postConcat(lumMatrix);

    paint.setColorFilter(new ColorMatrixColorFilter(imageMatrix));
    canvas.drawBitmap(bm,0,0,paint);
    return bitmap;
}
 
开发者ID:lujianzhao,项目名称:AndroidBase,代码行数:35,代码来源:ImageUtils.java

示例6: rotateColor

import android.graphics.ColorMatrix; //导入方法依赖的package包/类
@SuppressWarnings("unused")
private int rotateColor(int color, float rad) {
          float deg = rad * 180 / 3.1415927f;
          int r = Color.red(color);
          int g = Color.green(color);
          int b = Color.blue(color);

          ColorMatrix cm = new ColorMatrix();
          ColorMatrix tmp = new ColorMatrix();

          cm.setRGB2YUV();
          tmp.setRotate(0, deg);
          cm.postConcat(tmp);
          tmp.setYUV2RGB();
          cm.postConcat(tmp);

          final float[] a = cm.getArray();

          int ir = floatToByte(a[0] * r +  a[1] * g +  a[2] * b);
          int ig = floatToByte(a[5] * r +  a[6] * g +  a[7] * b);
          int ib = floatToByte(a[10] * r + a[11] * g + a[12] * b);

          return Color.argb(alpha, pinToByte(ir),
                            pinToByte(ig), pinToByte(ib));
      }
 
开发者ID:FAIMS,项目名称:faims-android,代码行数:26,代码来源:ColorPickerDialog.java

示例7: handleImageEffect

import android.graphics.ColorMatrix; //导入方法依赖的package包/类
/**
 * 颜色效果
 */
public static Bitmap handleImageEffect(Bitmap bm, float hue, float saturation, float lum) {
  Bitmap bmp = Bitmap.createBitmap(bm.getWidth(), bm.getHeight(), Bitmap.Config.ARGB_8888);
  Canvas canvas = new Canvas(bmp);
  Paint paint = new Paint();

  //色调
  ColorMatrix hueMatrix = new ColorMatrix();
  hueMatrix.setRotate(0, hue); //Red
  hueMatrix.setRotate(1, hue); //Green
  hueMatrix.setRotate(2, hue); //Blue

  //饱和度
  ColorMatrix saturationMatrix = new ColorMatrix();
  saturationMatrix.setSaturation(saturation);

  //亮度
  ColorMatrix lumMatrix = new ColorMatrix();
  lumMatrix.setScale(lum, lum, lum, 1);

  ColorMatrix imageMatrix = new ColorMatrix();
  imageMatrix.postConcat(hueMatrix);
  imageMatrix.postConcat(saturationMatrix);
  imageMatrix.postConcat(lumMatrix);

  paint.setColorFilter(new ColorMatrixColorFilter(imageMatrix));
  canvas.drawBitmap(bm, 0, 0, paint);
  return bmp;
}
 
开发者ID:liuguoquan727,项目名称:android-study,代码行数:32,代码来源:ImageHelper.java

示例8: transform

import android.graphics.ColorMatrix; //导入方法依赖的package包/类
@Override
public Bitmap transform(final Bitmap source) {
    int width = source.getWidth();
    int height = source.getHeight();

    Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);

    ColorMatrix grayScaleMatrix = new ColorMatrix();
    grayScaleMatrix.setSaturation(0f);

    ColorMatrix tintMatrix = new ColorMatrix();
    tintMatrix.setScale(Color.red(color) / MAX_LUMINOSITY,
            Color.green(color) / MAX_LUMINOSITY,
            Color.blue(color) / MAX_LUMINOSITY,
            Color.alpha(color) / MAX_LUMINOSITY);

    grayScaleMatrix.postConcat(tintMatrix);
    ColorMatrixColorFilter filter = new ColorMatrixColorFilter(grayScaleMatrix);

    Paint paint = new Paint();
    paint.setColor(color);
    paint.setColorFilter(filter);

    Canvas canvas = new Canvas(bitmap);
    canvas.drawBitmap(source, 0, 0, paint);
    source.recycle();

    return bitmap;
}
 
开发者ID:timrijckaert,项目名称:NewsStandHeaderView,代码行数:30,代码来源:ColorTintingGrayScaleTransformation.java

示例9: setColor

import android.graphics.ColorMatrix; //导入方法依赖的package包/类
public void setColor(int color) {
    if (mPaint == null) {
        mPaint = new Paint(Paint.FILTER_BITMAP_FLAG);
    }
    if (color != 0) {
        ColorMatrix m1 = new ColorMatrix();
        m1.setSaturation(0);

        ColorMatrix m2 = new ColorMatrix();
        setColorScale(color, m2);
        m1.postConcat(m2);

        if (Utilities.ATLEAST_LOLLIPOP) {
            animateFilterTo(m1.getArray());
        } else {
            mPaint.setColorFilter(new ColorMatrixColorFilter(m1));
            invalidate();
        }
    } else {
        if (!Utilities.ATLEAST_LOLLIPOP || mCurrentFilter == null) {
            mPaint.setColorFilter(null);
            invalidate();
        } else {
            animateFilterTo(new ColorMatrix().getArray());
        }
    }
}
 
开发者ID:Mr-lin930819,项目名称:SimplOS,代码行数:28,代码来源:DragView.java

示例10: handleImageMatrix

import android.graphics.ColorMatrix; //导入方法依赖的package包/类
/**
 * 根据具体给定的bitmap,色调 饱和度及亮度生成新的bitmap
 *
 * @param tone 色调
 * @param saturation 饱和度
 * @param lum 亮度
 * @return new bitmap
 */
public static Bitmap handleImageMatrix(Bitmap bm, float tone, float saturation, float lum) {
    Bitmap bitmap = Bitmap.createBitmap(bm.getWidth(), bm.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint();

    // 色调
    ColorMatrix toneMatrix = new ColorMatrix();
    toneMatrix.setRotate(0, tone);
    toneMatrix.setRotate(1, tone);
    toneMatrix.setRotate(2, tone);

    // 饱和度
    ColorMatrix saturationMatrix = new ColorMatrix();
    saturationMatrix.setSaturation(saturation);

    // 亮度
    ColorMatrix lumMatrix = new ColorMatrix();
    lumMatrix.setScale(lum, lum, lum, 1);

    ColorMatrix imageMatrix = new ColorMatrix();
    imageMatrix.postConcat(toneMatrix);
    imageMatrix.postConcat(saturationMatrix);
    imageMatrix.postConcat(lumMatrix);

    paint.setColorFilter(new ColorMatrixColorFilter(imageMatrix));
    canvas.drawBitmap(bm, 0, 0, paint);
    return bitmap;
}
 
开发者ID:sunxu3074,项目名称:imooc-practice-android,代码行数:37,代码来源:ImageUtils.java


注:本文中的android.graphics.ColorMatrix.postConcat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。