private static ImageSource CreateImage(byte[] imageData, int decodePixelWidth, int decodePixelHeight)
{
try
{
if (imageData == null) return null;
BitmapImage result = new BitmapImage();
result.BeginInit();
if (decodePixelWidth > 0)
{
result.DecodePixelWidth = decodePixelWidth;
}
if (decodePixelHeight > 0)
{
result.DecodePixelHeight = decodePixelHeight;
}
result.StreamSource = new MemoryStream(imageData);
result.CreateOptions = BitmapCreateOptions.None;
result.CacheOption = BitmapCacheOption.Default;
result.EndInit();
return result;
}
catch (System.Exception ex1)
{
TaskDialog.Show("Error!", "exception: " + ex1);
}
return null;
}