/** 获取图片 */ public Bitmap getBitmap(Context context) { // Don't leak context if (webImageCache == null) { webImageCache = new WebImageCache(context); } // 首先从缓存中获得图片 Bitmap bitmap = null; if (url != null) { bitmap = webImageCache.get(url); if (bitmap == null && mSmartImageConfig.isDownloadImage) { bitmap = getBitmapFromUrl(url); } else { if (bitmap != null && mSmartImageConfig.isAutoRotate && bitmap.getWidth() > bitmap.getHeight()) { Matrix matrix = new Matrix(); matrix.postRotate(90); bitmap = Bitmap.createBitmap( bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); if (bitmap != null) { webImageCache.cacheBitmapToMemory(url, bitmap); } } } } if (bitmap != null && mSmartImageConfig.isRound) { bitmap = toGrayscale(bitmap, 10); return bitmap; } else { return bitmap; } }