diff --git a/src/Models/DiffResult.cs b/src/Models/DiffResult.cs index 3cc33f59..64ec2393 100644 --- a/src/Models/DiffResult.cs +++ b/src/Models/DiffResult.cs @@ -570,8 +570,11 @@ namespace SourceGit.Models public Bitmap Old { get; set; } = null; public Bitmap New { get; set; } = null; - public string OldSize => Old != null ? $"{Old.PixelSize.Width} x {Old.PixelSize.Height}" : "0 x 0"; - public string NewSize => New != null ? $"{New.PixelSize.Width} x {New.PixelSize.Height}" : "0 x 0"; + public long OldFileSize { get; set; } = 0; + public long NewFileSize { get; set; } = 0; + + public string OldImageSize => Old != null ? $"{Old.PixelSize.Width} x {Old.PixelSize.Height}" : "0 x 0"; + public string NewImageSize => New != null ? $"{New.PixelSize.Width} x {New.PixelSize.Height}" : "0 x 0"; } public class NoOrEOLChange diff --git a/src/ViewModels/DiffContext.cs b/src/ViewModels/DiffContext.cs index 8a10feab..4ff80c23 100644 --- a/src/ViewModels/DiffContext.cs +++ b/src/ViewModels/DiffContext.cs @@ -157,14 +157,19 @@ namespace SourceGit.ViewModels var imgDiff = new Models.ImageDiff(); if (_option.Revisions.Count == 2) { - imgDiff.Old = BitmapFromRevisionFile(_repo, _option.Revisions[0], oldPath); - imgDiff.New = BitmapFromRevisionFile(_repo, _option.Revisions[1], oldPath); + (imgDiff.Old, imgDiff.OldFileSize) = BitmapFromRevisionFile(_repo, _option.Revisions[0], oldPath); + (imgDiff.New, imgDiff.NewFileSize) = BitmapFromRevisionFile(_repo, _option.Revisions[1], oldPath); } else { var fullPath = Path.Combine(_repo, _option.Path); - imgDiff.Old = BitmapFromRevisionFile(_repo, "HEAD", oldPath); - imgDiff.New = File.Exists(fullPath) ? new Bitmap(fullPath) : null; + (imgDiff.Old, imgDiff.OldFileSize) = BitmapFromRevisionFile(_repo, "HEAD", oldPath); + + if (File.Exists(fullPath)) + { + imgDiff.New = new Bitmap(fullPath); + imgDiff.NewFileSize = new FileInfo(fullPath).Length; + } } rs = imgDiff; } @@ -207,10 +212,11 @@ namespace SourceGit.ViewModels }); } - private Bitmap BitmapFromRevisionFile(string repo, string revision, string file) + private (Bitmap, long) BitmapFromRevisionFile(string repo, string revision, string file) { var stream = Commands.QueryFileContent.Run(repo, revision, file); - return stream.Length > 0 ? new Bitmap(stream) : null; + var size = stream.Length; + return size > 0 ? (new Bitmap(stream), size) : (null, size); } private static readonly HashSet IMG_EXTS = new HashSet() diff --git a/src/Views/DiffView.axaml b/src/Views/DiffView.axaml index 96af72cb..17bba0f3 100644 --- a/src/Views/DiffView.axaml +++ b/src/Views/DiffView.axaml @@ -177,18 +177,22 @@ - - + + - + + + - + - + + +