Exemplo n.º 1
0
        private IMobeelizerFile GetRandomPhoto()
        {
            String             uri  = String.Format("Resources/images/{0}", DataUtil.GetRandomPhoto());
            StreamResourceInfo info = Application.GetResourceStream(new Uri(uri, UriKind.Relative));

            return(Mobeelizer.CreateFile("photo", info.Stream));;
        }
Exemplo n.º 2
0
        private void GetPhotoTaskCompleted(object sender, PhotoResult e)
        {
            if (getPhotoCallback != null)
            {
                if (e.TaskResult == TaskResult.OK)
                {
                    JpegInfo info = ExifReader.ReadJpeg(e.ChosenPhoto, e.OriginalFileName);
                    e.ChosenPhoto.Seek(0, SeekOrigin.Begin);
                    ExifOrientation _orientation = info.Orientation;
                    int             _angle       = 0;
                    switch (info.Orientation)
                    {
                    case ExifOrientation.TopLeft:
                    case ExifOrientation.Undefined:
                        _angle = 0;
                        break;

                    case ExifOrientation.TopRight:
                        _angle = 90;
                        break;

                    case ExifOrientation.BottomRight:
                        _angle = 180;
                        break;

                    case ExifOrientation.BottomLeft:
                        _angle = 270;
                        break;
                    }

                    Stream capturedImage;
                    if (_angle > 0d)
                    {
                        capturedImage = RotateStream(e.ChosenPhoto, _angle);
                    }
                    else
                    {
                        capturedImage = e.ChosenPhoto;
                    }
                    IMobeelizerFile file = Mobeelizer.CreateFile("photo", capturedImage);
                    this.getPhotoCallback(file);
                    this.getPhotoCallback = null;
                }
                else
                {
                    this.GetPhoto(getPhotoCallback);
                }
            }
        }