Cropping Photo from photochooser task

3 posts, 0 answers
  1. Mohan Raj
    Mohan Raj avatar
    1 posts
    Member since:
    Jan 2013

    Posted 09 Nov 2013 Link to this post

    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. Manuel
    Manuel avatar
    5 posts
    Member since:
    Mar 2012

    Posted 13 Nov 2013 Link to this post

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


    thanks you very much

  3. DevCraft banner
  4. Deyan
    Admin
    Deyan avatar
    2037 posts

    Posted 14 Nov 2013 Link to this post

    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.
Back to Top