コード例 #1
0
ファイル: IOSDeviceGallery.cs プロジェクト: artemy0/Quiz
        public void SaveImage(Texture2D image, string name, ImageFormat format = ImageFormat.JPG, Action <string> callback = null)
        {
            callback = callback == null ? null : RuntimeHelper.ToMainThread(callback);

            if (image == null)
            {
                if (callback != null)
                {
                    callback("Can't save a null image.");
                }

                return;
            }

            byte[]  rawImage = TextureUtilities.EncodeAsByteArray(image, format);
            NSData  data     = NSData.DataWithBytesNoCopy(rawImage, (uint)rawImage.Length);
            UIImage uiImage  = UIImage.ImageWithData(data);

            UIFunctions.UIImageWriteToSavedPhotosAlbum(uiImage, (savedImage, nsError) =>
            {
                if (callback != null)
                {
                    callback(nsError != null ? nsError.LocalizedDescription : null);
                }
            });
        }