@@ -63,33 +63,22 @@ public string GetGraphic(int pixelsPerModule, Color darkColor, Color lightColor,
63
63
}
64
64
65
65
#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 ) )
83
70
{
84
- throw new PlatformNotSupportedException ( "The specified image type is not supported on this platform." ) ;
71
+ base64 = BitmapToBase64 ( bmp , imgType ) ;
85
72
}
73
+ return base64 ;
74
+ #pragma warning restore CA1416 // Validate platform compatibility
86
75
#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." ) ;
88
77
#endif
89
78
}
90
79
91
80
#if NETFRAMEWORK || NETSTANDARD2_0 || NET5_0 || NET6_0_WINDOWS
92
- #if NET6_0_WINDOWS
81
+ #if NET6_0_OR_GREATER
93
82
[ System . Runtime . Versioning . SupportedOSPlatform ( "windows" ) ]
94
83
#endif
95
84
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,
105
94
#endif
106
95
107
96
#if NETFRAMEWORK || NETSTANDARD2_0 || NET5_0 || NET6_0_WINDOWS
108
- #if NET6_0_WINDOWS
97
+ #if NET6_0_OR_GREATER
109
98
[ System . Runtime . Versioning . SupportedOSPlatform ( "windows" ) ]
110
99
#endif
111
100
private string BitmapToBase64 ( Bitmap bmp , ImageType imgType )
@@ -137,11 +126,11 @@ private string BitmapToBase64(Bitmap bmp, ImageType imgType)
137
126
138
127
public enum ImageType
139
128
{
140
- #if NET6_0_WINDOWS
129
+ #if NET6_0_OR_GREATER
141
130
[ System . Runtime . Versioning . SupportedOSPlatform ( "windows" ) ]
142
131
#endif
143
132
Gif ,
144
- #if NET6_0_WINDOWS
133
+ #if NET6_0_OR_GREATER
145
134
[ System . Runtime . Versioning . SupportedOSPlatform ( "windows" ) ]
146
135
#endif
147
136
Jpeg ,
0 commit comments