Crop transparent edges from icons then center it

This commit is contained in:
Jaex 2019-05-15 01:53:14 +03:00
parent 791f9fb693
commit 2c01aea2bc

View file

@ -159,6 +159,8 @@ public void UpdateThumbnail()
{ {
string filePath = Task.Info.FilePath; string filePath = Task.Info.FilePath;
if (!string.IsNullOrEmpty(filePath))
{
try try
{ {
if (Helpers.IsImageFile(filePath)) if (Helpers.IsImageFile(filePath))
@ -178,9 +180,10 @@ public void UpdateThumbnail()
else else
{ {
using (Icon icon = NativeMethods.GetJumboFileIcon(filePath)) using (Icon icon = NativeMethods.GetJumboFileIcon(filePath))
using (Image img = icon.ToBitmap()) using (Bitmap bmp = icon.ToBitmap())
using (Image img = ImageHelpers.AutoCropTransparent(bmp))
{ {
ThumbnailImage = ImageHelpers.ResizeImage(img, ThumbnailSize, false); ThumbnailImage = ImageHelpers.ResizeImage(img, ThumbnailSize, false, true);
pbThumbnail.Image = ThumbnailImage; pbThumbnail.Image = ThumbnailImage;
pbThumbnail.Cursor = pThumbnail.Cursor = Cursors.Default; pbThumbnail.Cursor = pThumbnail.Cursor = Cursors.Default;
} }
@ -192,6 +195,7 @@ public void UpdateThumbnail()
} }
} }
} }
}
public void UpdateProgress() public void UpdateProgress()
{ {