Skip to content

Commit 70b2855

Browse files
committed
Update
1 parent 2eac6ad commit 70b2855

File tree

1 file changed

+12
-23
lines changed

1 file changed

+12
-23
lines changed

QRCoder/Base64QRCode.cs

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -63,33 +63,22 @@ public string GetGraphic(int pixelsPerModule, Color darkColor, Color lightColor,
6363
}
6464

6565
#if NETFRAMEWORK || NETSTANDARD2_0 || NET5_0 || NET6_0_WINDOWS
66-
if (
67-
#if NET6_0_OR_GREATER
68-
RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
69-
#else
70-
true
71-
#endif
72-
)
73-
{
74-
var qr = new QRCode(QrCodeData);
75-
var base64 = string.Empty;
76-
using (Bitmap bmp = qr.GetGraphic(pixelsPerModule, darkColor, lightColor, drawQuietZones))
77-
{
78-
base64 = BitmapToBase64(bmp, imgType);
79-
}
80-
return base64;
81-
}
82-
else
66+
#pragma warning disable CA1416 // Validate platform compatibility
67+
var qr = new QRCode(QrCodeData);
68+
var base64 = string.Empty;
69+
using (Bitmap bmp = qr.GetGraphic(pixelsPerModule, darkColor, lightColor, drawQuietZones))
8370
{
84-
throw new PlatformNotSupportedException("The specified image type is not supported on this platform.");
71+
base64 = BitmapToBase64(bmp, imgType);
8572
}
73+
return base64;
74+
#pragma warning restore CA1416 // Validate platform compatibility
8675
#else
87-
throw new PlatformNotSupportedException("The specified image type is not supported on this platform.");
76+
throw new PlatformNotSupportedException("Only the PNG image type is supported on this platform.");
8877
#endif
8978
}
9079

9180
#if NETFRAMEWORK || NETSTANDARD2_0 || NET5_0 || NET6_0_WINDOWS
92-
#if NET6_0_WINDOWS
81+
#if NET6_0_OR_GREATER
9382
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
9483
#endif
9584
public string GetGraphic(int pixelsPerModule, Color darkColor, Color lightColor, Bitmap icon, int iconSizePercent = 15, int iconBorderWidth = 6, bool drawQuietZones = true, ImageType imgType = ImageType.Png)
@@ -105,7 +94,7 @@ public string GetGraphic(int pixelsPerModule, Color darkColor, Color lightColor,
10594
#endif
10695

10796
#if NETFRAMEWORK || NETSTANDARD2_0 || NET5_0 || NET6_0_WINDOWS
108-
#if NET6_0_WINDOWS
97+
#if NET6_0_OR_GREATER
10998
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
11099
#endif
111100
private string BitmapToBase64(Bitmap bmp, ImageType imgType)
@@ -137,11 +126,11 @@ private string BitmapToBase64(Bitmap bmp, ImageType imgType)
137126

138127
public enum ImageType
139128
{
140-
#if NET6_0_WINDOWS
129+
#if NET6_0_OR_GREATER
141130
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
142131
#endif
143132
Gif,
144-
#if NET6_0_WINDOWS
133+
#if NET6_0_OR_GREATER
145134
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
146135
#endif
147136
Jpeg,

0 commit comments

Comments
 (0)