I got this code in my Xamarin app (API 28):
I tried to find a way to convert a bitmap to a graphic object (https://learn.microsoft.com/en-us/dotnet/api/system.drawing.graphics?view=dotnet-plat-ext-3.1), with the goal to use the InterpolationMode and to apply the filter, and then to revert the change, but I failed to find a single example on how to do it.
I found this: Convert graphics object to bitmap object But it is not what I am looking for, because, I got this code:
private Android.Graphics.Bitmap GetBitmap(Drawable d, System.Drawing.Size? bounds)
{
...some code regarding width and height, and then
var bd = d as BitmapDrawable;
if (bd != null)
{
Android.Graphics.Bitmap src = bd.Bitmap;
if (width == src.Width && height == src.Height)
{
return src;
}
else
{
Graphics myGraphics = Graphics.FromImage(src); // here is the problem
// USE G TO SET InterpolationMode
// convert resulting G somehow back to Android.Graphics.Bitmap, and return it insted of the bottom line
return Android.Graphics.Bitmap.CreateScaledBitmap(src, width, height, true);
}
}
}
Error code:
Cannot convert from Android.Graphics.Bitmap to System.Drawing.Bitmap
I need some suggestions on how to solve this, any help will be much appreciated.
Thank you for your time.