Refactoring: created a OutputSettings class to contain all the output settings for writing files. Default the settings are loaded from the configuration, in a later version it will be possible to have separate settings for every destination and these can be configured at one place... the settings form.

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1815 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-04-24 16:44:34 +00:00
commit e5fd88ebd3
21 changed files with 182 additions and 123 deletions

View file

@ -130,10 +130,11 @@ namespace GreenshotImgurPlugin {
}
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()) {
BackgroundForm backgroundForm = BackgroundForm.ShowAndWait(Attributes.Name, Language.GetString("imgur", LangKey.communication_wait));
host.SaveToStream(image, stream, config.UploadFormat, config.UploadJpegQuality, config.UploadReduceColors);
host.SaveToStream(image, stream, outputSettings);
try {
string filename = Path.GetFileName(host.GetFilename(config.UploadFormat, captureDetails));
ImgurInfo imgurInfo = ImgurUtils.UploadToImgur(stream.GetBuffer(), (int)stream.Length, captureDetails.DateTime.ToString(), filename);
@ -170,10 +171,11 @@ namespace GreenshotImgurPlugin {
public void EditMenuClick(object sender, EventArgs eventArgs) {
ToolStripMenuItem item = (ToolStripMenuItem)sender;
IImageEditor imageEditor = (IImageEditor)item.Tag;
OutputSettings outputSettings = new OutputSettings(config.UploadFormat, config.UploadJpegQuality, config.UploadReduceColors);
using (MemoryStream stream = new MemoryStream()) {
BackgroundForm backgroundForm = BackgroundForm.ShowAndWait(Attributes.Name, Language.GetString("imgur", LangKey.communication_wait));
imageEditor.SaveToStream(stream, config.UploadFormat, config.UploadJpegQuality, config.UploadReduceColors);
imageEditor.SaveToStream(stream, outputSettings);
try {
string filename = Path.GetFileName(host.GetFilename(config.UploadFormat, imageEditor.CaptureDetails));
ImgurInfo imgurInfo = ImgurUtils.UploadToImgur(stream.GetBuffer(), (int)stream.Length, imageEditor.CaptureDetails.Title, filename);