Tabnine Logo
BitmapShader.setLocalMatrix
Code IndexAdd Tabnine to your IDE (free)

How to use
setLocalMatrix
method
in
android.graphics.BitmapShader

Best Java code snippets using android.graphics.BitmapShader.setLocalMatrix (Showing top 20 results out of 1,152)

origin: nostra13/Android-Universal-Image-Loader

@Override
protected void onBoundsChange(Rect bounds) {
  super.onBoundsChange(bounds);
  mRect.set(0, 0, bounds.width(), bounds.height());
  radius = Math.min(bounds.width(), bounds.height()) / 2;
  strokeRadius = radius - strokeWidth / 2;
  // Resize the original bitmap to fit the new bound
  Matrix shaderMatrix = new Matrix();
  shaderMatrix.setRectToRect(mBitmapRect, mRect, Matrix.ScaleToFit.FILL);
  bitmapShader.setLocalMatrix(shaderMatrix);
}
origin: hdodenhof/CircleImageView

private void updateShaderMatrix() {
  float scale;
  float dx = 0;
  float dy = 0;
  mShaderMatrix.set(null);
  if (mBitmapWidth * mDrawableRect.height() > mDrawableRect.width() * mBitmapHeight) {
    scale = mDrawableRect.height() / (float) mBitmapHeight;
    dx = (mDrawableRect.width() - mBitmapWidth * scale) * 0.5f;
  } else {
    scale = mDrawableRect.width() / (float) mBitmapWidth;
    dy = (mDrawableRect.height() - mBitmapHeight * scale) * 0.5f;
  }
  mShaderMatrix.setScale(scale, scale);
  mShaderMatrix.postTranslate((int) (dx + 0.5f) + mDrawableRect.left, (int) (dy + 0.5f) + mDrawableRect.top);
  mBitmapShader.setLocalMatrix(mShaderMatrix);
}
origin: nostra13/Android-Universal-Image-Loader

@Override
protected void onBoundsChange(Rect bounds) {
  super.onBoundsChange(bounds);
  mRect.set(margin, margin, bounds.width() - margin, bounds.height() - margin);
  
  // Resize the original bitmap to fit the new bound
  Matrix shaderMatrix = new Matrix();
  shaderMatrix.setRectToRect(mBitmapRect, mRect, Matrix.ScaleToFit.FILL);
  bitmapShader.setLocalMatrix(shaderMatrix);
  
}
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: rey5137/material

private void updateMatrix(){
  if(mBitmap == null)
    return;
  Rect bounds = getBounds();
  if(bounds.width() == 0 || bounds.height() == 0)
    return;
  mMatrix.reset();
  float scale = bounds.height() / (float)Math.min(mBitmap.getWidth(), mBitmap.getHeight());
  mMatrix.setScale(scale, scale, 0, 0);
  mMatrix.postTranslate((bounds.height()  - mBitmap.getWidth() * scale) / 2, (bounds.height() - mBitmap.getHeight() * scale) / 2);
  mBitmapShader.setLocalMatrix(mMatrix);
}
origin: naman14/Timber

private void updateShaderMatrix() {
  float scale;
  float dx = 0;
  float dy = 0;
  mShaderMatrix.set(null);
  if (mBitmapWidth * mDrawableRect.height() > mDrawableRect.width() * mBitmapHeight) {
    scale = mDrawableRect.height() / (float) mBitmapHeight;
    dx = (mDrawableRect.width() - mBitmapWidth * scale) * 0.5f;
  } else {
    scale = mDrawableRect.width() / (float) mBitmapWidth;
    dy = (mDrawableRect.height() - mBitmapHeight * scale) * 0.5f;
  }
  mShaderMatrix.setScale(scale, scale);
  mShaderMatrix.postTranslate((int) (dx + 0.5f) + mDrawableRect.left, (int) (dy + 0.5f) + mDrawableRect.top);
  mBitmapShader.setLocalMatrix(mShaderMatrix);
}
origin: aa112901/remusic

private void updateShaderMatrix() {
  float scale;
  float dx = 0;
  float dy = 0;
  mShaderMatrix.set(null);
  if (mBitmapWidth * mDrawableRect.height() > mDrawableRect.width() * mBitmapHeight) {
    scale = mDrawableRect.height() / (float) mBitmapHeight;
    dx = (mDrawableRect.width() - mBitmapWidth * scale) * 0.5f;
  } else {
    scale = mDrawableRect.width() / (float) mBitmapWidth;
    dy = (mDrawableRect.height() - mBitmapHeight * scale) * 0.5f;
  }
  mShaderMatrix.setScale(scale, scale);
  mShaderMatrix.postTranslate((int) (dx + 0.5f) + mDrawableRect.left, (int) (dy + 0.5f) + mDrawableRect.top);
  mBitmapShader.setLocalMatrix(mShaderMatrix);
}
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: HotBitmapGG/bilibili-android-client

  private void updateShaderMatrix() {
    float scale;
    float dx = 0;
    float dy = 0;
    mShaderMatrix.set(null);
    if (mBitmapWidth * mDrawableRect.height() > mDrawableRect.width() * mBitmapHeight) {
      scale = mDrawableRect.height() / (float) mBitmapHeight;
      dx = (mDrawableRect.width() - mBitmapWidth * scale) * 0.5f;
    } else {
      scale = mDrawableRect.width() / (float) mBitmapWidth;
      dy = (mDrawableRect.height() - mBitmapHeight * scale) * 0.5f;
    }
    mShaderMatrix.setScale(scale, scale);
    mShaderMatrix.postTranslate((int) (dx + 0.5f) + mDrawableRect.left, (int) (dy + 0.5f) + mDrawableRect.top);
    mBitmapShader.setLocalMatrix(mShaderMatrix);
  }
}
origin: lygttpod/SuperTextView

private void updateShaderMatrix() {
  float scale;
  float dx = 0;
  float dy = 0;
  mShaderMatrix.set(null);
  if (mBitmapWidth * mDrawableRect.height() > mDrawableRect.width() * mBitmapHeight) {
    scale = mDrawableRect.height() / (float) mBitmapHeight;
    dx = (mDrawableRect.width() - mBitmapWidth * scale) * 0.5f;
  } else {
    scale = mDrawableRect.width() / (float) mBitmapWidth;
    dy = (mDrawableRect.height() - mBitmapHeight * scale) * 0.5f;
  }
  mShaderMatrix.setScale(scale, scale);
  mShaderMatrix.postTranslate((int) (dx + 0.5f) + mDrawableRect.left, (int) (dy + 0.5f) + mDrawableRect.top);
  mBitmapShader.setLocalMatrix(mShaderMatrix);
}
origin: rey5137/material

private void updateMatrix(){
  if(mBitmap == null)
    return;
  Rect bounds = getBounds();
  if(bounds.width() == 0 || bounds.height() == 0)
    return;
  mMatrix.reset();
  float scale = bounds.height() / (float)Math.min(mBitmap.getWidth(), mBitmap.getHeight());
  mMatrix.setScale(scale, scale, 0, 0);
  mMatrix.postTranslate(bounds.exactCenterX()  - mBitmap.getWidth() * scale / 2, bounds.exactCenterY() - mBitmap.getHeight() * scale / 2);
  mBitmapShader.setLocalMatrix(mMatrix);
}
origin: iMeiji/Toutiao

private void updateShaderMatrix() {
  float scale;
  float dx = 0;
  float dy = 0;
  mShaderMatrix.set(null);
  if (mBitmapWidth * mDrawableRect.height() > mDrawableRect.width() * mBitmapHeight) {
    scale = mDrawableRect.height() / (float) mBitmapHeight;
    dx = (mDrawableRect.width() - mBitmapWidth * scale) * 0.5f;
  } else {
    scale = mDrawableRect.width() / (float) mBitmapWidth;
    dy = (mDrawableRect.height() - mBitmapHeight * scale) * 0.5f;
  }
  mShaderMatrix.setScale(scale, scale);
  mShaderMatrix.postTranslate((int) (dx + 0.5f) + mDrawableRect.left, (int) (dy + 0.5f) + mDrawableRect.top);
  mBitmapShader.setLocalMatrix(mShaderMatrix);
}
origin: GitLqr/LQRWeChat

private void updateShaderMatrix() {
  float scale;
  float dx = 0;
  float dy = 0;
  mShaderMatrix = new Matrix();
  mShaderMatrix.set(null);
  mDrawableRect = new Rect(0, 0, getRight() - getLeft(), getBottom()
      - getTop());
  if (mBitmapWidth * mDrawableRect.height() > mDrawableRect.width()
      * mBitmapHeight) {
    scale = mDrawableRect.height() / (float) mBitmapHeight;
    dx = (mDrawableRect.width() - mBitmapWidth * scale) * 0.5f;
  } else {
    scale = mDrawableRect.width() / (float) mBitmapWidth;
    dy = (mDrawableRect.height() - mBitmapHeight * scale) * 0.5f;
  }
  mShaderMatrix.setScale(scale, scale);
  mShaderMatrix.postTranslate((int) (dx + 0.5f), (int) (dy + 0.5f));
  mBitmapShader.setLocalMatrix(mShaderMatrix);
}
origin: Bearded-Hen/Android-Bootstrap

matrix.postTranslate((dx + 0.5f), (dy + 0.5f));
imageShader.setLocalMatrix(matrix);
imageRectF.set(0, 0, viewWidth, viewHeight);
origin: mmin18/RealtimeBlurView

  /**
   * Custom oval shape
   */
  @Override
  protected void drawBlurredBitmap(Canvas canvas, Bitmap blurredBitmap, int overlayColor) {
    if (blurredBitmap != null) {
      mRectF.right = getWidth();
      mRectF.bottom = getHeight();

      mPaint.reset();
      mPaint.setAntiAlias(true);
      BitmapShader shader = new BitmapShader(blurredBitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
      Matrix matrix = new Matrix();
      matrix.postScale(mRectF.width() / blurredBitmap.getWidth(), mRectF.height() / blurredBitmap.getHeight());
      shader.setLocalMatrix(matrix);
      mPaint.setShader(shader);
      canvas.drawOval(mRectF, mPaint);

      mPaint.reset();
      mPaint.setAntiAlias(true);
      mPaint.setColor(overlayColor);
      canvas.drawOval(mRectF, mPaint);
    }
  }
}
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();
}
origin: ZieIony/Carbon

Matrix matrix = new Matrix();
matrix.postTranslate(bounds.left, bounds.top);
checkedShader.setLocalMatrix(matrix);
origin: vinc3m1/RoundedImageView

BitmapShader bitmapShader = new BitmapShader(mBitmap, mTileModeX, mTileModeY);
if (mTileModeX == Shader.TileMode.CLAMP && mTileModeY == Shader.TileMode.CLAMP) {
 bitmapShader.setLocalMatrix(mShaderMatrix);
origin: ZieIony/Carbon

final Rect bounds = getBounds();
mMaskMatrix.setTranslate(bounds.left - x, bounds.top - y);
mMaskShader.setLocalMatrix(mMaskMatrix);
origin: weexteam/weex-hackernews

private static void updateShaderAndSize(@NonNull ImageView.ScaleType scaleType, int vWidth, int vHeight, ImageDrawable imageDrawable, BitmapShader bitmapShader) {
 Matrix matrix = createShaderMatrix(scaleType, vWidth, vHeight,
                   imageDrawable.bitmapWidth,
                   imageDrawable.bitmapHeight);
 int intrinsicWidth = vWidth, intrinsicHeight = vHeight;
 if (scaleType == ImageView.ScaleType.FIT_CENTER) {
  RectF bitmapRect = new RectF(0, 0, imageDrawable.bitmapWidth, imageDrawable.bitmapHeight), contentRect = new RectF();
  matrix.mapRect(contentRect, bitmapRect);
  intrinsicWidth = (int) contentRect.width();
  intrinsicHeight = (int) contentRect.height();
  matrix = createShaderMatrix(scaleType, intrinsicWidth, intrinsicHeight, imageDrawable
    .bitmapWidth, imageDrawable.bitmapHeight);
 }
 imageDrawable.setIntrinsicWidth(intrinsicWidth);
 imageDrawable.setIntrinsicHeight(intrinsicHeight);
 bitmapShader.setLocalMatrix(matrix);
}
android.graphicsBitmapShadersetLocalMatrix

Popular methods of BitmapShader

  • <init>
  • getLocalMatrix

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • putExtra (Intent)
  • onRequestPermissionsResult (Fragment)
  • BufferedInputStream (java.io)
    A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the i
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • Properties (java.util)
    A Properties object is a Hashtable where the keys and values must be Strings. Each property can have
  • Set (java.util)
    A Set is a data structure which does not allow duplicate elements.
  • BoxLayout (javax.swing)
  • JTable (javax.swing)
  • Top 17 Plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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