5
मेरे पास कुछ एक्सएमएल-लेआउट जेनरेट किया गया है ImageView और मैं उस छवि की प्रतिलिपि बनाना चाहता हूं जिसे मैं नीचे LinearLayout
पर क्लिक करता हूं।क्यों Bitmap.getConfig() शून्य वापस आता है?
public void onClick(View v) {
// Take layout where i want to put my copy-image
LinearLayout savingLayout = (LinearLayout)findViewById(R.id.linearSaved);
//Create a new image
ImageView savedImage = new ImageView(savingLayout.getContext());
//Take the bitmap from the object i clicked
Bitmap b = ((BitmapDrawable)((ImageView)v).getDrawable()).getBitmap();
//Take the config of the bitmap. IT RETURNS NULL
Bitmap.Config cfg= b.getConfig();
//Copy the Bitmap and assign it to the new ImageView... IT CRASH (cfg == null)
Bitmap b2 = b.copy(cfg, true);
savedImage.setImageBitmap(b2);
savingLayout.addView(savedImage);
}
तो क्यों b.getConfig()
रिटर्न अशक्त:
मैं सभी ImageView
के onClick
घटनाओं के लिए अनुवर्ती घटना आवंटित की थी? एक कामकाज है?
धन्यवाद
'getConfig' वहां नहीं है क्योंकि यह रिटर्न इस बात पर निर्भर करता है कि किस प्रकार की छवि और/या मेरे पास कौन सा डिवाइस है? – zambotn