public static void SerializeDataToAlbum(Texture2D p_texture, string p_fileName) { FixInstanceName(); var v_extension = "." + CrossPickerServices.EncodeOption.ToString().ToLower(); if (!string.IsNullOrEmpty(p_fileName) && !p_fileName.EndsWith(v_extension)) { p_fileName += v_extension; } byte[] v_data = p_texture != null ? (CrossPickerServices.EncodeOption == CrossPickerServices.TextureEncoderEnum.JPG ? p_texture.EncodeToJPG() : p_texture.EncodeToPNG()) : null; NativeGallery.MediaSaveCallback v_mediaSaveDelegate = (error) => { if (string.IsNullOrEmpty(error)) { var v_temporarySavePath = CrossPickerServices.SaveTextureToTemporaryPath(v_data, System.IO.Path.GetFileName(p_fileName)); Instance.NativeImageSaveSuccess(v_temporarySavePath); } else { Instance.NativeImageSaveFailed(); } }; NativeGallery.SaveImageToGallery(v_data, Application.productName, p_fileName, v_mediaSaveDelegate); }
protected virtual void NativeImagePickedEnd(string p_path) { var v_texture = !string.IsNullOrEmpty(p_path)? NativeCamera.LoadImageAtPath(p_path, -1, false) : null; var v_temporarySavePath = CrossPickerServices.SaveTextureToTemporaryPath(v_texture); CrossPickerServices.CallPickerFinishEvent(v_temporarySavePath, v_texture); }
protected virtual void NativeCameraPickedEnd(string p_path, bool p_saveToGallery) { var v_texture = !string.IsNullOrEmpty(p_path) ? NativeGallery.LoadImageAtPath(p_path, CrossPickerServices.MaxImageLoadSize, false, false) : null; if (p_saveToGallery && v_texture != null) { CrossPickerServices.SerializeDataToAlbum(v_texture, System.IO.Path.GetFileNameWithoutExtension(p_path)); } var v_temporarySavePath = CrossPickerServices.SaveTextureToTemporaryPath(v_texture); //CrossPickerServices.GetTemporarySavePath(CrossPickerServices.GetUniqueImgFileName(CrossPickerServices.EncodeOption)); CrossPickerServices.CallPickerFinishEvent(v_temporarySavePath, v_texture); }
public static void SerializeDataToAlbum(Texture2D p_texture, string p_fileName) { FixInstanceName(); var v_extension = "." + CrossPickerServices.EncodeOption.ToString().ToLower(); if (!string.IsNullOrEmpty(p_fileName) && !p_fileName.EndsWith(v_extension)) { p_fileName += v_extension; } byte[] v_data = p_texture != null ? (CrossPickerServices.EncodeOption == CrossPickerServices.TextureEncoderEnum.JPG ? p_texture.EncodeToJPG() : p_texture.EncodeToPNG()) : null; var v_temporarySavePath = CrossPickerServices.SaveTextureToTemporaryPath(v_data, System.IO.Path.GetFileName(p_fileName)); if (!string.IsNullOrEmpty(v_temporarySavePath)) { CrossPickerServices.CallImageSavedSucessEvent(v_temporarySavePath); } else { CrossPickerServices.CallImageSavedFailedEvent(); } }