hi,
I am making a Windows Phone Application where i need to save a picture to gallery. I am using the following code. the
imgview is the image
But I am getting an Debugg error at
var picture = mediaLibrary.SavePicture(fileName, stream);
. the filename which i am passing is correct. Do i need to add eny more assemblies or dll files to make that .. PlZ help me .
private bool SaveImageToPhotoHub(WriteableBitmap bmp)
{
using (var mediaLibrary = new MediaLibrary())
{
using (var stream = new MemoryStream())
{
var fileName = string.Format("Gs{0}.jpg", Guid.NewGuid());
bmp.SaveJpeg(stream, bmp.PixelWidth, bmp.PixelHeight, 0, 100);
stream.Seek(0, SeekOrigin.Begin);
var picture = mediaLibrary.SavePicture(fileName, stream);
if (picture.Name.Contains(fileName)) return true;
}
}
return false;
}
private void Save_Click(object sender, RoutedEventArgs e)
{
WriteableBitmap bmp = new WriteableBitmap(imgview, null);
if (SaveImageToPhotoHub(bmp))
{
MessageBox.Show("Image Saved", "Information", MessageBoxButton.OK);
}
else
{
MessageBox.Show("Error : Image Not Saved", "Information", MessageBoxButton.OK);
}
}