Bug fix QRCodeHelper

pull/5865/head
2dust 1 month ago
parent 055cd62dd8
commit fe3836be14

@ -1,4 +1,5 @@
using System.Drawing;
using System.Collections;
using System.Drawing;
using System.IO;
using System.Windows;
using System.Windows.Interop;
@ -7,9 +8,6 @@ using System.Windows.Media.Imaging;
namespace v2rayN
{
/// <summary>
/// 含有QR码的描述类和包装编码和渲染
/// </summary>
public class QRCodeHelper
{
public static ImageSource? GetQRCode(string? strContent)
@ -62,21 +60,14 @@ namespace v2rayN
y = 96 / g.DpiY;
}
private static ImageSource ByteToImage(byte[] imageData)
private static ImageSource? ByteToImage(IEnumerable imageData)
{
BitmapImage biImg = new();
using MemoryStream ms = new(imageData);
biImg.BeginInit();
biImg.StreamSource = ms;
biImg.EndInit();
return biImg as ImageSource;
return new ImageSourceConverter().ConvertFrom(imageData) as BitmapSource;
}
private static byte[]? ImageToByte(Image img)
{
var converter = new ImageConverter();
return converter.ConvertTo(img, typeof(byte[])) as byte[];
return new ImageConverter().ConvertTo(img, typeof(byte[])) as byte[];
}
}
}
Loading…
Cancel
Save