本文整理匯總了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}