Example usage for android.widget ImageView setImageBitmap

List of usage examples for android.widget ImageView setImageBitmap

Introduction

In this page you can find the example usage for android.widget ImageView setImageBitmap.

Prototype

@android.view.RemotableViewMethod
public void setImageBitmap(Bitmap bm) 

Source Link

Document

Sets a Bitmap as the content of this ImageView.

Usage

From source file:Main.java

public static void setImage(Bitmap bitmap, ImageView imageview) {
    if (bitmap != null) {
        imageview.setImageBitmap(bitmap);
    }//  www .  j ava 2  s.  co m
}

From source file:Main.java

public static void setImageBitmapFromFile(ImageView v, String path) {
    Bitmap bm = BitmapFactory.decodeFile(path);
    v.setImageBitmap(bm);
}

From source file:Main.java

public static ImageView createImageViewFromBitmap(Context context, Bitmap bitmap) {
    ImageView imageView = new ImageView(context);
    imageView.setScaleType(ScaleType.FIT_XY);
    imageView.setImageBitmap(bitmap);
    return imageView;
}

From source file:Main.java

/**
 * <pre>/*  w  w  w . j av  a  2 s.  c  o m*/
 * Recycle bitmap rendered by {@link ImageView}.
 * </pre>
 * @return true if bitmap was recycled successfully
 */
public static boolean recycleImageView(ImageView imageView) {
    Bitmap bm = extractBitmap(imageView);
    imageView.setImageBitmap(null);
    return recycleBitmap(bm);
}

From source file:Main.java

public static void setImagePictureFromBitmap(Context c, ImageView view, Bitmap bitmap, int notFoundResource) {
    if (bitmap == null)
        view.setImageResource(notFoundResource);
    view.setImageBitmap(bitmap);
}

From source file:Main.java

public static void setImageToImageView(Context context, Intent intent, ImageView imageView) {
    Bundle extras = intent.getExtras();/*  w w w.  ja  va  2s .  co  m*/
    if (extras != null) {
        photo = extras.getParcelable("data");
        imageView.setImageBitmap(photo);
    }
}

From source file:Main.java

public static void setImageSrc(ImageView imageView, Bitmap bm) {
    BitmapFactory.Options option = new BitmapFactory.Options();
    option.inSampleSize = 1;/*from  ww  w  .ja v  a2 s.  c om*/
    imageView.setImageBitmap(bm);
}

From source file:Main.java

public static void setPicToView(Intent picdata, ImageView imageView) {
    Bundle extras = picdata.getExtras();
    if (extras != null) {
        Bitmap photo = extras.getParcelable("data");
        imageView.setImageBitmap(photo);
    }/*from   w  w w . j a  va 2s. co m*/

}

From source file:com.kogitune.activitytransition.core.TransitionAnimation.java

private static void setImageToView(View toView, Bitmap bitmap) {
    if (toView instanceof ImageView) {
        final ImageView toImageView = (ImageView) toView;
        toImageView.setImageBitmap(bitmap);
    } else {/*from  www  .j ava2s.  c  o  m*/
        ViewCompat.setBackground(toView, new BitmapDrawable(toView.getResources(), bitmap));
    }
}

From source file:Main.java

public static ImageView getImageViewFromUrl(String imageUrl, Activity activity, int viewId) {

    try {/*from   w  ww  .  j  a  v  a 2s  . c  o m*/
        ImageView i = (ImageView) activity.findViewById(viewId);
        Bitmap bitmap = BitmapFactory.decodeStream((InputStream) new URL(imageUrl).getContent());
        i.setImageBitmap(bitmap);
        return i;
    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return null;

}