简体   繁体   中英

convert image into bitmap android

I have image..I want to convert it to bitmap & show it as bitmap.It is a default image. Now my architecture just like following way. I want to convert it to bitmap & return...

final int stub_id=R.drawable.tnlrocks;

photoToLoad.imageView.setImageResource(stub_id);

I did this. but it doesn't work. Help to overcome this problem......

Bitmap largeIcon = BitmapFactory.decodeResource(context.getResources(), R.drawable.tnlrocks);

                photoToLoad.imageView.setImageBitmap(largeIcon );

please help me to overcome this problem......

尝试这个:

photoToLoad.imageView.setImageDrawable(stub_id);

There are some good examples you can refer to :

Working With Images In Android

convert image into bitmap

Hope this helps you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM