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:
RKrom 2012-03-14 11:53:03 +00:00
commit 40807d5d2b
5 changed files with 70 additions and 69 deletions

View file

@ -141,11 +141,9 @@ namespace GreenshotImgurPlugin {
BackgroundForm backgroundForm = BackgroundForm.ShowAndWait(Attributes.Name, lang.GetString(LangKey.communication_wait));
host.SaveToStream(image, stream, config.UploadFormat, config.UploadJpegQuality);
byte[] buffer = stream.GetBuffer();
try {
string filename = Path.GetFileName(host.GetFilename(config.UploadFormat, captureDetails));
ImgurInfo imgurInfo = ImgurUtils.UploadToImgur(buffer, captureDetails.DateTime.ToString(), filename);
ImgurInfo imgurInfo = ImgurUtils.UploadToImgur(stream.GetBuffer(), (int)stream.Length, captureDetails.DateTime.ToString(), filename);
LOG.InfoFormat("Storing imgur upload for hash {0} and delete hash {1}", imgurInfo.Hash, imgurInfo.DeleteHash);
config.ImgurUploadHistory.Add(imgurInfo.Hash, imgurInfo.DeleteHash);
config.runtimeImgurHistory.Add(imgurInfo.Hash, imgurInfo);
@ -181,10 +179,9 @@ namespace GreenshotImgurPlugin {
BackgroundForm backgroundForm = BackgroundForm.ShowAndWait(Attributes.Name, lang.GetString(LangKey.communication_wait));
imageEditor.SaveToStream(stream, config.UploadFormat, config.UploadJpegQuality);
byte [] buffer = stream.GetBuffer();
try {
string filename = Path.GetFileName(host.GetFilename(config.UploadFormat, imageEditor.CaptureDetails));
ImgurInfo imgurInfo = ImgurUtils.UploadToImgur(buffer, imageEditor.CaptureDetails.Title, filename);
ImgurInfo imgurInfo = ImgurUtils.UploadToImgur(stream.GetBuffer(), (int)stream.Length, imageEditor.CaptureDetails.Title, filename);
imageEditor.Surface.Modified = false;
LOG.InfoFormat("Storing imgur upload for hash {0} and delete hash {1}", imgurInfo.Hash, imgurInfo.DeleteHash);
config.ImgurUploadHistory.Add(imgurInfo.Hash, imgurInfo.DeleteHash);