Tabnine Logo
BitmapShader.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
android.graphics.BitmapShader
constructor

Best Java code snippets using android.graphics.BitmapShader.<init> (Showing top 20 results out of 2,331)

origin: nostra13/Android-Universal-Image-Loader

public RoundedDrawable(Bitmap bitmap, int cornerRadius, int margin) {
  this.cornerRadius = cornerRadius;
  this.margin = margin;
  bitmapShader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
  mBitmapRect = new RectF (margin, margin, bitmap.getWidth() - margin, bitmap.getHeight() - margin);
  
  paint = new Paint();
  paint.setAntiAlias(true);
  paint.setShader(bitmapShader);
  paint.setFilterBitmap(true);
  paint.setDither(true);
}
origin: rey5137/material

public void setImage(Bitmap bm){
  if(mBitmap != bm){
    mBitmap = bm;
    if(mBitmap != null) {
      mBitmapShader = new BitmapShader(mBitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
      mMatrix.reset();
      float scale = mHeight / (float)Math.min(mBitmap.getWidth(), mBitmap.getHeight());
      mMatrix.setScale(scale, scale, 0, 0);
      mMatrix.postTranslate((mHeight  - mBitmap.getWidth() * scale) / 2, (mHeight - mBitmap.getHeight() * scale) / 2);
      mBitmapShader.setLocalMatrix(mMatrix);
    }
  }
}
origin: nostra13/Android-Universal-Image-Loader

public CircleDrawable(Bitmap bitmap, Integer strokeColor, float strokeWidth) {
  radius = Math.min(bitmap.getWidth(), bitmap.getHeight()) / 2;
  bitmapShader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
  mBitmapRect = new RectF(0, 0, bitmap.getWidth(), bitmap.getHeight());
  paint = new Paint();
  paint.setAntiAlias(true);
  paint.setShader(bitmapShader);
  paint.setFilterBitmap(true);
  paint.setDither(true);
  if (strokeColor == null) {
    strokePaint = null;
  } else {
    strokePaint = new Paint();
    strokePaint.setStyle(Paint.Style.STROKE);
    strokePaint.setColor(strokeColor);
    strokePaint.setStrokeWidth(strokeWidth);
    strokePaint.setAntiAlias(true);
  }
  this.strokeWidth = strokeWidth;
  strokeRadius = radius - strokeWidth / 2;
}
origin: smuyyh/BookReader

private static Bitmap roundCrop(BitmapPool pool, Bitmap source) {
  if (source == null) return null;
  Bitmap result = pool.get(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888);
  if (result == null) {
    result = Bitmap.createBitmap(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888);
  }
  Canvas canvas = new Canvas(result);
  Paint paint = new Paint();
  paint.setShader(new BitmapShader(source, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP));
  paint.setAntiAlias(true);
  RectF rectF = new RectF(0f, 0f, source.getWidth(), source.getHeight());
  canvas.drawRoundRect(rectF, radius, radius, paint);
  return result;
}
origin: siyamed/android-shape-imageview

protected void createShader() {
  Bitmap bitmap = calculateDrawableSizes();
  if(bitmap != null && bitmap.getWidth() > 0 && bitmap.getHeight() > 0) {
    shader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
    imagePaint.setShader(shader);
  }
}
origin: frogermcs/InstaMaterial

@Override
public Bitmap transform(Bitmap source) {
  int size = Math.min(source.getWidth(), source.getHeight());
  int x = (source.getWidth() - size) / 2;
  int y = (source.getHeight() - size) / 2;
  Bitmap squaredBitmap = Bitmap.createBitmap(source, x, y, size, size);
  if (squaredBitmap != source) {
    source.recycle();
  }
  Bitmap bitmap = Bitmap.createBitmap(size, size, source.getConfig());
  Canvas canvas = new Canvas(bitmap);
  Paint paint = new Paint();
  BitmapShader shader = new BitmapShader(squaredBitmap, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);
  paint.setShader(shader);
  paint.setAntiAlias(true);
  float r = size / 2f;
  canvas.drawCircle(r, r, r, paint);
  squaredBitmap.recycle();
  return bitmap;
}
origin: wasabeef/glide-transformations

@Override
protected Bitmap transform(@NonNull Context context, @NonNull BitmapPool pool,
              @NonNull Bitmap toTransform, int outWidth, int outHeight) {
 int width = toTransform.getWidth();
 int height = toTransform.getHeight();
 Bitmap bitmap = pool.get(width, height, Bitmap.Config.ARGB_8888);
 bitmap.setHasAlpha(true);
 Canvas canvas = new Canvas(bitmap);
 Paint paint = new Paint();
 paint.setAntiAlias(true);
 paint.setShader(new BitmapShader(toTransform, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP));
 drawRoundRect(canvas, paint, width, height);
 return bitmap;
}
origin: cymcsg/UltimateAndroid

/**
 * Re-initializes the shader texture used to fill in
 * the Circle upon drawing.
 */
public void updateBitmapShader() {
  if (image == null)
    return;
  shader = new BitmapShader(image, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
  if(canvasSize != image.getWidth() || canvasSize != image.getHeight()) {
    Matrix matrix = new Matrix();
    float scale = (float) canvasSize / (float) image.getWidth();
    matrix.setScale(scale, scale);
    shader.setLocalMatrix(matrix);
  }
}
origin: smuyyh/BookReader

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;
}
origin: north2016/T-MVP

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;
}
origin: GitLqr/LQRWeChat

private void setup() {
  if (mBitmap == null) {
    return;
  }
  mBitmapShader = new BitmapShader(mBitmap, Shader.TileMode.CLAMP,
      Shader.TileMode.CLAMP);
  mBitmapPaint = new Paint();
  mBitmapPaint.setAntiAlias(true);
  mBitmapPaint.setShader(mBitmapShader);
  mBitmapHeight = mBitmap.getHeight();
  mBitmapWidth = mBitmap.getWidth();
  updateShaderMatrix();
  invalidate();
}
origin: koral--/android-gif-drawable

  @Override
  public void onDraw(Canvas canvas, Paint paint, Bitmap buffer) {
    if (mCornerRadius == 0) {
      canvas.drawBitmap(buffer, null, mDstRectF, paint);
      return;
    }
    if (mShader == null) {
      mShader = new BitmapShader(buffer, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
      final Matrix shaderMatrix = new Matrix();
      shaderMatrix.setTranslate(mDstRectF.left, mDstRectF.top);
      shaderMatrix.preScale(mDstRectF.width() / buffer.getWidth(), mDstRectF.height() / buffer.getHeight());
      mShader.setLocalMatrix(shaderMatrix);
    }
    paint.setShader(mShader);
    canvas.drawRoundRect(mDstRectF, mCornerRadius, mCornerRadius, paint);
  }
}
origin: aa112901/remusic

private void make(Bitmap bitmap) {
  mBitmap = getCroppedRoundBitmap(bitmap, 255, 15);
  mBitmapShader = new BitmapShader(mBitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
  mBitmapPaint.setAntiAlias(true);
  mBitmapPaint.setShader(mBitmapShader);
  mDrawableRect.set(0, 0, getWidth(), getHeight());
  mDrawableRadius = Math.min(mDrawableRect.height() / 2, mDrawableRect.width() / 2);
  mBitmapHeight = mBitmap.getHeight();
  mBitmapWidth = mBitmap.getWidth();
  updateShaderMatrix();
  invalidate();
}
origin: rey5137/material

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();
  }
}
origin: rey5137/material

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();
  }
}
origin: bumptech/glide

BitmapShader shader = new BitmapShader(toTransform, Shader.TileMode.CLAMP,
  Shader.TileMode.CLAMP);
Paint paint = new Paint();
origin: square/picasso

@Override public RequestHandler.Result transform(RequestHandler.Result source) {
 Bitmap bitmap = source.getBitmap();
 if (bitmap == null) {
  return source;
 }
 Bitmap result = createBitmap(bitmap.getWidth(), bitmap.getHeight(), bitmap.getConfig());
 Bitmap noise;
 try {
  noise = picasso.load(R.drawable.noise).get();
 } catch (IOException e) {
  throw new RuntimeException("Failed to apply transformation! Missing resource.");
 }
 BitmapShader shader = new BitmapShader(noise, REPEAT, REPEAT);
 ColorMatrix colorMatrix = new ColorMatrix();
 colorMatrix.setSaturation(0);
 ColorMatrixColorFilter filter = new ColorMatrixColorFilter(colorMatrix);
 Paint paint = new Paint(ANTI_ALIAS_FLAG);
 paint.setColorFilter(filter);
 Canvas canvas = new Canvas(result);
 canvas.drawBitmap(bitmap, 0, 0, paint);
 paint.setColorFilter(null);
 paint.setShader(shader);
 paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.MULTIPLY));
 canvas.drawRect(0, 0, canvas.getWidth(), canvas.getHeight(), paint);
 bitmap.recycle();
 noise.recycle();
 return new RequestHandler.Result(result, source.getLoadedFrom(), source.getExifRotation());
}
origin: hdodenhof/CircleImageView

mBitmapShader = new BitmapShader(mBitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
origin: alexvasilkov/GestureViews

private void setup() {
  Bitmap bitmap = isCircle ? getBitmapFromDrawable(getDrawable()) : null;
  if (bitmap != null) {
    bitmapPaint.setShader(new BitmapShader(bitmap, TileMode.CLAMP, TileMode.CLAMP));
    updateShaderMatrix();
  } else {
    bitmapPaint.setShader(null);
  }
  invalidate();
}
origin: alexvasilkov/GestureViews

private void setup() {
  init();
  Bitmap bitmap = isCircle ? getBitmapFromDrawable(getDrawable()) : null;
  if (bitmap != null) {
    BitmapShader bitmapShader = new BitmapShader(bitmap, TileMode.CLAMP, TileMode.CLAMP);
    tmpMatrix.set(getImageMatrix());
    tmpMatrix.postTranslate(getPaddingLeft(), getPaddingTop());
    bitmapShader.setLocalMatrix(tmpMatrix);
    bitmapPaint.setShader(bitmapShader);
  } else {
    bitmapPaint.setShader(null);
  }
  invalidate();
}
android.graphicsBitmapShader<init>

Popular methods of BitmapShader

  • setLocalMatrix
  • getLocalMatrix

Popular in Java

  • Running tasks concurrently on multiple threads
  • getContentResolver (Context)
  • getSupportFragmentManager (FragmentActivity)
  • getExternalFilesDir (Context)
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • MessageFormat (java.text)
    Produces concatenated messages in language-neutral way. New code should probably use java.util.Forma
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • JFileChooser (javax.swing)
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now