我想加載具有透明背景的PNG。從URI加載的圖像有黑色背景
mImageCursor = getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
ImageThumbnailAdapter.IMAGE_PROJECTION, null, null,
MediaStore.Images.ImageColumns.DISPLAY_NAME);
投影:
private static Bitmap loadThumbnail(ContentResolver cr, Uri uri) {
return MediaStore.Images.Thumbnails.getThumbnail(
cr, ContentUris.parseId(uri), MediaStore.Images.Thumbnails.MINI_KIND, sBitmapOptions);
}
設置在景觀:
裝載public static final int IMAGE_ID_COLUMN = 0;
public static final int IMAGE_NAME_COLUMN = 1;
方法
Bitmap bitmapOld = loadThumbnail(mArgs.mContentResolver, mArgs.mUri);
ByteArrayOutputStream out = new ByteArrayOutputStream();
bitmapOld.compress(Bitmap.CompressFormat.PNG, 100, out );
final Bitmap bitmap = BitmapFactory.decodeStream(new ByteArrayInputStream(out.toByteArray()));
Bitmap mutableBitmap = bitmapOld.copy(Bitmap.Config.ARGB_8888, true);
final Canvas canvas = new Canvas(mutableBitmap);
// Canvas c = new Canvas(bitmap);
canvas.drawColor(0, PorterDuff.Mode.CLEAR);
//This drawabl is coming black in Background.
final Bitmap bmpfinal = mutableBitmap;
那麼你能告訴我這是一個網絡uri或像你這樣的簡單存儲在本地系統? –
本地文件系統。 –
只需通過此鏈接https://github.com/hiteshsahu/AwesomeAndroid-Gallery –