-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainPage.xaml.cs
54 lines (45 loc) · 1.46 KB
/
MainPage.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using CoreGraphics;
using Foundation;
using Microsoft.Maui.Storage;
using UIKit;
namespace iOSImageSaveIssue
{
public partial class MainPage : ContentPage
{
int count = 0;
public MainPage()
{
InitializeComponent();
}
private void OnSaveButtonClicked(object sender, EventArgs e)
{
#if IOS
if (this.image != null && this.image.Handler != null && this.image.Handler.PlatformView is UIImageView uiImage)
{
var nativeImage = uiImage.Image;
if (nativeImage == null)
{
return;
}
var formattedImage = nativeImage.AsJPEG();
if (formattedImage == null)
{
return;
}
Stream? stream = formattedImage.AsStream();
if (stream == null || stream == Stream.Null)
{
return;
}
string downloadFilePath = "/Users/syncfusion/Downloads";
string filePath = Path.GetFullPath(Path.Combine(downloadFilePath, "IosImage.jpeg"));
NSData? imageData = NSData.FromStream(stream);
if (imageData != null)
{
imageData.Save(filePath, false, out NSError? nsError);
}
}
#endif
}
}
}