Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
DubyaDude committed Mar 21, 2024
1 parent f779299 commit 7ed6292
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions Sample.UI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ private async void Forward_Click(object sender, RoutedEventArgs e)

internal static class Helper
{
internal static BitmapImage? GetThumbnail(IRandomAccessStreamReference Thumbnail, bool convertToPng = false)
internal static BitmapImage? GetThumbnail(IRandomAccessStreamReference Thumbnail, bool convertToPng = true)
{
if (Thumbnail == null)
return null;
Expand All @@ -190,15 +190,12 @@ internal static class Helper

if (convertToPng)
{
using (var fileMemoryStream = new System.IO.MemoryStream(thumbnailBytes))
{
Bitmap b = (Bitmap)Bitmap.FromStream(fileMemoryStream);
using (var pngMemoryStream = new System.IO.MemoryStream())
{
b.Save(pngMemoryStream, System.Drawing.Imaging.ImageFormat.Png);
imageBytes = pngMemoryStream.ToArray();
}
}
using var fileMemoryStream = new System.IO.MemoryStream(thumbnailBytes);
Bitmap thumbnailBitmap = (Bitmap)Bitmap.FromStream(fileMemoryStream);

using var pngMemoryStream = new System.IO.MemoryStream();
thumbnailBitmap.Save(pngMemoryStream, System.Drawing.Imaging.ImageFormat.Png);
imageBytes = pngMemoryStream.ToArray();
}

var image = new BitmapImage();
Expand Down

0 comments on commit 7ed6292

Please sign in to comment.