i've an image processing app. If i take a picture using the part of the app that captures the image, the image is eventually displayed corectly on the screen. This is because i have specified camera params using the hardwares screen size. if i try to load an image that was taken from the phone's camera (not the app's camera), then the image is too large on the screen and sometimes too large from a byte point of view. how can i resize or compress the images in the gallery so that my app can use them? thanks
public class DisplayUndistortedBitmapFromGalleryActivity extends Activity {
private static final String TAG = "*********DUBFGActivity";
private Context mContext = this;
Uri uri;
private Bitmap mbitmap = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
uri = getIntent().getData();
if(uri != null){
Log.e(TAG, "uri ok");
}else {
Log.e(TAG, "uri not ok");
}
try {
mbitmap = Media.getBitmap(getContentResolver(), uri);
//setMbitmap(bitmap);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(mbitmap == null){
Log.e(TAG,"mbitmap is null");
}else{
Log.e(TAG,"mbitmap is not null");
}
.
public class DisplayUndistortedBitmapFromGallery extends View{
public DisplayUndistortedBitmapFromGallery(Context context) {
super(context);
}
public DisplayUndistortedBitmapFromGallery(Context context, AttributeSet attr) {
super(context,attr);
Log.e(TAG, "++++++++++ inside dubfgview constructor");
Bitmap bm = ((DisplayUndistortedBitmapFromGalleryActivity)getContext()).getMbitmap();
if(bm == null){
Log.e(TAG, "bm = null");
}else{
Log.e(TAG, "bm = not null");
}
bgr = bm.copy(bm.getConfig(), true);