mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-02 18:26:27 +13:00
Crop transparent edges from icons then center it
This commit is contained in:
parent
791f9fb693
commit
2c01aea2bc
1 changed files with 24 additions and 20 deletions
|
@ -159,37 +159,41 @@ public void UpdateThumbnail()
|
||||||
{
|
{
|
||||||
string filePath = Task.Info.FilePath;
|
string filePath = Task.Info.FilePath;
|
||||||
|
|
||||||
try
|
if (!string.IsNullOrEmpty(filePath))
|
||||||
{
|
{
|
||||||
if (Helpers.IsImageFile(filePath))
|
try
|
||||||
{
|
{
|
||||||
using (Image img = ImageHelpers.LoadImage(filePath))
|
if (Helpers.IsImageFile(filePath))
|
||||||
{
|
{
|
||||||
if (img != null)
|
using (Image img = ImageHelpers.LoadImage(filePath))
|
||||||
{
|
{
|
||||||
//ThumbnailImage = ImageHelpers.CreateThumbnail(img, ThumbnailSize.Width, ThumbnailSize.Height);
|
if (img != null)
|
||||||
ThumbnailImage = ImageHelpers.ResizeImage(img, ThumbnailSize, false);
|
{
|
||||||
|
//ThumbnailImage = ImageHelpers.CreateThumbnail(img, ThumbnailSize.Width, ThumbnailSize.Height);
|
||||||
|
ThumbnailImage = ImageHelpers.ResizeImage(img, ThumbnailSize, false);
|
||||||
|
pbThumbnail.Image = ThumbnailImage;
|
||||||
|
ThumbnailSourceFilePath = filePath;
|
||||||
|
pbThumbnail.Cursor = pThumbnail.Cursor = Cursors.Hand;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
using (Icon icon = NativeMethods.GetJumboFileIcon(filePath))
|
||||||
|
using (Bitmap bmp = icon.ToBitmap())
|
||||||
|
using (Image img = ImageHelpers.AutoCropTransparent(bmp))
|
||||||
|
{
|
||||||
|
ThumbnailImage = ImageHelpers.ResizeImage(img, ThumbnailSize, false, true);
|
||||||
pbThumbnail.Image = ThumbnailImage;
|
pbThumbnail.Image = ThumbnailImage;
|
||||||
ThumbnailSourceFilePath = filePath;
|
pbThumbnail.Cursor = pThumbnail.Cursor = Cursors.Default;
|
||||||
pbThumbnail.Cursor = pThumbnail.Cursor = Cursors.Hand;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
using (Icon icon = NativeMethods.GetJumboFileIcon(filePath))
|
DebugHelper.WriteException(e);
|
||||||
using (Image img = icon.ToBitmap())
|
|
||||||
{
|
|
||||||
ThumbnailImage = ImageHelpers.ResizeImage(img, ThumbnailSize, false);
|
|
||||||
pbThumbnail.Image = ThumbnailImage;
|
|
||||||
pbThumbnail.Cursor = pThumbnail.Cursor = Cursors.Default;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
DebugHelper.WriteException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue