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