I have a code piece below which creates an IplImage object from a camera and then creates a bitmap using this iplImage.
var iplImage = Globals.ActiveCamera.Acquisition?.IplImage?.ConvertTo(PixelFormatName.BGR8, ConversionMode.Fast);
if (iplImage == null)
{
return;
}
frame = new Bitmap(Convert.ToInt16(iplImage?.Width()), Convert.ToInt16(iplImage?.Height()), Convert.ToInt16(iplImage?.PixelFormat().CalculateStorageSizeOfPixels(iplImage.Width())), System.Drawing.Imaging.PixelFormat.Format24bppRgb, iplImage.Data());
Even, I check for null and return if it is. I still get warning CS8601 when using iplImage.Data().
I’m confused what I am missing at this point.
>Solution :
My suspicion would be that the warning is because
Convert.ToInt16(iplImage?.Width())
has nullable input to Convert.ToInt16. But you know iplImage cannot be null here. So, make it Convert.ToInt16(iplImage.Width()) and Convert.ToInt16(iplImage.Height()) respective.