gpt4 book ai didi

c# - 将 UIImage 转换为字节数组

转载 作者:行者123 更新时间:2023-11-30 11:14:22 24 4
gpt4 key购买 nike

我需要将 UIImage 转换为字节数组。我正在使用 Xamarin 的 Visual Studio 插件来生成 iOS 应用程序。

下面的代码获取图像,但我需要将其作为字节数组而不是 UIImage 通过服务堆栈发送。

        var signatureView = new SignaturePad.SignaturePadView(new RectangleF(10, 660, 300, 150));
signatureView.BackgroundColor = UIColor.White;
this.View.AddSubview(signatureView);
UIImage signatureImage = signatureView.GetImage();

最佳答案

无耻地窃取ChrisNTR

using (NSData imageData = image.AsPNG()) {
Byte[] myByteArray = new Byte[imageData.Length];
System.Runtime.InteropServices.Marshal.Copy(imageData.Bytes, myByteArray, 0, Convert.ToInt32(imageData.Length));
}

关于c# - 将 UIImage 转换为字节数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51886268/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com