【发布时间】:2011-10-27 19:12:47
【问题描述】:
我有一个图像处理应用程序。如果我使用捕获图像的应用程序部分拍照,图像最终会正确显示在屏幕上。这是因为我使用硬件屏幕尺寸指定了相机参数。如果我尝试加载从手机相机(而不是应用程序的相机)拍摄的图像,则图像在屏幕上太大,有时从字节的角度来看太大。如何调整或压缩图库中的图像,以便我的应用可以使用它们?谢谢
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);
【问题讨论】: