I need to store a bitmap object in my MAUI.NET application.
To be clear - in my definition: bitmap is a representation of the image by the 2 dimensional array of pixels, that have at least R,G and B value.
In .NET 4.7 it wasn't already such an object, but there was a NuGet System.Drawings.Common that allowed me to use such an object.
How to handle such a situation in MAUI.NET?
edit: Sorry if I wasn't clear. This is my scenario:
I am not about drawing and image in UI.
I want to let user specify path to file and then I need to have a Bitmap of this picture/image, because I need to pass it to different layers/project -> pass it to algorithms with the logic that would process it.
So this would be a code I would do in .NET Framework 4...:
string filepath = someFileSystemDialog.Result;
Bitmap bitmap = new Bitmap(filepath); // here is the problem, in previous .NET there was Bitmap object wchich was perfect, here is lack
Bitmap processedBitmap = MyOtherProjectWithLogicAlgorithms.ProcessAnImage(bitmap);
processedBitmap.Save(finalOutputPath, ImageFormat.Png);
But in Maui.NET from a filedialog I managed to get something like below:
var fileResult = await FilePicker.Default.PickAsync(...);
if(fileResult != null)
{
ImageSource is = ImageSource.FromFile(fileResult.FullPath);
Bitmap bm = ??(is); // how to get Bitmap from an ImageSource ?
MyOtherProjectWithLogicAlgorithms is an other .NET project that (for compatibility would also have .NET 6.0) - I guess this is required to work with MAUI.NET as dependency project.
There is Bitmap but seems that is dedicated only to Android: Android.Graphics.Bitmap - Can I use it in general code for all the platforms?