BitmapUtils.java 文件源码

java
阅读 48 收藏 0 点赞 0 评论 0

项目:android-titanium-imagecropper 作者:
/**
 * Rotate the given bitmap by the given degrees.<br>
 * New bitmap is created and the old one is recycled.
 */
private static Bitmap rotateAndFlipBitmapInt(
    Bitmap bitmap, int degrees, boolean flipHorizontally, boolean flipVertically) {
  if (degrees > 0 || flipHorizontally || flipVertically) {
    Matrix matrix = new Matrix();
    matrix.setRotate(degrees);
    matrix.postScale(flipHorizontally ? -1 : 1, flipVertically ? -1 : 1);
    Bitmap newBitmap =
        Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, false);
    if (newBitmap != bitmap) {
      bitmap.recycle();
    }
    return newBitmap;
  } else {
    return bitmap;
  }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号