Skip to content

Commit 075a1a3

Browse files
committed
Adjust Preview area Size / Add Source Resize Logic
1 parent 4c846e2 commit 075a1a3

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

Flow.Launcher.Infrastructure/Image/ImageLoader.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Concurrent;
33
using System.Collections.Generic;
4+
using System.Diagnostics;
45
using System.IO;
56
using System.Linq;
67
using System.Net;
@@ -288,9 +289,33 @@ private static BitmapImage LoadFullImage(string path)
288289
BitmapImage image = new BitmapImage();
289290
image.BeginInit();
290291
image.CacheOption = BitmapCacheOption.OnLoad;
291-
image.UriSource = new Uri(path);
292+
image.UriSource = new Uri(path);
292293
image.CreateOptions = BitmapCreateOptions.IgnoreColorProfile;
293294
image.EndInit();
295+
296+
if (image.PixelWidth > 320)
297+
{
298+
BitmapImage resizedWidth = new BitmapImage();
299+
resizedWidth.BeginInit();
300+
resizedWidth.CacheOption = BitmapCacheOption.OnLoad;
301+
resizedWidth.UriSource = new Uri(path);
302+
resizedWidth.CreateOptions = BitmapCreateOptions.IgnoreColorProfile;
303+
resizedWidth.DecodePixelWidth = 320;
304+
resizedWidth.EndInit();
305+
306+
if (resizedWidth.PixelHeight > 320)
307+
{
308+
BitmapImage resizedHeight = new BitmapImage();
309+
resizedHeight.BeginInit();
310+
resizedHeight.CacheOption = BitmapCacheOption.OnLoad;
311+
resizedHeight.UriSource = new Uri(path);
312+
resizedHeight.CreateOptions = BitmapCreateOptions.IgnoreColorProfile;
313+
resizedHeight.DecodePixelHeight = 320;
314+
resizedHeight.EndInit();
315+
return resizedHeight;
316+
}
317+
return resizedWidth;
318+
}
294319
return image;
295320
}
296321
}

Flow.Launcher/MainWindow.xaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,10 @@
326326
<Grid>
327327
<Grid.ColumnDefinitions>
328328
<ColumnDefinition Width="*" />
329-
<ColumnDefinition Width="0.75*" MinWidth="250" />
329+
<ColumnDefinition
330+
Width="0.85*"
331+
MinWidth="244"
332+
MaxWidth="340" />
330333
</Grid.ColumnDefinitions>
331334
<StackPanel
332335
x:Name="ResultArea"
@@ -415,7 +418,7 @@
415418
<Image
416419
x:Name="PreviewImageIcon"
417420
Grid.Row="0"
418-
MaxHeight="400"
421+
MaxHeight="320"
419422
Margin="0,16,0,0"
420423
HorizontalAlignment="Center"
421424
Source="{Binding PreviewImage}"

0 commit comments

Comments
 (0)