AffdexMe.MainWindow.ConstructImage C# (CSharp) Метод

ConstructImage() приватный Метод

Constructs the bitmap image from byte array.
private ConstructImage ( byte imageData, int width, int height ) : System.Windows.Media.Imaging.BitmapSource
imageData byte The image data.
width int The width.
height int The height.
Результат System.Windows.Media.Imaging.BitmapSource
        private BitmapSource ConstructImage(byte[] imageData, int width, int height)
        {
            try
            {
                if (imageData != null && imageData.Length > 0)
                {
                    var stride = (width * PixelFormats.Bgr24.BitsPerPixel + 7) / 8;
                    var imageSrc = BitmapSource.Create(width, height, 96d, 96d, PixelFormats.Bgr24, null, imageData, stride);
                    return imageSrc;
                }
            }
            catch(Exception ex)
            {
                String message = String.IsNullOrEmpty(ex.Message) ? "AffdexMe error encountered." : ex.Message;
                ShowExceptionAndShutDown(message);
            }

            return null;
        }