Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi, I'm working on a windows store application, I'm selecting an image using FileOpenPicker and editing the image using an API, I'm displaying the edited image on a new image control. How do i save this image to the disk?
Posted

Hello Ravindra,
To save an image to IsolatedStorage from a PhotoChooserTask, use this (the e object in the task callback holds the stream.
C#
public static void SaveImage(Stream imageStream, string fileName, int orientation, int quality)
{
    using (var isolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
    {
        if (isolatedStorage.FileExists(fileName))
            isolatedStorage.DeleteFile(fileName);

        IsolatedStorageFileStream fileStream = isolatedStorage.CreateFile(fileName);
        BitmapImage bitmap = new BitmapImage();
        bitmap.SetSource(imageStream);

        WriteableBitmap wb = new WriteableBitmap(bitmap);
        wb.SaveJpeg(fileStream, wb.PixelWidth, wb.PixelHeight, orientation, quality);
        fileStream.Close();
    }
}
 
Share this answer
 
Hi Sunasara,

I'm working on Windows 8 application not Windows phone.

Could you please post the code for a windows 8 application.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900