diff --git a/src/ViewModels/CommitDetail.cs b/src/ViewModels/CommitDetail.cs
index 55618897..25c0cbd5 100644
--- a/src/ViewModels/CommitDetail.cs
+++ b/src/ViewModels/CommitDetail.cs
@@ -230,9 +230,23 @@ namespace SourceGit.ViewModels
var matchLFS = REG_LFS_FORMAT().Match(content);
if (matchLFS.Success)
{
- var obj = new Models.RevisionLFSObject() { Object = new Models.LFSObject() };
- obj.Object.Oid = matchLFS.Groups[1].Value;
- obj.Object.Size = long.Parse(matchLFS.Groups[2].Value);
+ var lfsObj = new Models.RevisionLFSObject() { Object = new Models.LFSObject
+ {
+ Oid = matchLFS.Groups[1].Value,
+ Size = long.Parse(matchLFS.Groups[2].Value)
+ }};
+
+ var ext = Path.GetExtension(file.Path);
+ var obj = null as object;
+ if (IMG_EXTS.Contains(ext))
+ {
+ var imageType = ext!.Substring(1).ToUpper(CultureInfo.CurrentCulture);
+ obj = new RevisionLFSImageObject(_repo.FullPath, lfsObj, imageType);
+ }
+ else
+ {
+ obj = lfsObj;
+ }
Dispatcher.UIThread.Invoke(() => ViewRevisionFileContent = obj);
}
else
diff --git a/src/ViewModels/FileHistories.cs b/src/ViewModels/FileHistories.cs
index 0e474af2..114af2de 100644
--- a/src/ViewModels/FileHistories.cs
+++ b/src/ViewModels/FileHistories.cs
@@ -103,10 +103,23 @@ namespace SourceGit.ViewModels
var matchLFS = REG_LFS_FORMAT().Match(content);
if (matchLFS.Success)
{
- var lfs = new Models.RevisionLFSObject() { Object = new() };
- lfs.Object.Oid = matchLFS.Groups[1].Value;
- lfs.Object.Size = long.Parse(matchLFS.Groups[2].Value);
- Dispatcher.UIThread.Invoke(() => ViewContent = new FileHistoriesRevisionFile(_file, lfs));
+ var lfs = new Models.RevisionLFSObject() { Object = new Models.LFSObject {
+ Oid = matchLFS.Groups[1].Value,
+ Size = long.Parse(matchLFS.Groups[2].Value)
+ } };
+
+ var ext = Path.GetExtension(_file);
+ var obj = null as object;
+ if (IMG_EXTS.Contains(ext))
+ {
+ var imageType = Path.GetExtension(_file)!.TrimStart('.').ToUpper(CultureInfo.CurrentCulture);
+ obj = new RevisionLFSImageObject(_repo.FullPath, lfs, ext);
+ }
+ else
+ {
+ obj = lfs;
+ }
+ Dispatcher.UIThread.Invoke(() => ViewContent = new FileHistoriesRevisionFile(_file, obj));
}
else
{
diff --git a/src/ViewModels/LFSImageDiff.cs b/src/ViewModels/LFSImageDiff.cs
index 655004a6..2db78aff 100644
--- a/src/ViewModels/LFSImageDiff.cs
+++ b/src/ViewModels/LFSImageDiff.cs
@@ -34,7 +34,7 @@ namespace SourceGit.ViewModels
});
}
- private (Bitmap, long) BitmapFromLFSObject(string repo, Models.LFSObject lfs)
+ public static (Bitmap, long) BitmapFromLFSObject(string repo, Models.LFSObject lfs)
{
if (string.IsNullOrEmpty(lfs.Oid) || lfs.Size == 0)
return (null, 0);
diff --git a/src/ViewModels/RevisionLFSImageObject.cs b/src/ViewModels/RevisionLFSImageObject.cs
new file mode 100644
index 00000000..351cd438
--- /dev/null
+++ b/src/ViewModels/RevisionLFSImageObject.cs
@@ -0,0 +1,38 @@
+using System.Threading.Tasks;
+
+using Avalonia.Threading;
+
+using CommunityToolkit.Mvvm.ComponentModel;
+
+namespace SourceGit.ViewModels
+{
+ public class RevisionLFSImageObject : ObservableObject
+ {
+ public Models.RevisionLFSObject LFS
+ {
+ get;
+ }
+
+ public Models.RevisionImageFile Image
+ {
+ get => _image;
+ private set => SetProperty(ref _image, value);
+ }
+
+ public RevisionLFSImageObject(string repo, Models.RevisionLFSObject lfs, string ext)
+ {
+ LFS = lfs;
+ Task.Run(() =>
+ {
+ var img = new Models.RevisionImageFile
+ {
+ ImageType = ext
+ };
+ (img.Image, img.FileSize) = SourceGit.ViewModels.LFSImageDiff.BitmapFromLFSObject(repo, LFS.Object);
+ Dispatcher.UIThread.Invoke(() => Image = img);
+ });
+ }
+
+ private Models.RevisionImageFile _image;
+ }
+}
diff --git a/src/Views/RevisionFileContentViewer.axaml b/src/Views/RevisionFileContentViewer.axaml
index 86393316..bd96fb2c 100644
--- a/src/Views/RevisionFileContentViewer.axaml
+++ b/src/Views/RevisionFileContentViewer.axaml
@@ -49,15 +49,59 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Views/RevisionFileLFSContentViewer.axaml b/src/Views/RevisionFileLFSContentViewer.axaml
new file mode 100644
index 00000000..08c94805
--- /dev/null
+++ b/src/Views/RevisionFileLFSContentViewer.axaml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Views/RevisionFileLFSContentViewer.axaml.cs b/src/Views/RevisionFileLFSContentViewer.axaml.cs
new file mode 100644
index 00000000..787b61b2
--- /dev/null
+++ b/src/Views/RevisionFileLFSContentViewer.axaml.cs
@@ -0,0 +1,12 @@
+using Avalonia.Controls;
+
+namespace SourceGit.Views
+{
+ public partial class RevisionFileLFSContentViewer : UserControl
+ {
+ public RevisionFileLFSContentViewer()
+ {
+ InitializeComponent();
+ }
+ }
+}