我想保存一个从相机拍摄的照片,然后把照片和 Thumb 保存在 sdCard 中,然后把它们显示在一个 imageView 中。后来给出空指针错误。
imageBitmap = Bitmap.createScaledBitmap(imageBitmap, 40, 40, false);
哪里出错了?
{ Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); try { if (title.getText().toString().equals("")) { displayAlert("Please Input Title First","Error!"); } else { Integer val = myMisc.miscId ; String fileName = "image" + "_" + title.getText().toString()+"_" + val.toString(); photo = this.createFile(fileName, ".jpg"); myMisc.filename = photo.getAbsolutePath(); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo)); startActivityForResult(intent, RESULT_CAMERA_SELECT); } } catch(Exception e) { Log.v("Error", "Can't create file to take picture!"); displayAlert("Can't create file to take picture!","SDCard Error!"); } } public synchronized void onActivityResult(final int requestCode, int resultCode, final Intent data) { if (resultCode == Activity.RESULT_OK) { if (requestCode == RESULT_CAMERA_SELECT) { try { saveImage(); } catch (IOException e) { e.printStackTrace(); } } public static int calculateInSampleSize( BitmapFactory.Options options, int reqWidth, int reqHeight) { // Raw height and width of image final int height = options.outHeight; final int width = options.outWidth; int inSampleSize = 1;
相关分类