How do I get a stream or byte[] from a MauiImage?

Paul Mariotti 11 Reputation points
2022-10-29T11:16:22.003+00:00

I am developing a multiplatform app using NetMaui.
I have a large number of image files in the /Resources/Images folder, and all of the files have a build type of MauiImage.
I have no problem getting the images displayed on phone screens in the proper resolution and size, but I also need to use (as input to an installed library) these files as either a Steam or a byte[].
This would be very easy if the files had a build type of EmbeddedResource, but I cannot find any way to convert them to stream or byte[] if I keep the build type as MauiImage.
It would be impossible to duplicate the files as EmbeddedResources since this would make the app extremely large.
Does anybody out there know how this problem cold be solved?

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,414 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.