android.graphics.Bitmap.prepareToDraw()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(496)

本文整理了Java中android.graphics.Bitmap.prepareToDraw()方法的一些代码示例,展示了Bitmap.prepareToDraw()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bitmap.prepareToDraw()方法的具体详情如下:
包路径:android.graphics.Bitmap
类名称:Bitmap
方法名:prepareToDraw

Bitmap.prepareToDraw介绍

暂无

代码示例

代码示例来源:origin: bumptech/glide

@Override
 public void initialize() {
  bitmap.prepareToDraw();
 }
}

代码示例来源:origin: bumptech/glide

@Override
 public void initialize() {
  drawable.getBitmap().prepareToDraw();
 }
}

代码示例来源:origin: bumptech/glide

@Override
 public void initialize() {
  if (drawable instanceof BitmapDrawable) {
   ((BitmapDrawable) drawable).getBitmap().prepareToDraw();
  } else if (drawable instanceof GifDrawable) {
   ((GifDrawable) drawable).getFirstFrame().prepareToDraw();
  }
 }
}

代码示例来源:origin: bumptech/glide

@Override
 public void initialize() {
  drawable.getFirstFrame().prepareToDraw();
 }
}

代码示例来源:origin: square/picasso

private void deliver(BitmapHunter hunter) {
 if (hunter.isCancelled()) {
  return;
 }
 RequestHandler.Result result = hunter.getResult();
 if (result != null) {
  Bitmap bitmap = result.getBitmap();
  if (bitmap != null) {
   bitmap.prepareToDraw();
  }
 }
 mainThreadHandler.sendMessage(mainThreadHandler.obtainMessage(HUNTER_COMPLETE, hunter));
 logDelivery(hunter);
}

代码示例来源:origin: mozilla-tw/Rocket

@Override
 public void initialize() {
  bitmap.prepareToDraw();
 }
}

代码示例来源:origin: mozilla-tw/Rocket

@Override
 public void initialize() {
  bitmap.prepareToDraw();
 }
}

代码示例来源:origin: mozilla-tw/Rocket

@Override
 public void initialize() {
  drawable.getBitmap().prepareToDraw();
 }
}

代码示例来源:origin: mozilla-tw/Rocket

@Override
 public void initialize() {
  if (drawable instanceof BitmapDrawable) {
   ((BitmapDrawable) drawable).getBitmap().prepareToDraw();
  }
 }
}

代码示例来源:origin: org.mapsforge/svg-android

private void doBitmap(Canvas canvas, float x, float y, float width, float height, byte[] bytes) {
 Bitmap bm = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
 if (bm != null) {
// Log.d(TAG, String.format("Image %f x %f %s", width, height, bm));
  bm.prepareToDraw();
  Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG | Paint.ANTI_ALIAS_FLAG);
  RectF rect = new RectF(x, y, x+width, y+height);
  canvas.clipRect(rect, Op.REPLACE);
  canvas.drawBitmap(bm, null, rect, paint);
  bm.recycle();
 }
}

代码示例来源:origin: milosmns/silly-android

/**
 * Colors the given bitmap to the specified color. Uses {@link PorterDuff.Mode#SRC_ATOP}.
 *
 * @param bitmap The original bitmap, must not be {@code null}
 * @param color  Which color to use for coloring
 * @return A new, colored Bitmap, never {@code null}
 */
@NonNull
public static Bitmap colorBitmap(@NonNull final Bitmap bitmap, @ColorInt final int color) {
  // use the original bitmap config
  final Bitmap result = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), bitmap.getConfig());
  // paint over the new canvas
  final Paint paint = new Paint();
  final Canvas c = new Canvas(result);
  paint.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP));
  c.drawBitmap(bitmap, 0, 0, paint);
  result.prepareToDraw();
  return result;
}

代码示例来源:origin: stackoverflow.com

mScreenBitmap.prepareToDraw();

代码示例来源:origin: wasdennnoch/AndroidN-ify

@Override
  protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
    DisplayMetrics mDisplayMetrics = (DisplayMetrics) XposedHelpers.getObjectField(param.thisObject, "mDisplayMetrics");
    Bitmap mScreenBitmap = (Bitmap) XposedHelpers.getObjectField(param.thisObject, "mScreenBitmap");
    if (width != 0 && height != 0 && (width != mDisplayMetrics.widthPixels || height != mDisplayMetrics.heightPixels)) {
      // Crop the screenshot to selected region
      Bitmap cropped = Bitmap.createBitmap(mScreenBitmap, x, y, width, height);
      mScreenBitmap.recycle();
      mScreenBitmap = cropped;
    }
    // reset
    x = 0;
    y = 0;
    width = 0;
    height = 0;
    // Optimizations
    mScreenBitmap.setHasAlpha(false);
    mScreenBitmap.prepareToDraw();
    XposedHelpers.setObjectField(param.thisObject, "mScreenBitmap", mScreenBitmap);
  }
});

代码示例来源:origin: kaixuanluo/pc-android-controller-android

mScreenBitmap.prepareToDraw();

代码示例来源:origin: goodbranch/ScreenCapture

/**
 * Takes a screenshot of the current display and shows an animation.
 */
void takeScreenshot(Bitmap bitmap, onScreenShotListener onScreenShotListener, boolean statusBarVisible, boolean navBarVisible) {
 // Take the screenshot
 mScreenBitmap = bitmap;
 this.mOnScreenShotListener = onScreenShotListener;
 if (mOnScreenShotListener != null) {
  mOnScreenShotListener.onStartShot();
 }
 if (mScreenBitmap == null) {
  notifyScreenshotError(mContext);
  return;
 }
 // Optimizations
 mScreenBitmap.setHasAlpha(false);
 mScreenBitmap.prepareToDraw();
 // Start the post-screenshot animation
 startAnimation(mDisplayMetrics.widthPixels, mDisplayMetrics.heightPixels,
   statusBarVisible, navBarVisible);
}

代码示例来源:origin: milosmns/silly-android

redSquare.prepareToDraw();
final byte[] redPixels = new byte[redSquare.getWidth() * redSquare.getHeight() * 8];
final ByteBuffer redBuffer = ByteBuffer.wrap(redPixels);
redSquare.copyPixelsToBuffer(redBuffer);
redSquare.copyPixelsFromBuffer(redBuffer);
redSquare.prepareToDraw();

相关文章