0

I am using SmartImageView to load my images from my own database .

myImage = (SmartImageView) findViewById(R.id.imageView1);
    myImage.setImageUrl("http://172.22.75.224/droidlogin/zonea.JPG");

and i would need to convert this myimage to bitmap so as to draw over it using canvas.

currently i use

 Bitmap bitmap = ((BitmapDrawable)myImage.getDrawable()).getBitmap();

but it keeps giving me a null which means that it didn't conver to bitmap.

Hope someone could assist me please!

EggRollMan
  • 583
  • 1
  • 8
  • 20

3 Answers3

0

This is a great method of converting resource images into Android Bitmaps.

Bitmap largeIcon = BitmapFactory.decodeResource(getResources(), R.drawable.large_icon);
notBuilder.setLargeIcon(largeIcon);

hope it will work for you ...

Irfan Nasim
  • 1,952
  • 2
  • 19
  • 29
  • hi my image is inside my server . and im using smartimageview to load it into my app. But i want to draw over it now. using decode resource needs the image to be in my file. – EggRollMan Sep 11 '14 at 09:00
  • you can use Canvas class. Canvas class will allow you to draw decoded image. – Irfan Nasim Sep 11 '14 at 09:19
0

This will work for you as well.

But you try to be smart to convert this according to your problem.

Drawable myDrawable = getResources().getDrawable(R.drawable.logo);
Bitmap myLogo = ((BitmapDrawable) myDrawable).getBitmap();
Irfan Nasim
  • 1,952
  • 2
  • 19
  • 29
0

Try this ,it may help you

InputStream in = new java.net.URL(url).openStream(); Bitmap bitmap = BitmapFactory.decodeStream(in);

sachithkn
  • 457
  • 1
  • 4
  • 13