mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
Fix PVS high issues
This commit is contained in:
parent
74b9de085e
commit
20c83136a9
8 changed files with 22 additions and 35 deletions
|
@ -284,12 +284,7 @@ private static Image GetImageAlternative()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Image img = GetDIBImage(ms);
|
return GetDIBImage(ms);
|
||||||
|
|
||||||
if (img != null)
|
|
||||||
{
|
|
||||||
return img;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -814,27 +814,21 @@ public static bool IsImageTransparent(Bitmap bmp)
|
||||||
|
|
||||||
public static bool AddMetadata(Image img, int id, string text)
|
public static bool AddMetadata(Image img, int id, string text)
|
||||||
{
|
{
|
||||||
PropertyItem pi;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pi = (PropertyItem)typeof(PropertyItem).GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[] { }, null).Invoke(null);
|
PropertyItem pi = (PropertyItem)typeof(PropertyItem).GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[] { }, null).Invoke(null);
|
||||||
pi.Id = id;
|
pi.Id = id;
|
||||||
pi.Len = text.Length + 1;
|
pi.Len = text.Length + 1;
|
||||||
pi.Type = 2;
|
pi.Type = 2;
|
||||||
byte[] bytesText = Encoding.ASCII.GetBytes(text + " ");
|
byte[] bytesText = Encoding.ASCII.GetBytes(text + " ");
|
||||||
bytesText[bytesText.Length - 1] = 0;
|
bytesText[bytesText.Length - 1] = 0;
|
||||||
pi.Value = bytesText;
|
pi.Value = bytesText;
|
||||||
|
img.SetPropertyItem(pi);
|
||||||
if (pi != null)
|
return true;
|
||||||
{
|
|
||||||
img.SetPropertyItem(pi);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
DebugHelper.WriteException(e, "Reflection failed.");
|
DebugHelper.WriteException(e, "AddMetadata reflection failed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -1142,7 +1136,7 @@ public static void Pixelate(Bitmap bmp, int pixelSize)
|
||||||
{
|
{
|
||||||
ColorBgra color = unsafeBitmap.GetPixel(x2, y2);
|
ColorBgra color = unsafeBitmap.GetPixel(x2, y2);
|
||||||
|
|
||||||
float pixelWeight = (float)color.Alpha / 255;
|
float pixelWeight = color.Alpha / 255f;
|
||||||
|
|
||||||
r += color.Red * pixelWeight;
|
r += color.Red * pixelWeight;
|
||||||
g += color.Green * pixelWeight;
|
g += color.Green * pixelWeight;
|
||||||
|
|
|
@ -203,13 +203,14 @@ private void LoadImageUploaderSettings()
|
||||||
if (OAuthInfo.CheckOAuth(Config.PhotobucketOAuthInfo))
|
if (OAuthInfo.CheckOAuth(Config.PhotobucketOAuthInfo))
|
||||||
{
|
{
|
||||||
lblPhotobucketAccountStatus.Text = Resources.UploadersConfigForm_Login_successful;
|
lblPhotobucketAccountStatus.Text = Resources.UploadersConfigForm_Login_successful;
|
||||||
txtPhotobucketDefaultAlbumName.Text = Config.PhotobucketAccountInfo.AlbumID;
|
|
||||||
lblPhotobucketParentAlbumPath.Text = Resources.UploadersConfigForm_LoadSettings_Parent_album_path_e_g_ + " " +
|
|
||||||
Config.PhotobucketAccountInfo.AlbumID + "/Personal/" + DateTime.Now.Year;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.PhotobucketAccountInfo != null)
|
if (Config.PhotobucketAccountInfo != null)
|
||||||
{
|
{
|
||||||
|
txtPhotobucketDefaultAlbumName.Text = Config.PhotobucketAccountInfo.AlbumID;
|
||||||
|
lblPhotobucketParentAlbumPath.Text = Resources.UploadersConfigForm_LoadSettings_Parent_album_path_e_g_ + " " +
|
||||||
|
Config.PhotobucketAccountInfo.AlbumID + "/Personal/" + DateTime.Now.Year;
|
||||||
|
|
||||||
cboPhotobucketAlbumPaths.Items.Clear();
|
cboPhotobucketAlbumPaths.Items.Clear();
|
||||||
|
|
||||||
if (Config.PhotobucketAccountInfo.AlbumList.Count > 0)
|
if (Config.PhotobucketAccountInfo.AlbumList.Count > 0)
|
||||||
|
|
|
@ -129,9 +129,10 @@ public override UploadResult Upload(Stream stream, string fileName)
|
||||||
{
|
{
|
||||||
string photoid = xele.Value;
|
string photoid = xele.Value;
|
||||||
FlickrPhotosGetSizesResponse photos = PhotosGetSizes(photoid);
|
FlickrPhotosGetSizesResponse photos = PhotosGetSizes(photoid);
|
||||||
FlickrPhotosGetSizesSize photo = photos?.sizes?.size?[photos.sizes.size.Length - 1];
|
if (photos != null && photos.sizes != null && photos.sizes.size != null && photos.sizes.size.Length > 0)
|
||||||
if (photo != null)
|
|
||||||
{
|
{
|
||||||
|
FlickrPhotosGetSizesSize photo = photos.sizes.size[photos.sizes.size.Length - 1];
|
||||||
|
|
||||||
if (Settings.DirectLink)
|
if (Settings.DirectLink)
|
||||||
{
|
{
|
||||||
result.URL = photo.source;
|
result.URL = photo.source;
|
||||||
|
|
|
@ -462,15 +462,11 @@ private void PbThumbnail_MouseMove(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
if (Task.Info != null && !string.IsNullOrEmpty(Task.Info.FilePath) && File.Exists(Task.Info.FilePath))
|
if (Task.Info != null && !string.IsNullOrEmpty(Task.Info.FilePath) && File.Exists(Task.Info.FilePath))
|
||||||
{
|
{
|
||||||
|
Program.MainForm.AllowDrop = false;
|
||||||
IDataObject dataObject = new DataObject(DataFormats.FileDrop, new string[] { Task.Info.FilePath });
|
IDataObject dataObject = new DataObject(DataFormats.FileDrop, new string[] { Task.Info.FilePath });
|
||||||
|
dragBoxFromMouseDown = Rectangle.Empty;
|
||||||
if (dataObject != null)
|
pbThumbnail.DoDragDrop(dataObject, DragDropEffects.Copy | DragDropEffects.Move);
|
||||||
{
|
Program.MainForm.AllowDrop = true;
|
||||||
Program.MainForm.AllowDrop = false;
|
|
||||||
dragBoxFromMouseDown = Rectangle.Empty;
|
|
||||||
pbThumbnail.DoDragDrop(dataObject, DragDropEffects.Copy | DragDropEffects.Move);
|
|
||||||
Program.MainForm.AllowDrop = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -152,7 +152,7 @@ private void btnCopyLink_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
url = lvClipboardFormats.Items[0].SubItems[1].Text;
|
url = lvClipboardFormats.Items[0].SubItems[1].Text;
|
||||||
}
|
}
|
||||||
else if (lvClipboardFormats.SelectedItems.Count > 0)
|
else
|
||||||
{
|
{
|
||||||
url = lvClipboardFormats.SelectedItems[0].SubItems[1].Text;
|
url = lvClipboardFormats.SelectedItems[0].SubItems[1].Text;
|
||||||
}
|
}
|
||||||
|
|
|
@ -658,8 +658,8 @@ public static Icon GetProgressIcon(int percentage)
|
||||||
using (Font font = new Font("Arial", 10))
|
using (Font font = new Font("Arial", 10))
|
||||||
using (StringFormat sf = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center })
|
using (StringFormat sf = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center })
|
||||||
{
|
{
|
||||||
g.DrawString(percentage.ToString(), font, Brushes.Black, size.Width / 2, size.Height / 2, sf);
|
g.DrawString(percentage.ToString(), font, Brushes.Black, size.Width / 2f, size.Height / 2f, sf);
|
||||||
g.DrawString(percentage.ToString(), font, Brushes.White, size.Width / 2, (size.Height / 2) - 1, sf);
|
g.DrawString(percentage.ToString(), font, Brushes.White, size.Width / 2f, (size.Height / 2f) - 1, sf);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Icon.FromHandle(bmp.GetHicon());
|
return Icon.FromHandle(bmp.GetHicon());
|
||||||
|
|
|
@ -265,10 +265,10 @@ private static void Task_TaskCompleted(WorkerTask task)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
task.KeepImage = false;
|
|
||||||
|
|
||||||
if (task != null)
|
if (task != null)
|
||||||
{
|
{
|
||||||
|
task.KeepImage = false;
|
||||||
|
|
||||||
if (task.RequestSettingUpdate)
|
if (task.RequestSettingUpdate)
|
||||||
{
|
{
|
||||||
Program.MainForm.UpdateCheckStates();
|
Program.MainForm.UpdateCheckStates();
|
||||||
|
|
Loading…
Reference in a new issue