This question is locked. New answers and comments are not allowed.
Hi,
I want to prompt the user to pick the photos from gallery, then crop and save it to the isolated storage.. but it didn't work. shows excpetion as "Specified method is not supported" at
wb.SaveJpeg(fileStream, wb.PixelWidth, wb.PixelHeight, 0, 100);
Any help please.
Thanx
void
pt_Completed(
object
sender, PhotoResult e)
{
if
(e.ChosenPhoto!=
null
)
saveImage(e.ChosenPhoto,
"customImage"
);
}
private
void
saveImage(System.IO.Stream stream,
string
p)
{
using
(IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
if
(myIsolatedStorage.FileExists(
"/Shared/ShellContent/"
+ p +
".jpg"
))
{
myIsolatedStorage.DeleteFile(
"/Shared/ShellContent/"
+ p +
".jpg"
);
}
IsolatedStorageFileStream fileStream = myIsolatedStorage.CreateFile(
"/Shared/ShellContent/"
+ p +
".jpg"
);
BitmapImage bitmap =
new
BitmapImage();
bitmap.SetSource(stream);
//WriteableBitmap wb = new WriteableBitmap(bitmap);
cropImage(bitmap, fileStream);
fileStream.Close();
}
}
private
async
void
cropImage(BitmapImage bitmap, IsolatedStorageFileStream fileStream)
{
CropTool crp =
new
CropTool();
crp.CropRect =
new
Rect(0.25, 0.25, 0.32, 0.68);
WriteableBitmap wb = await crp.Apply(bitmap);
wb.SaveJpeg(fileStream, wb.PixelWidth, wb.PixelHeight, 0, 100);
}