當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。