use of android.graphics.Canvas in project glitch-hq-android by tinyspeck.
the class BitmapUtil method CreateOvalImage.
public static Bitmap CreateOvalImage(Bitmap orgBmp) {
int nW = 60;
int nH = 60;
int nW0 = orgBmp.getWidth();
int nH0 = orgBmp.getHeight();
// Rect r = new Rect();
// r.left = (int) ( nW0 * 0.18 );
// r.top = nH0 / 11;
// r.right = (int) ( nW0 * 0.94 );
// r.bottom = (int) ( nH0 * 0.63 );
Rect r = new Rect();
r.left = 18;
r.top = 16;
r.right = nW0;
r.bottom = 95;
Bitmap bmNew = Bitmap.createBitmap(nW, nH, Bitmap.Config.ARGB_8888);
Canvas cvs = new Canvas(bmNew);
Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setAntiAlias(true);
paint.setAlpha(78);
paint.setColor(0xffc0c0c0);
RectF rDest = new RectF();
rDest.left = 1;
rDest.right = nW;
rDest.top = 1;
rDest.bottom = nH;
Path clip = new Path();
clip.addCircle(nW / 2, nH / 2, (float) (nW / 2 + 0.5), Path.Direction.CW);
cvs.clipPath(clip);
cvs.drawARGB(78, 233, 240, 240);
cvs.drawBitmap(orgBmp, r, rDest, paint);
cvs.drawCircle(nW / 2, nH / 2, nW / 2, paint);
return bmNew;
}
use of android.graphics.Canvas in project glitch-hq-android by tinyspeck.
the class BitmapUtil method GetGrayscale.
public static Bitmap GetGrayscale(ImageView iv, Bitmap bm, boolean big) {
int width, height;
height = bm.getHeight();
width = bm.getWidth();
Bitmap bmGrayscale = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Bitmap bmCheckMark = BitmapFactory.decodeResource(iv.getResources(), big ? R.drawable.checkmark : R.drawable.checkmark_small);
Canvas c = new Canvas(bmGrayscale);
// for bitmap
Paint paint = new Paint();
ColorMatrix cm = new ColorMatrix();
cm.setSaturation(0);
ColorMatrixColorFilter f = new ColorMatrixColorFilter(cm);
paint.setColorFilter(f);
// for check mark
Paint colorPaint = new Paint();
// for circle around bitmap
Paint cPaint = new Paint();
cPaint.setStyle(Paint.Style.STROKE);
cPaint.setAntiAlias(true);
cPaint.setAlpha(78);
cPaint.setColor(0xffc0c0c0);
Path clip = new Path();
clip.addCircle(width / 2, height / 2, (float) (width / 2 + 1.0), Path.Direction.CW);
c.clipPath(clip);
c.drawARGB(78, 233, 240, 240);
c.drawBitmap(bm, 0, 0, paint);
c.drawCircle(width / 2, height / 2, width / 2, cPaint);
if (big) {
c.drawBitmap(bmCheckMark, 100, 65, colorPaint);
} else {
c.drawBitmap(bmCheckMark, 35, 30, colorPaint);
}
return bmGrayscale;
}
use of android.graphics.Canvas in project BGAQRCode-Android by bingoogolapple.
the class BGAQRCodeUtil method adjustPhotoRotation.
public static Bitmap adjustPhotoRotation(Bitmap inputBitmap, int orientationDegree) {
if (inputBitmap == null) {
return null;
}
Matrix matrix = new Matrix();
matrix.setRotate(orientationDegree, (float) inputBitmap.getWidth() / 2, (float) inputBitmap.getHeight() / 2);
float outputX, outputY;
if (orientationDegree == 90) {
outputX = inputBitmap.getHeight();
outputY = 0;
} else {
outputX = inputBitmap.getHeight();
outputY = inputBitmap.getWidth();
}
final float[] values = new float[9];
matrix.getValues(values);
float x1 = values[Matrix.MTRANS_X];
float y1 = values[Matrix.MTRANS_Y];
matrix.postTranslate(outputX - x1, outputY - y1);
Bitmap outputBitmap = Bitmap.createBitmap(inputBitmap.getHeight(), inputBitmap.getWidth(), Bitmap.Config.ARGB_8888);
Paint paint = new Paint();
Canvas canvas = new Canvas(outputBitmap);
canvas.drawBitmap(inputBitmap, matrix, paint);
return outputBitmap;
}
use of android.graphics.Canvas in project BGAQRCode-Android by bingoogolapple.
the class BGAQRCodeUtil method makeTintBitmap.
public static Bitmap makeTintBitmap(Bitmap inputBitmap, int tintColor) {
if (inputBitmap == null) {
return null;
}
Bitmap outputBitmap = Bitmap.createBitmap(inputBitmap.getWidth(), inputBitmap.getHeight(), inputBitmap.getConfig());
Canvas canvas = new Canvas(outputBitmap);
Paint paint = new Paint();
paint.setColorFilter(new PorterDuffColorFilter(tintColor, PorterDuff.Mode.SRC_IN));
canvas.drawBitmap(inputBitmap, 0, 0, paint);
return outputBitmap;
}
use of android.graphics.Canvas in project BGARefreshLayout-Android by bingoogolapple.
the class BGAMoocStyleRefreshView method initCanvas.
private void initCanvas() {
mOriginalBitmapWidth = mOriginalBitmap.getWidth();
mOriginalBitmapHeight = mOriginalBitmap.getHeight();
// 初始状态值
mWaveOriginalY = mOriginalBitmapHeight;
mWaveY = 1.2f * mWaveOriginalY;
mBezierControlOriginalY = 1.25f * mWaveOriginalY;
mBezierControlY = mBezierControlOriginalY;
mXfermode = new PorterDuffXfermode(PorterDuff.Mode.SRC_IN);
mBezierPath = new Path();
mCanvas = new Canvas();
mUltimateBitmap = Bitmap.createBitmap(mOriginalBitmapWidth, mOriginalBitmapHeight, Config.ARGB_8888);
mCanvas.setBitmap(mUltimateBitmap);
}
Aggregations