use of android.graphics.BitmapShader in project T-MVP by north2016.
the class GlideCircleTransform method circleCrop.
private static Bitmap circleCrop(BitmapPool pool, Bitmap source) {
if (source == null)
return null;
int size = Math.min(source.getWidth(), source.getHeight());
int x = (source.getWidth() - size) / 2;
int y = (source.getHeight() - size) / 2;
// TODO this could be acquired from the pool too
Bitmap squared = Bitmap.createBitmap(source, x, y, size, size);
Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888);
if (result == null) {
result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
}
Canvas canvas = new Canvas(result);
Paint paint = new Paint();
paint.setShader(new BitmapShader(squared, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP));
paint.setAntiAlias(true);
float r = size / 2f;
canvas.drawCircle(r, r, r, paint);
return result;
}
use of android.graphics.BitmapShader in project mobile-android by photo.
the class WheelRadio method onLayout.
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
int w = right - left;
if (w > 0 && changed || mForceLayout) {
mRealRect = new Rect(mPaddingLeft, top, w - mPaddingRight, bottom);
mIndicatorSmall = makeBitmap2(w / mSmallTicksCount, bottom - top, mLineTickSize);
mShader = new BitmapShader(mIndicatorSmall, Shader.TileMode.REPEAT, Shader.TileMode.CLAMP);
mIndicatorBig = makeBitmap3(mRealRect.width() / mBigTicksCount, bottom - top, mLineBigSize);
mShader1 = new BitmapShader(mIndicatorBig, Shader.TileMode.REPEAT, Shader.TileMode.CLAMP);
mIndicator = makeIndicator(bottom - top, mLineBigSize);
mCorrectionX = (((float) mRealRect.width() / mBigTicksCount) % 1) * mBigTicksCount;
mForceLayout = false;
}
}
use of android.graphics.BitmapShader in project CircleDemo by Naoki2015.
the class GlideCircleTransform method circleCrop.
private Bitmap circleCrop(BitmapPool pool, Bitmap source) {
if (source == null)
return null;
int size = Math.min(source.getWidth(), source.getHeight());
int x = (source.getWidth() - size) / 2;
int y = (source.getHeight() - size) / 2;
// TODO this could be acquired from the pool too
Bitmap squared = Bitmap.createBitmap(source, x, y, size, size);
Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888);
if (result == null) {
result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
}
Canvas canvas = new Canvas(result);
Paint paint = new Paint();
paint.setShader(new BitmapShader(squared, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP));
paint.setAntiAlias(true);
float r = size / 2f;
canvas.drawCircle(r, r, r, paint);
return result;
}
use of android.graphics.BitmapShader in project material by rey5137.
the class ContactChipDrawable method setImage.
public void setImage(Bitmap bm) {
if (mBitmap != bm) {
mBitmap = bm;
if (mBitmap != null) {
mBitmapShader = new BitmapShader(mBitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
updateMatrix();
}
invalidateSelf();
}
}
use of android.graphics.BitmapShader in project JamsMusicPlayer by psaravan.
the class CircularImageView method onDraw.
@Override
public void onDraw(Canvas canvas) {
// load the bitmap
image = drawableToBitmap(getDrawable());
// init shader
if (image != null) {
canvasSize = canvas.getWidth();
if (canvas.getHeight() < canvasSize)
canvasSize = canvas.getHeight();
BitmapShader shader = new BitmapShader(Bitmap.createScaledBitmap(image, canvasSize, canvasSize, false), Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
paint.setShader(shader);
// circleCenter is the x or y of the view's center
// radius is the radius in pixels of the cirle to be drawn
// paint contains the shader that will texture the shape
int circleCenter = (canvasSize - (borderWidth * 2)) / 2;
canvas.drawCircle(circleCenter + borderWidth, circleCenter + borderWidth, ((canvasSize - (borderWidth * 2)) / 2) + borderWidth - 4.0f, paintBorder);
canvas.drawCircle(circleCenter + borderWidth, circleCenter + borderWidth, ((canvasSize - (borderWidth * 2)) / 2) - 4.0f, paint);
}
}
Aggregations