Reputation: 11
Here this is my code
var stream = new MemoryStream();
await responseStream.CopyToAsync(stream);
stream.Position = 0;
var Result = stream;
byte[] bytes = stream.ToArray();
string Base64 = System.Convert.ToBase64String(bytes);
// get the size of the image
MemoryStream ms = new MemoryStream(bytes);
Image returnImage = Image.FromStream(ms);
Bitmap resizedImage = new(returnImage, new Size(310, 212));
resizedImage.Save(stream, ImageFormat.Jpeg);
VisaItineraryResponse.Pax.ElementAt(paxindex)
.Docs.ElementAt(DocIndex).Base64String = Convert.ToString(resizedImage);
I got an exception while using this code
System.Exception: Failed
System.TypeInitializationException: The type initializer for 'Gdip' threw an exception.
System.PlatformNotSupportedException: System.Drawing.Common is not supported on non-Windows platforms. See https://aka.ms/systemdrawingnonwindows for more information.
Upvotes: 1
Views: 1388
Reputation: 4929
If you click on the provided link in the exception, it says
Because System.Drawing.Common was designed to be a thin wrapper over Windows technologies, its cross-platform implementation is subpar.
Recommended action
To use these APIs for cross-platform apps, migrate to one of the following libraries:
I have used skiasharp and would recommend it. I can't say how that compares to maui graphics.
Upvotes: 1