/// <summary> /// Capture an image from the device camera. /// </summary> /// <param name="maxSize">Max captured media thumbnail size that will be transferred to Unity</param> /// <param name="callback">Operation result callback.</param> public static void CaptureImage(int maxSize, Action <AN_CameraCaptureResult> callback) { var permissions = new[] { AMM_ManifestPermission.CAMERA, AMM_ManifestPermission.READ_EXTERNAL_STORAGE, AMM_ManifestPermission.WRITE_EXTERNAL_STORAGE }; AN_PermissionsUtility.TryToResolvePermission( new [] { AMM_ManifestPermission.READ_EXTERNAL_STORAGE, AMM_ManifestPermission.WRITE_EXTERNAL_STORAGE }, (granted) => { AN_GalleryInternal.PickImageFromGallery(maxSize, AN_GalleryChooseType.CAPTURE_PICTURE, false, (result) => { AN_CameraCaptureResult captureResult; if (result.IsFailed) { captureResult = new AN_CameraCaptureResult(result.Error); } else { captureResult = new AN_CameraCaptureResult(result.Media[0]); } callback.Invoke(captureResult); }); }); }
/// <summary> /// Starts pick media from a gallery flow. /// </summary> /// <param name="callback"></param> public void Show(Action <AN_GalleryPickResult> callback) { AN_PermissionsUtility.TryToResolvePermission( new [] { AMM_ManifestPermission.READ_EXTERNAL_STORAGE, AMM_ManifestPermission.WRITE_EXTERNAL_STORAGE }, (granted) => { var type = AN_GalleryChooseType.PICK_PICTURE; if (m_types.Contains(AN_MediaType.Image) && m_types.Contains(AN_MediaType.Video)) { type = AN_GalleryChooseType.PICK_PICTURE_OR_VIDEO; } else { if (m_types.Contains(AN_MediaType.Video)) { type = AN_GalleryChooseType.PICK_VIDEO; } } AN_GalleryInternal.PickImageFromGallery(m_maxSize, type, m_allowMultiSelect, callback); }); }
/// <summary> /// Saves images to the device gallery. /// </summary> /// <param name="image">Image that needs to be saved</param> /// <param name="name">Image name. If image with the same name already exists, it will be replaced</param> /// <param name="appDirectory">app directory name</param> /// <param name="format">save format</param> /// <param name="callback">Operation callback.</param> public static void SaveImageToGallery(Texture2D image, string name, string appDirectory, AN_GalleryFormat format, Action <AN_GallerySaveResult> callback) { AN_GalleryInternal.SaveImageToGallery(image, name, appDirectory, format, callback); }
/// <summary> /// All media that was captured using device camera on the device storage. /// Since Unity part will only get media thumbnails as texture2D, you might want to get original captured media /// using the <see cref="Gallery.AN_Media.Path"/>. /// Once you've complete operations with media, you may removed all captured media files using this method. /// </summary> public static void DeleteCapturedMedia() { AN_GalleryInternal.DeleteChooserTmpDirectory(); }