Exemplo n.º 1
0
        /// <summary>
        /// Gets the picture media file.
        /// </summary>
        /// <param name="info">The information.</param>
        /// <returns>MediaFile.</returns>
        private void GetPictureMediaFile(NSDictionary info, Action <MediaFile> callback)
        {
            var image = (UIImage)info[UIImagePickerController.OriginalImage];

            var referenceURL = (NSUrl)info[UIImagePickerController.ReferenceUrl];

            if (referenceURL == null) //from camera
            {
                var             metadata = (NSDictionary)info[UIImagePickerController.MediaMetadata];
                ALAssetsLibrary library  = new ALAssetsLibrary();
                library.WriteImageToSavedPhotosAlbum(image.CGImage, metadata, (assetUrl, error) => {
                });
                GetPictureMediaFileWithMetadata(metadata, image, callback);
            }
            else // from albun
            {
                ALAssetsLibrary library = new ALAssetsLibrary();
                library.AssetForUrl(referenceURL, (ALAsset asset) =>
                {
                    ALAssetRepresentation rep = asset.DefaultRepresentation;
                    NSDictionary metadata     = rep.Metadata;
                    var cgimg = rep.GetFullScreenImage();
                    var img   = new UIImage(cgimg);
                    GetPictureMediaFileWithMetadata(metadata, img, callback);
                }, (e) =>
                {
                });
            }
        }
Exemplo n.º 2
0
        public static void setCurrentPhotoToIndex(int index)
        {
            currentAsset = photoAssets [index];
            ALAssetRepresentation rep = currentAsset.RepresentationForUti("public.jpeg");
            CGImage imageRef          = rep.GetFullScreenImage();

            if (imageRef != null)
            {
                currentPhotoImage = UIImage.FromImage(imageRef);
                currentPhotoIndex = index;
            }
        }
Exemplo n.º 3
0
        public static void setCurrentPhotoToIndex(int index)
        {
            currentAsset = photoAssets [index];
            ALAssetRepresentation rep = currentAsset.RepresentationForUti("public.jpeg");

            // image might not be available as a JPEG
            if (rep == null)
            {
                return;
            }
            CGImage imageRef = rep.GetFullScreenImage();

            if (imageRef == null)
            {
                return;
            }
            currentPhotoImage = UIImage.FromImage(imageRef);
            currentPhotoIndex = index;
        }