public static void TakePhotoBig(OnPickPhotoListener listener, ImageResultSize maxSize, string albumName) { AndroidGoodiesActivityClass.CallStatic("prepareToTakeBigPhoto", listener, (int)maxSize, albumName); StartAndroidGoodiesActivity(); }
static void PickImage(int requestCode, ImageResultSize maxSize, bool shouldGenerateThumbnails) { StartAndroidGoodiesActivity(requestCode, intent => { intent.PutExtra(EXTRAS_MAX_SIZE, (int)maxSize); intent.PutExtra(EXTRAS_GENERATE_THUMBNAILS, shouldGenerateThumbnails); }); }
/// <summary> /// Picks the image from gallery. /// </summary> /// <param name="onSuccess">On success callback. Image is received as callback parameter</param> /// <param name="onError">On error callback.</param> /// <param name="maxSize">Max image size. If provided image will be downscaled.</param> /// <param name="shouldGenerateThumbnails">Whether thumbnail images will be generated. Used to show small previews of image.</param> public static void PickImageFromGallery(Action <ImagePickResult> onSuccess, Action <string> onError, ImageResultSize maxSize = ImageResultSize.Original, bool shouldGenerateThumbnails = true) { if (AGUtils.IsNotAndroidCheck()) { return; } Check.Argument.IsNotNull(onSuccess, "onSuccess"); _onSuccessAction = onSuccess; _onCancelAction = onError; AGActivityUtils.PickPhotoFromGallery(maxSize, shouldGenerateThumbnails); }
/// <summary> /// Required permissions: /// <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> /// /// Launches the camera app to take a photo and returns resulting Texture2D in callback. The photo is also saved to the device gallery. /// /// IMPORTANT! : You don't need any permissions to use this method. It works using Android intent. /// </summary> /// <param name="onSuccess">On success callback. Image is received as callback parameter</param> /// <param name="onError">On error/cancel callback.</param> /// <param name="maxSize">Max image size. If provided image will be downscaled.</param> /// <param name="shouldGenerateThumbnails">Whether thumbnail images will be generated. Used to show small previews of image.</param> public static void TakePhoto(Action <ImagePickResult> onSuccess, Action <string> onError, ImageResultSize maxSize = ImageResultSize.Original, bool shouldGenerateThumbnails = true) { if (AGUtils.IsNotAndroidCheck()) { return; } if (onSuccess == null) { throw new ArgumentNullException("onSuccess", "Success callback cannot be null"); } _onSuccessAction = onSuccess; _onCancelAction = onError; AGUtils.RunOnUiThread(() => AGActivityUtils.TakePhoto(maxSize, shouldGenerateThumbnails)); }
/// <summary> /// Required permissions: /// <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> /// /// Launches the camera app to take a photo and returns resulting Texture2D in callback. The photo is also saved to the device gallery. /// /// IMPORTANT! : You don't need any permissions to use this method. It works using Android intent. /// </summary> /// <param name="onSuccess">On success callback. Image is received as callback parameter</param> /// <param name="onCancel">On cancel callback.</param> /// <param name="maxSize">Max image size. If provided image will be downscaled.</param> /// <param name="albumName">Album where photo will be stored.</param> public static void TakePhoto(Action <ImagePickResult> onSuccess, Action onCancel, ImageResultSize maxSize = ImageResultSize.Original, string albumName = DefaultAlbumName) { if (AGUtils.IsNotAndroidCheck()) { return; } if (onSuccess == null) { throw new ArgumentNullException("onSuccess", "Success callback cannot be null"); } var listener = new AGActivityUtils.OnPickPhotoListener(onSuccess, onCancel); AGUtils.RunOnUiThread(() => AGActivityUtils.TakePhotoBig(listener, maxSize, albumName)); }
void TakePhoto() { // Whether to generate thumbnails const bool shouldGenerateThumbnails = false; // if image is larger it will be downscaled to the max size proportionally const ImageResultSize imageResultSize = ImageResultSize.Max1024; AGCamera.TakePhoto( selectedImage => { // Load received image into Texture2D var imageTexture2D = selectedImage.LoadTexture2D(); var msg = string.Format("{0} was taken from camera with size {1}x{2}", selectedImage.DisplayName, imageTexture2D.width, imageTexture2D.height); AGUIMisc.ShowToast(msg); Debug.Log(msg); image.sprite = SpriteFromTex2D(imageTexture2D); // Clean up Resources.UnloadUnusedAssets(); }, error => AGUIMisc.ShowToast("Cancelled taking photo from camera: " + error), imageResultSize, shouldGenerateThumbnails); }
public static void PickPhotoFromGallery(OnPickPhotoListener listener, ImageFormat imageFormat, ImageResultSize maxSize) { AndroidGoodiesActivityClass.CallStatic("prepareToPickPhoto", listener, (int)imageFormat, (int)maxSize); StartAndroidGoodiesActivity(); }
public static void TakePhoto(ImageResultSize maxSize, bool shouldGenerateThumbnails) { PickImage(REQ_CODE_TAKE_PHOTO, maxSize, shouldGenerateThumbnails); }
public static void PickPhotoFromGallery(ImageResultSize maxSize, bool shouldGenerateThumbnails) { PickImage(REQ_CODE_PICK_IMAGE, maxSize, shouldGenerateThumbnails); }
/// <summary> /// Picks the image from gallery. /// </summary> /// <param name="onSuccess">On success callback. Image is received as callback parameter</param> /// <param name="onCancel">On cancel callback.</param> /// <param name="imageFormat">Image format.</param> /// <param name="maxSize">Max image size. If provided image will be downscaled.</param> public static void PickImageFromGallery(Action <ImagePickResult> onSuccess, Action onCancel, ImageFormat imageFormat = ImageFormat.PNG, ImageResultSize maxSize = ImageResultSize.Original) { if (AGUtils.IsNotAndroidCheck()) { return; } if (onSuccess == null) { throw new ArgumentNullException("onSuccess", "Success callback cannot be null"); } AGUtils.RunOnUiThread( () => AGActivityUtils.PickPhotoFromGallery( new AGActivityUtils.OnPickPhotoListener(onSuccess, onCancel), imageFormat, maxSize)); }