當前位置: 首頁>>代碼示例>>Java>>正文


Java ColorMatrix.set方法代碼示例

本文整理匯總了Java中android.graphics.ColorMatrix.set方法的典型用法代碼示例。如果您正苦於以下問題:Java ColorMatrix.set方法的具體用法?Java ColorMatrix.set怎麽用?Java ColorMatrix.set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.graphics.ColorMatrix的用法示例。


在下文中一共展示了ColorMatrix.set方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: FriskyContrast

import android.graphics.ColorMatrix; //導入方法依賴的package包/類
public static Bitmap FriskyContrast(Bitmap bitmap,int Value)
{
    ColorMatrix colorMatrix = new ColorMatrix();
    colorMatrix.set(new float[] {
            Value, 0, 0, 0, 1,
            0, Value, 0, 0, 1,
            0, 0, Value, 0, 1,
            0, 0, 0, Value, 0   });

    Bitmap BrightedImage = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), bitmap
            .getConfig());
    Canvas canvas = new Canvas(BrightedImage);
    Paint paint = new Paint();
    paint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));
    canvas.drawBitmap(bitmap, 0, 0, paint);
    return BrightedImage;

}
 
開發者ID:Dwijraj,項目名稱:FriskyImage,代碼行數:19,代碼來源:FriskyImageProperty.java

示例2: FriskyBright

import android.graphics.ColorMatrix; //導入方法依賴的package包/類
public static   Bitmap FriskyBright(Bitmap mBitmap,int fb) {
    ColorMatrix colorMatrix = new ColorMatrix();
     colorMatrix.set(new float[] {
            1, 0, 0, 0, fb,
            0, 1, 0, 0, fb,
            0, 0, 1, 0, fb,
            0, 0, 0, 1, 0   });

    Bitmap BrightedImage = Bitmap.createBitmap(mBitmap.getWidth(), mBitmap.getHeight(), mBitmap
            .getConfig());
    Canvas canvas = new Canvas(BrightedImage);
    Paint paint = new Paint();
    paint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));
    canvas.drawBitmap(mBitmap, 0, 0, paint);
    return BrightedImage;

}
 
開發者ID:Dwijraj,項目名稱:FriskyImage,代碼行數:18,代碼來源:FriskyImageProperty.java

示例3: SimulationPageAnim

import android.graphics.ColorMatrix; //導入方法依賴的package包/類
public SimulationPageAnim(int w, int h, View view, OnPageChangeListener listener) {
    super(w, h, view, listener);
    mPath0 = new Path();
    mPath1 = new Path();
    mMaxLength = (float) Math.hypot(mScreenWidth, mScreenHeight);
    mPaint = new Paint();
    mPaint.setStyle(Paint.Style.FILL);

    createDrawable();

    ColorMatrix cm = new ColorMatrix();//設置顏色數組
    float array[] = { 1, 0, 0, 0, 0,
            0, 1, 0, 0, 0,
            0, 0,1, 0, 0,
            0, 0, 0, 1, 0 };
    cm.set(array);
    mColorMatrixFilter = new ColorMatrixColorFilter(cm);
    mMatrix = new Matrix();

    mTouchX = 0.01f; // 不讓x,y為0,否則在點計算時會有問題
    mTouchY = 0.01f;
}
 
開發者ID:z-chu,項目名稱:FriendBook,代碼行數:23,代碼來源:SimulationPageAnim.java

示例4: SimulationPageAnim

import android.graphics.ColorMatrix; //導入方法依賴的package包/類
public SimulationPageAnim(int w, int h, View view, OnPageChangeListener listener) {
    super(w, h, view, listener);
    mPath0 = new Path();
    mPath1 = new Path();
    mMaxLength = (float) Math.hypot(mScreenWidth, mScreenHeight);
    mPaint = new Paint();

    mPaint.setStyle(Paint.Style.FILL);

    createDrawable();

    ColorMatrix cm = new ColorMatrix();//設置顏色數組
    float array[] = { 1, 0, 0, 0, 0,
            0, 1, 0, 0, 0,
            0, 0,1, 0, 0,
            0, 0, 0, 1, 0 };
    cm.set(array);
    mColorMatrixFilter = new ColorMatrixColorFilter(cm);
    mMatrix = new Matrix();

    mTouchX = 0.01f; // 不讓x,y為0,否則在點計算時會有問題
    mTouchY = 0.01f;
}
 
開發者ID:newbiechen1024,項目名稱:NovelReader,代碼行數:24,代碼來源:SimulationPageAnim.java

示例5: contrastBitmap

import android.graphics.ColorMatrix; //導入方法依賴的package包/類
static Bitmap contrastBitmap(Bitmap bitmap, float contrast) {
    float[] colorTransform = new float[]{
            contrast, 0, 0, 0, 0,
            0, contrast, 0, 0, 0,
            0, 0, contrast, 0, 0,
            0, 0, 0, 1, 0};

    ColorMatrix colorMatrix = new ColorMatrix();
    colorMatrix.setSaturation(0f);
    colorMatrix.set(colorTransform);

    ColorMatrixColorFilter colorFilter = new ColorMatrixColorFilter(colorMatrix);
    Paint paint = new Paint();
    paint.setColorFilter(colorFilter);

    Bitmap resultBitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);
    Canvas canvas = new Canvas(resultBitmap);
    canvas.drawBitmap(resultBitmap, 0, 0, paint);

    return resultBitmap;
}
 
開發者ID:hoanganhtuan95ptit,項目名稱:EditPhoto,代碼行數:22,代碼來源:Utils.java

示例6: brightBitmap

import android.graphics.ColorMatrix; //導入方法依賴的package包/類
public static Bitmap brightBitmap(Bitmap bitmap, int brightness) {
    float[] colorTransform = {
            1, 0, 0, 0, brightness,
            0, 1, 0, 0, brightness,
            0, 0, 1, 0, brightness,
            0, 0, 0, 1, 0};

    ColorMatrix colorMatrix = new ColorMatrix();
    colorMatrix.setSaturation(0f);
    colorMatrix.set(colorTransform);

    ColorMatrixColorFilter colorFilter = new ColorMatrixColorFilter(colorMatrix);
    Paint paint = new Paint();
    paint.setColorFilter(colorFilter);


    Bitmap resultBitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);
    Canvas canvas = new Canvas(resultBitmap);
    canvas.drawBitmap(resultBitmap, 0, 0, paint);

    return resultBitmap;
}
 
開發者ID:hoanganhtuan95ptit,項目名稱:EditPhoto,代碼行數:23,代碼來源:Utils.java

示例7: contrastBitmap

import android.graphics.ColorMatrix; //導入方法依賴的package包/類
public static Bitmap contrastBitmap(Bitmap bitmap, int contrast) {
    float[] colorTransform = {
            contrast, 0, 0, 0, 1,
            0, contrast, 0, 0, 1,
            0, 0, contrast, 0, 1,
            0, 0, 0, 1, 0};

    ColorMatrix colorMatrix = new ColorMatrix();
    colorMatrix.setSaturation(0f);
    colorMatrix.set(colorTransform);

    ColorMatrixColorFilter colorFilter = new ColorMatrixColorFilter(colorMatrix);
    Paint paint = new Paint();
    paint.setColorFilter(colorFilter);


    Bitmap resultBitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);
    Canvas canvas = new Canvas(resultBitmap);
    canvas.drawBitmap(resultBitmap, 0, 0, paint);

    return resultBitmap;
}
 
開發者ID:hoanganhtuan95ptit,項目名稱:EditPhoto,代碼行數:23,代碼來源:Utils.java

示例8: brightBitmap

import android.graphics.ColorMatrix; //導入方法依賴的package包/類
static Bitmap brightBitmap(Bitmap bitmap, float brightness) {
    float[] colorTransform = {
            1, 0, 0, 0, brightness,
            0, 1, 0, 0, brightness,
            0, 0, 1, 0, brightness,
            0, 0, 0, 1, 0};

    ColorMatrix colorMatrix = new ColorMatrix();
    colorMatrix.setSaturation(0f);
    colorMatrix.set(colorTransform);

    ColorMatrixColorFilter colorFilter = new ColorMatrixColorFilter(colorMatrix);
    Paint paint = new Paint();
    paint.setColorFilter(colorFilter);


    Bitmap resultBitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);
    Canvas canvas = new Canvas(resultBitmap);
    canvas.drawBitmap(resultBitmap, 0, 0, paint);

    return resultBitmap;
}
 
開發者ID:hoanganhtuan95ptit,項目名稱:EditPhoto,代碼行數:23,代碼來源:Utils.java

示例9: PageWidget

import android.graphics.ColorMatrix; //導入方法依賴的package包/類
public PageWidget(Context context, String bookId,
                  List<BookMixAToc.mixToc.Chapters> chaptersList,
                  OnReadStateChangeListener listener) {
    super(context, bookId, chaptersList, listener);
    mPath0 = new Path();
    mPath1 = new Path();
    mMaxLength = (float) Math.hypot(mScreenWidth, mScreenHeight);
    mPaint = new Paint();
    mPaint.setStyle(Paint.Style.FILL);

    createDrawable();

    ColorMatrix cm = new ColorMatrix();//設置顏色數組
    float array[] = {0.55f, 0, 0, 0, 80.0f, 0, 0.55f, 0, 0, 80.0f, 0, 0, 0.55f, 0, 80.0f, 0, 0, 0, 0.2f, 0};
    cm.set(array);
    mColorMatrixFilter = new ColorMatrixColorFilter(cm);
    mMatrix = new Matrix();

    mTouch.x = 0.01f; // 不讓x,y為0,否則在點計算時會有問題
    mTouch.y = 0.01f;
}
 
開發者ID:ynztlxdeai,項目名稱:TextReader,代碼行數:22,代碼來源:PageWidget.java

示例10: handleImageGrayEffect

import android.graphics.ColorMatrix; //導入方法依賴的package包/類
public static Bitmap handleImageGrayEffect(Bitmap bitmap) {
  Bitmap bmp =
      Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
  float[] colorMatrixValue = new float[] {
      0.33f, 0.59f, 0.11f, 0, 0, 0.33f, 0.59f, 0.11f, 0, 0, 0.33f, 0.59f, 0.11f, 0, 0, 0, 0, 0, 1,
      0
  };
  ColorMatrix colorMatrix = new ColorMatrix();
  colorMatrix.set(colorMatrixValue);

  Canvas canvas = new Canvas(bmp);
  Paint paint = new Paint();
  paint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));
  canvas.drawBitmap(bitmap, 0, 0, paint);
  return bmp;
}
 
開發者ID:liuguoquan727,項目名稱:android-study,代碼行數:17,代碼來源:ImageHelper.java

示例11: createSLD

import android.graphics.ColorMatrix; //導入方法依賴的package包/類
/**
 * 設置Selector。 本次隻增加點擊變暗的效果,注釋的代碼為更多的效果
 */
public static StateListDrawable createSLD(Context context, Drawable drawable) {
    StateListDrawable bg = new StateListDrawable();
    int brightness = 50 - 127;
    ColorMatrix cMatrix = new ColorMatrix();
    cMatrix.set(new float[]{1, 0, 0, 0, brightness, 0, 1, 0, 0,
            brightness,// 改變亮度
            0, 0, 1, 0, brightness, 0, 0, 0, 1, 0});

    Paint paint = new Paint();
    paint.setColorFilter(new ColorMatrixColorFilter(cMatrix));

    Drawable normal = drawable;
    Drawable pressed = createDrawable(drawable, paint);
    bg.addState(new int[]{android.R.attr.state_pressed,}, pressed);
    bg.addState(new int[]{android.R.attr.state_focused,}, pressed);
    bg.addState(new int[]{android.R.attr.state_selected}, pressed);
    bg.addState(new int[]{}, normal);
    return bg;
}
 
開發者ID:dscn,項目名稱:ktball,代碼行數:23,代碼來源:CommonUtil.java

示例12: generateGrayImage

import android.graphics.ColorMatrix; //導入方法依賴的package包/類
/**
 * 灰色效果
 */
public static Bitmap generateGrayImage(Bitmap bm) {
    Bitmap bitmap = Bitmap.createBitmap(bm.getWidth(), bm.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint();

    float[] matrixs = new float[] { 0.33f, 0.59f, 0.11f, 0, 0, 0.33f, 0.59f, 0.11f, 0, 0, 0.33f, 0.59f, 0.11f, 0, 0,
            0, 0, 0, 1, 0 };

    ColorMatrix colorMatrix = new ColorMatrix();
    colorMatrix.set(matrixs);
    paint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));

    canvas.drawBitmap(bm, 0, 0, paint);

    return bitmap;
}
 
開發者ID:sunxu3074,項目名稱:imooc-practice-android,代碼行數:20,代碼來源:ImageUtils.java

示例13: revertImage

import android.graphics.ColorMatrix; //導入方法依賴的package包/類
/**
 * 圖像反轉
 */
public static Bitmap revertImage(Bitmap bm) {
    Bitmap bitmap = Bitmap.createBitmap(bm.getWidth(), bm.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint();

    float[] matrixs = new float[] { -1, 0, 0, 1, 1, 0, -1, 0, 1, 1, 0, 0, -1, 1, 1, 0, 0, 0, 1, 0 };

    ColorMatrix colorMatrix = new ColorMatrix();
    colorMatrix.set(matrixs);
    paint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));

    canvas.drawBitmap(bm, 0, 0, paint);

    return bitmap;
}
 
開發者ID:sunxu3074,項目名稱:imooc-practice-android,代碼行數:19,代碼來源:ImageUtils.java

示例14: memoriesImage

import android.graphics.ColorMatrix; //導入方法依賴的package包/類
/**
 * 懷舊效果
 */
public static Bitmap memoriesImage(Bitmap bm) {
    Bitmap bitmap = Bitmap.createBitmap(bm.getWidth(), bm.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint();

    float[] matrixs = new float[] { 0.393f, 0.769f, 0.189f, 0, 0, 0.349f, 0.686f, 0.168f, 0, 0, 0.272f, 0.534f,
            0.134f, 0, 0, 0, 0, 0, 1, 0 };

    ColorMatrix colorMatrix = new ColorMatrix();
    colorMatrix.set(matrixs);
    paint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));

    canvas.drawBitmap(bm, 0, 0, paint);

    return bitmap;
}
 
開發者ID:sunxu3074,項目名稱:imooc-practice-android,代碼行數:20,代碼來源:ImageUtils.java

示例15: desaturateImage

import android.graphics.ColorMatrix; //導入方法依賴的package包/類
/**
 * 去色效果
 */
public static Bitmap desaturateImage(Bitmap bm) {
    Bitmap bitmap = Bitmap.createBitmap(bm.getWidth(), bm.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint();

    float[] matrixs = new float[] { 1.5f, 1.5f, 1.5f, 0, -1, 1.5f, 1.5f, 1.5f, 0, -1, 1.5f, 1.5f, 1.5f, 0, -1, 0, 0,
            0, 1, 0 };

    ColorMatrix colorMatrix = new ColorMatrix();
    colorMatrix.set(matrixs);
    paint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));

    canvas.drawBitmap(bm, 0, 0, paint);

    return bitmap;
}
 
開發者ID:sunxu3074,項目名稱:imooc-practice-android,代碼行數:20,代碼來源:ImageUtils.java


注:本文中的android.graphics.ColorMatrix.set方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。