mirror of
https://github.com/greenshot/greenshot
synced 2025-08-21 05:53:27 -07:00
Fixed bug where the image exported to the Clipboard, Jira, Imgur or Confluence is bigger as it should be. The reason is that "MemoryStream.getBuffer()" returns the byte buffer for the stream, which is usually bigger (capacity) than the actual data!!
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1702 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
4267c50984
commit
40807d5d2b
5 changed files with 70 additions and 69 deletions
|
@ -141,40 +141,42 @@ namespace GreenshotConfluencePlugin {
|
|||
}
|
||||
|
||||
private bool upload(Image image, Page page, string filename, bool openPage) {
|
||||
byte[] buffer;
|
||||
using (MemoryStream stream = new MemoryStream()) {
|
||||
ConfluencePlugin.Host.SaveToStream(image, stream, config.UploadFormat, config.UploadJpegQuality);
|
||||
byte [] buffer = stream.GetBuffer();
|
||||
try {
|
||||
ConfluencePlugin.ConfluenceConnector.addAttachment(page.id, "image/" + config.UploadFormat.ToString().ToLower(), null, filename, buffer);
|
||||
LOG.Debug("Uploaded to Confluence.");
|
||||
if (config.CopyWikiMarkupForImageToClipboard) {
|
||||
int retryCount = 2;
|
||||
while (retryCount >= 0) {
|
||||
try {
|
||||
Clipboard.SetText("!" + filename + "!");
|
||||
break;
|
||||
} catch (Exception ee) {
|
||||
if (retryCount == 0) {
|
||||
LOG.Error(ee);
|
||||
} else {
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
} finally {
|
||||
--retryCount;
|
||||
// COPY buffer to array
|
||||
buffer = stream.ToArray();
|
||||
}
|
||||
try {
|
||||
ConfluencePlugin.ConfluenceConnector.addAttachment(page.id, "image/" + config.UploadFormat.ToString().ToLower(), null, filename, buffer);
|
||||
LOG.Debug("Uploaded to Confluence.");
|
||||
if (config.CopyWikiMarkupForImageToClipboard) {
|
||||
int retryCount = 2;
|
||||
while (retryCount >= 0) {
|
||||
try {
|
||||
Clipboard.SetText("!" + filename + "!");
|
||||
break;
|
||||
} catch (Exception ee) {
|
||||
if (retryCount == 0) {
|
||||
LOG.Error(ee);
|
||||
} else {
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
} finally {
|
||||
--retryCount;
|
||||
}
|
||||
}
|
||||
if (openPage) {
|
||||
try {
|
||||
Process.Start(page.Url);
|
||||
} catch {}
|
||||
} else {
|
||||
System.Windows.MessageBox.Show(lang.GetString(LangKey.upload_success));
|
||||
}
|
||||
return true;
|
||||
} catch(Exception e) {
|
||||
System.Windows.MessageBox.Show(lang.GetString(LangKey.upload_failure) + " " + e.Message);
|
||||
}
|
||||
if (openPage) {
|
||||
try {
|
||||
Process.Start(page.Url);
|
||||
} catch {}
|
||||
} else {
|
||||
System.Windows.MessageBox.Show(lang.GetString(LangKey.upload_success));
|
||||
}
|
||||
return true;
|
||||
} catch(Exception e) {
|
||||
System.Windows.MessageBox.Show(lang.GetString(LangKey.upload_failure) + " " + e.Message);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue