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


Java ColorMatrix.setScale方法代码示例

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


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

示例1: lum

import android.graphics.ColorMatrix; //导入方法依赖的package包/类
/**
 * 亮度处理
 *
 * @param bitmap   原图
 * @param lumValue 新的亮度值
 * @return 改变了亮度值之后的图片
 */
public static Bitmap lum(Bitmap bitmap, int lumValue) {
    // 计算出符合要求的亮度值
    float newlumValue = lumValue * 1.0F / 127;
    // 创建一个颜色矩阵
    ColorMatrix lumColorMatrix = new ColorMatrix();
    // 设置亮度值
    lumColorMatrix.setScale(newlumValue, newlumValue, newlumValue, 1);
    // 创建一个画笔并设置其颜色过滤器
    Paint paint = new Paint();
    paint.setColorFilter(new ColorMatrixColorFilter(lumColorMatrix));
    // 创建一个新的图片并创建画布
    Bitmap newBitmap = Bitmap.createBitmap(bitmap.getWidth(),
            bitmap.getHeight(), Config.ARGB_8888);
    Canvas canvas = new Canvas(newBitmap);
    // 将原图使用给定的画笔画到画布上
    canvas.drawBitmap(bitmap, 0, 0, paint);
    return newBitmap;
}
 
开发者ID:youth5201314,项目名称:XFrame,代码行数:26,代码来源:XBitmapUtils.java

示例2: onCreate

import android.graphics.ColorMatrix; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_fold);

    mImageView = (ImageView)findViewById(R.id.image_view);
    mImageView.setPadding(ANTIALIAS_PADDING, ANTIALIAS_PADDING, ANTIALIAS_PADDING,
            ANTIALIAS_PADDING);
    mImageView.setScaleType(ImageView.ScaleType.FIT_XY);
    mImageView.setImageDrawable(getResources().getDrawable(R.drawable.image));

    mTextureView = new TextureView(this);
    mTextureView.setSurfaceTextureListener(mSurfaceTextureListener);

    mAnchorSeekBar = (SeekBar)findViewById(R.id.anchor_seek_bar);
    mFoldLayout = (FoldingLayout)findViewById(R.id.fold_view);
    mFoldLayout.setBackgroundColor(Color.BLACK);
    mFoldLayout.setFoldListener(mOnFoldListener);

    mTouchSlop = ViewConfiguration.get(this).getScaledTouchSlop();

    mAnchorSeekBar.setOnSeekBarChangeListener(mSeekBarChangeListener);

    mScrollGestureDetector = new GestureDetector(this, new ScrollGestureDetector());
    mItemSelectedListener = new ItemSelectedListener();

    mDefaultPaint = new Paint();
    mSepiaPaint = new Paint();

    ColorMatrix m1 = new ColorMatrix();
    ColorMatrix m2 = new ColorMatrix();
    m1.setSaturation(0);
    m2.setScale(1f, .95f, .82f, 1.0f);
    m1.setConcat(m2, m1);
    mSepiaPaint.setColorFilter(new ColorMatrixColorFilter(m1));
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:38,代码来源:FoldingLayoutActivity.java

示例3: 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

示例4: 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

示例5: lum

import android.graphics.ColorMatrix; //导入方法依赖的package包/类
/**
 * 亮度处理
 *
 * @param bitmap   原图
 * @param lumValue 新的亮度值
 * @return 改变了亮度值之后的图片
 */
public static Bitmap lum(Bitmap bitmap, int lumValue) {
    // 计算出符合要求的亮度值
    float newlumValue = lumValue * 1.0F / 127;
    // 创建一个颜色矩阵
    ColorMatrix lumColorMatrix = new ColorMatrix();
    // 设置亮度值
    lumColorMatrix.setScale(newlumValue, newlumValue, newlumValue, 1);
    // 创建一个画笔并设置其颜色过滤器
    Paint paint = new Paint();
    paint.setColorFilter(new ColorMatrixColorFilter(lumColorMatrix));
    // 创建一个新的图片并创建画布
    Bitmap newBitmap = Bitmap.createBitmap(bitmap.getWidth(),
            bitmap.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(newBitmap);
    // 将原图使用给定的画笔画到画布上
    canvas.drawBitmap(bitmap, 0, 0, paint);
    return newBitmap;
}
 
开发者ID:venshine,项目名称:AndroidCommon,代码行数:26,代码来源:BitmapUtils.java

示例6: lum

import android.graphics.ColorMatrix; //导入方法依赖的package包/类
/**
 * 亮度处理
 *
 * @param bitmap 原图
 * @param lumValue 新的亮度值
 * @return 改变了亮度值之后的图片
 */
public static Bitmap lum(Bitmap bitmap, int lumValue) {
    // 计算出符合要求的亮度值
    float newlumValue = lumValue * 1.0F / 127;
    // 创建一个颜色矩阵
    ColorMatrix lumColorMatrix = new ColorMatrix();
    // 设置亮度值
    lumColorMatrix.setScale(newlumValue, newlumValue, newlumValue, 1);
    // 创建一个画笔并设置其颜色过滤器
    Paint paint = new Paint();
    paint.setColorFilter(new ColorMatrixColorFilter(lumColorMatrix));
    // 创建一个新的图片并创建画布
    Bitmap newBitmap = Bitmap.createBitmap(bitmap.getWidth(),
            bitmap.getHeight(), Config.ARGB_8888);
    Canvas canvas = new Canvas(newBitmap);
    // 将原图使用给定的画笔画到画布上
    canvas.drawBitmap(bitmap, 0, 0, paint);
    return newBitmap;
}
 
开发者ID:drakeet,项目名称:Lunei,代码行数:26,代码来源:BitmapUtil.java

示例7: 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

示例8: lumAndHueAndSaturation

import android.graphics.ColorMatrix; //导入方法依赖的package包/类
/**
 * 亮度、色相、饱和度处理
 *
 * @param bitmap          原图
 * @param lumValue        亮度值
 * @param hueValue        色相值
 * @param saturationValue 饱和度值
 * @return 亮度、色相、饱和度处理后的图片
 */
public static Bitmap lumAndHueAndSaturation(Bitmap bitmap, int lumValue,
                                            int hueValue, int saturationValue) {
    // 计算出符合要求的饱和度值
    float newSaturationValue = saturationValue * 1.0F / 127;
    // 计算出符合要求的亮度值
    float newlumValue = lumValue * 1.0F / 127;
    // 计算出符合要求的色相值
    float newHueValue = (hueValue - 127) * 1.0F / 127 * 180;

    // 创建一个颜色矩阵并设置其饱和度
    ColorMatrix colorMatrix = new ColorMatrix();

    // 设置饱和度值
    colorMatrix.setSaturation(newSaturationValue);
    // 设置亮度值
    colorMatrix.setScale(newlumValue, newlumValue, newlumValue, 1);
    // 控制让红色区在色轮上旋转的角度
    colorMatrix.setRotate(0, newHueValue);
    // 控制让绿红色区在色轮上旋转的角度
    colorMatrix.setRotate(1, newHueValue);
    // 控制让蓝色区在色轮上旋转的角度
    colorMatrix.setRotate(2, newHueValue);

    // 创建一个画笔并设置其颜色过滤器
    Paint paint = new Paint();
    paint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));
    // 创建一个新的图片并创建画布
    Bitmap newBitmap = Bitmap.createBitmap(bitmap.getWidth(),
            bitmap.getHeight(), Config.ARGB_8888);
    Canvas canvas = new Canvas(newBitmap);
    // 将原图使用给定的画笔画到画布上
    canvas.drawBitmap(bitmap, 0, 0, paint);
    return newBitmap;
}
 
开发者ID:youth5201314,项目名称:XFrame,代码行数:44,代码来源:XBitmapUtils.java

示例9: 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

示例10: lumAndHueAndSaturation

import android.graphics.ColorMatrix; //导入方法依赖的package包/类
/**
 * 亮度、色相、饱和度处理
 *
 * @param bitmap          原图
 * @param lumValue        亮度值
 * @param hueValue        色相值
 * @param saturationValue 饱和度值
 * @return 亮度、色相、饱和度处理后的图片
 */
public static Bitmap lumAndHueAndSaturation(Bitmap bitmap, int lumValue,
                                            int hueValue, int saturationValue) {
    // 计算出符合要求的饱和度值
    float newSaturationValue = saturationValue * 1.0F / 127;
    // 计算出符合要求的亮度值
    float newlumValue = lumValue * 1.0F / 127;
    // 计算出符合要求的色相值
    float newHueValue = (hueValue - 127) * 1.0F / 127 * 180;

    // 创建一个颜色矩阵并设置其饱和度
    ColorMatrix colorMatrix = new ColorMatrix();

    // 设置饱和度值
    colorMatrix.setSaturation(newSaturationValue);
    // 设置亮度值
    colorMatrix.setScale(newlumValue, newlumValue, newlumValue, 1);
    // 控制让红色区在色轮上旋转的角度
    colorMatrix.setRotate(0, newHueValue);
    // 控制让绿红色区在色轮上旋转的角度
    colorMatrix.setRotate(1, newHueValue);
    // 控制让蓝色区在色轮上旋转的角度
    colorMatrix.setRotate(2, newHueValue);

    // 创建一个画笔并设置其颜色过滤器
    Paint paint = new Paint();
    paint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));
    // 创建一个新的图片并创建画布
    Bitmap newBitmap = Bitmap.createBitmap(bitmap.getWidth(),
            bitmap.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(newBitmap);
    // 将原图使用给定的画笔画到画布上
    canvas.drawBitmap(bitmap, 0, 0, paint);
    return newBitmap;
}
 
开发者ID:venshine,项目名称:AndroidCommon,代码行数:44,代码来源:BitmapUtils.java

示例11: lumAndHueAndSaturation

import android.graphics.ColorMatrix; //导入方法依赖的package包/类
/**
 * 亮度、色相、饱和度处理
 *
 * @param bitmap 原图
 * @param lumValue 亮度值
 * @param hueValue 色相值
 * @param saturationValue 饱和度值
 * @return 亮度、色相、饱和度处理后的图片
 */
public static Bitmap lumAndHueAndSaturation(Bitmap bitmap, int lumValue, int hueValue, int saturationValue) {
    // 计算出符合要求的饱和度值
    float newSaturationValue = saturationValue * 1.0F / 127;
    // 计算出符合要求的亮度值
    float newlumValue = lumValue * 1.0F / 127;
    // 计算出符合要求的色相值
    float newHueValue = (hueValue - 127) * 1.0F / 127 * 180;

    // 创建一个颜色矩阵并设置其饱和度
    ColorMatrix colorMatrix = new ColorMatrix();

    // 设置饱和度值
    colorMatrix.setSaturation(newSaturationValue);
    // 设置亮度值
    colorMatrix.setScale(newlumValue, newlumValue, newlumValue, 1);
    // 控制让红色区在色轮上旋转的角度
    colorMatrix.setRotate(0, newHueValue);
    // 控制让绿红色区在色轮上旋转的角度
    colorMatrix.setRotate(1, newHueValue);
    // 控制让蓝色区在色轮上旋转的角度
    colorMatrix.setRotate(2, newHueValue);

    // 创建一个画笔并设置其颜色过滤器
    Paint paint = new Paint();
    paint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));
    // 创建一个新的图片并创建画布
    Bitmap newBitmap = Bitmap.createBitmap(bitmap.getWidth(),
            bitmap.getHeight(), Config.ARGB_8888);
    Canvas canvas = new Canvas(newBitmap);
    // 将原图使用给定的画笔画到画布上
    canvas.drawBitmap(bitmap, 0, 0, paint);
    return newBitmap;
}
 
开发者ID:drakeet,项目名称:Lunei,代码行数:43,代码来源:BitmapUtil.java

示例12: 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

示例13: setBrightnessMatrix

import android.graphics.ColorMatrix; //导入方法依赖的package包/类
private static void setBrightnessMatrix(ColorMatrix matrix, int brightness) {
    // Brightness: C-new = C-old*(1-amount) + amount
    float scale = 1 - brightness / 255.0f;
    matrix.setScale(scale, scale, scale, 1);
    float[] array = matrix.getArray();

    // Add the amount to RGB components of the matrix, as per the above formula.
    // Fifth elements in the array correspond to the constant being added to
    // red, blue, green, and alpha channel respectively.
    array[4] = brightness;
    array[9] = brightness;
    array[14] = brightness;
}
 
开发者ID:Mr-lin930819,项目名称:SimplOS,代码行数:14,代码来源:FastBitmapDrawable.java

示例14: 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

示例15: setColorScale

import android.graphics.ColorMatrix; //导入方法依赖的package包/类
public static void setColorScale(int color, ColorMatrix target) {
    target.setScale(Color.red(color) / 255f, Color.green(color) / 255f,
            Color.blue(color) / 255f, Color.alpha(color) / 255f);
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:5,代码来源:DragView.java


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