Android Bitmap Load getBitmap(Context c, String uri, int minsizeDP)

Here you can find the source of getBitmap(Context c, String uri, int minsizeDP)

Description

get Bitmap

Declaration

public static Bitmap getBitmap(Context c, String uri, int minsizeDP) 

Method Source Code

//package com.java2s;
import java.io.InputStream;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.provider.ContactsContract;

public class Main {
    public static Bitmap getBitmap(Context c, String uri, int minsizeDP) {
        InputStream input = ContactsContract.Contacts
                .openContactPhotoInputStream(c.getContentResolver(),
                        Uri.parse(uri), true);
        Bitmap bitmap = BitmapFactory.decodeStream(input);
        if (bitmap != null
                && bitmap.getScaledHeight(c.getResources()
                        .getDisplayMetrics()) < minsizeDP) {
            int newsize = Math
                    .round(c.getResources().getDisplayMetrics().density
                            * minsizeDP);
            bitmap = Bitmap.createScaledBitmap(bitmap, newsize, newsize,
                    true);/* w w w  .  jav  a 2 s. co  m*/
        }
        return bitmap;
    }
}

Related

  1. SafeDecodeBitmapFile( String strFilePath)
  2. decodeF(File f)
  3. decodeFile(File f, int size)
  4. decodeFromDescriptor( FileDescriptor descriptor)
  5. decodeFromDescriptor( FileDescriptor descriptor, int reqWidth, int reqHeight)
  6. getImageFromAssetFile(Context context, String fileName)
  7. downloadImageToSd(String urlSource, String pathDest)
  8. downloadImageToSd(String urlSource, String pathDest, String referer)
  9. getResizedBitmap(Uri imageUri, Activity activity)