为了账号安全,请及时绑定邮箱和手机立即绑定

保存一个图像连同它的thuml然后显示在imageView中

保存一个图像连同它的thuml然后显示在imageView中

慕仙森 2019-03-29 19:19:32
我想保存一个从相机拍摄的照片,然后把照片和 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;
查看完整描述

3 回答

  • 3 回答
  • 0 关注
  • 405 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信