xamarin 拍照功能和相册浏览功能
根据路径获取图片失败 Bitmap resizedBitmap = BitmapFactory.DecodeFile( fileName, options);
操作环境、软件版本等信息
SetContentView(Resource.Layout.jx_main);
// Create your application here
//其他安卓芯片的默认拍照路径
originalFile = new Java.IO.File(Android.OS.Environment.GetExternalStoragePublicDirectory(
Android.OS.Environment.DirectoryPictures
), "zcb_pic_" + SystemClock.CurrentThreadTimeMillis() + ".jpg");
//高通芯片的默认拍照路径
finalFile = new Java.IO.File(Android.OS.Environment.GetExternalStoragePublicDirectory(
Android.OS.Environment.DirectoryDcim + @"/Camera"
), "zcb_pic_" + SystemClock.CurrentThreadTimeMillis() + ".jpg");
//拍照路径
public static Bitmap LoadAndResizeBitmap(this string fileName, int width, int height)
{
// First we get the the dimensions of the file on disk
BitmapFactory.Options options = new BitmapFactory.Options { InJustDecodeBounds = true };
BitmapFactory.DecodeFile(fileName, options);
// Next we calculate the ratio that we need to resize the image by
// in order to fit the requested dimensions.
int outHeight = options.OutHeight;
int outWidth = options.OutWidth;
int inSampleSize = 1;
if (outHeight > height || outWidth > width)
{
inSampleSize = outWidth > outHeight
? outHeight / height
: outWidth / width;
}
// Now we will load the image and have BitmapFactory resize it for us.
options.InSampleSize = inSampleSize;
options.InJustDecodeBounds = false;
Bitmap resizedBitmap = BitmapFactory.DecodeFile( fileName, options);
//Bitmap resizedBitmap = BitmapFactory.DecodeFile("file://" + fileName, options);
return resizedBitmap;
}
Bitmap resizedBitmap = BitmapFactory.DecodeFile( fileName, options);
如何修改改进
查考资料