This is a migrated thread and some comments may be shown as answers.

Cropping Photo from photochooser task

2 Answers 65 Views
ImageEditor
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Mohan Raj
Top achievements
Rank 1
Mohan Raj asked on 09 Nov 2013, 07:56 AM

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);
 
}


2 Answers, 1 is accepted

Sort by
0
Manuel
Top achievements
Rank 1
answered on 14 Nov 2013, 02:02 AM

Same need with an image from the camera : take picture => crop or modify color => save in isolated storage


thanks you very much

0
Deyan
Telerik team
answered on 14 Nov 2013, 08:36 AM
Hi,

These are standard Windows Phone APIs. A thorough documentation on their usage is available on MSDN:

http://msdn.microsoft.com/en-US/library/windowsphone/develop/microsoft.phone.tasks.photochoosertask(v=vs.105).aspx

http://developer.nokia.com/Community/Wiki/File_manipulation_with_IsolatedStorageFile_on_Windows_Phone

I hope this helps.

Regards,
Deyan
Telerik
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
Tags
ImageEditor
Asked by
Mohan Raj
Top achievements
Rank 1
Answers by
Manuel
Top achievements
Rank 1
Deyan
Telerik team
Share this question
or