android - كيفية تحويل صورة نقطية إلى Drawable في الروبوت؟
bitmap android-drawable (6)
كيف يمكنني تحويل صورة نقطية إلى Drawable؟
شكرا فرحا
إذا كان لديك صورة نقطية وتريد استخدامها في drawable ، مثل
Bitmap contact_pic; //a picture to show in drawable
drawable = new BitmapDrawable(contact_pic);
اعتدت مع السياق
//Convert bitmap to drawable
Drawable drawable = new BitmapDrawable(context.getResources(), bitmap);
تفضل واحد اخر:
Drawable drawable = RoundedBitmapDrawableFactory.create(context.getResources(), bitmap);
جرب هذا بتحويل Bitmap
نوع Bitmap
إلى Drawable
Drawable d = new BitmapDrawable(getResources(), bitmap);
documentation Bitmapdrawable الرسمية
هذا نموذج على كيفية تحويل الصورة النقطية إلى drawable
Bitmap bitmap;
//Convert bitmap to drawable
Drawable drawable = new BitmapDrawable(getResources(), bitmap);
imageView.setImageDrawable(drawable);
يبدو أنك تريد استخدام BitmapDrawable
من الوثائق:
و
Drawable
أن يلتف صورة نقطية ويمكن أن تكون مبلطة أوDrawable
أو محاذاة. يمكنك إنشاءBitmapDrawable
من مسار ملف أو دفق إدخال أو تضخم XML أو من كائنBitmap
.