mirror of
https://github.com/greenshot/greenshot
synced 2025-08-14 02:37:03 -07:00
Untested performance improvements with uploads, in short the image is directly stored to the upload stream instead of writing a stream to a byte[]. Expecting a small performance improvement, and a lot less memory usage while uploading.
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2125 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
c983567827
commit
abe79e65e9
6 changed files with 230 additions and 182 deletions
|
@ -110,37 +110,34 @@ namespace GreenshotPhotobucketPlugin {
|
|||
/// <returns>true if the upload succeeded</returns>
|
||||
public bool Upload(ICaptureDetails captureDetails, Image image, out string uploadURL) {
|
||||
OutputSettings outputSettings = new OutputSettings(config.UploadFormat, config.UploadJpegQuality, config.UploadReduceColors);
|
||||
using (MemoryStream stream = new MemoryStream()) {
|
||||
ImageOutput.SaveToStream(image, stream, outputSettings);
|
||||
try {
|
||||
string filename = Path.GetFileName(FilenameHelper.GetFilename(config.UploadFormat, captureDetails));
|
||||
PhotobucketInfo photobucketInfo = null;
|
||||
try {
|
||||
string filename = Path.GetFileName(FilenameHelper.GetFilename(config.UploadFormat, captureDetails));
|
||||
PhotobucketInfo photobucketInfo = null;
|
||||
|
||||
// Run upload in the background
|
||||
new PleaseWaitForm().ShowAndWait(Attributes.Name, Language.GetString("photobucket", LangKey.communication_wait),
|
||||
delegate() {
|
||||
photobucketInfo = PhotobucketUtils.UploadToPhotobucket(stream.GetBuffer(), (int)stream.Length, captureDetails.Title, filename);
|
||||
}
|
||||
);
|
||||
// This causes an exeption if the upload failed :)
|
||||
LOG.DebugFormat("Uploaded to Photobucket page: " + photobucketInfo.Page);
|
||||
uploadURL = null;
|
||||
try {
|
||||
if (config.UsePageLink) {
|
||||
uploadURL = photobucketInfo.Page;
|
||||
Clipboard.SetText(photobucketInfo.Page);
|
||||
} else {
|
||||
uploadURL = photobucketInfo.Original;
|
||||
Clipboard.SetText(photobucketInfo.Original);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
LOG.Error("Can't write to clipboard: ", ex);
|
||||
// Run upload in the background
|
||||
new PleaseWaitForm().ShowAndWait(Attributes.Name, Language.GetString("photobucket", LangKey.communication_wait),
|
||||
delegate() {
|
||||
photobucketInfo = PhotobucketUtils.UploadToPhotobucket(image, outputSettings, captureDetails.Title, filename);
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
LOG.Error(e);
|
||||
MessageBox.Show(Language.GetString("photobucket", LangKey.upload_failure) + " " + e.Message);
|
||||
);
|
||||
// This causes an exeption if the upload failed :)
|
||||
LOG.DebugFormat("Uploaded to Photobucket page: " + photobucketInfo.Page);
|
||||
uploadURL = null;
|
||||
try {
|
||||
if (config.UsePageLink) {
|
||||
uploadURL = photobucketInfo.Page;
|
||||
Clipboard.SetText(photobucketInfo.Page);
|
||||
} else {
|
||||
uploadURL = photobucketInfo.Original;
|
||||
Clipboard.SetText(photobucketInfo.Original);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
LOG.Error("Can't write to clipboard: ", ex);
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
LOG.Error(e);
|
||||
MessageBox.Show(Language.GetString("photobucket", LangKey.upload_failure) + " " + e.Message);
|
||||
}
|
||||
uploadURL = null;
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue