added monochrome print option

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2491 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
JKlingen 2013-02-17 07:58:58 +00:00
parent 9f86db6828
commit b537ae7e14
11 changed files with 1612 additions and 1480 deletions

View file

@ -168,6 +168,7 @@ namespace Greenshot.Configuration {
printoptions_allowrotate,
printoptions_allowshrink,
printoptions_dontaskagain,
printoptions_printmonochrome,
printoptions_timestamp,
printoptions_inverted,
printoptions_title,

View file

@ -106,42 +106,18 @@ namespace Greenshot.Destinations {
/// <param name="captureDetails"></param>
/// <returns>ExportInformation</returns>
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
PrinterSettings printerSettings = null;
// Create the output settins
SurfaceOutputSettings printOutputSettings = new SurfaceOutputSettings(OutputFormat.png, 100, false);
// TODO:
// add effects here, e.g. Monochrome
// printOutputSettings.Effects.Add(new MonochromeEffect());
// Set the color reducing if needed, this should change the 24/32-> 8 (or later even 1) bpp
// printOutputSettings.ReduceColors = true;
// Moved this from the PrintHelper, the invert effect should probably be the last!
if (conf.OutputPrintInverted) {
printOutputSettings.Effects.Add(new InvertEffect());
ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
PrinterSettings printerSettings = null;
if (!string.IsNullOrEmpty(printerName)) {
printerSettings = new PrintHelper(surface, captureDetails).PrintTo(printerName);
} else if (!manuallyInitiated) {
PrinterSettings settings = new PrinterSettings();
printerSettings = new PrintHelper(surface, captureDetails).PrintTo(settings.PrinterName);
} else {
printerSettings = new PrintHelper(surface, captureDetails).PrintWithDialog();
}
Image imageToPrint;
Boolean disposeImage = ImageOutput.CreateImageFromSurface(surface, printOutputSettings, out imageToPrint);
try {
if (!string.IsNullOrEmpty(printerName)) {
printerSettings = new PrintHelper(imageToPrint, captureDetails).PrintTo(printerName);
} else if (!manuallyInitiated) {
PrinterSettings settings = new PrinterSettings();
printerSettings = new PrintHelper(imageToPrint, captureDetails).PrintTo(settings.PrinterName);
} else {
printerSettings = new PrintHelper(imageToPrint, captureDetails).PrintWithDialog();
}
if (printerSettings != null) {
exportInformation.ExportMade = true;
}
} finally {
if (disposeImage && imageToPrint != null) {
imageToPrint.Dispose();
imageToPrint = null;
}
if (printerSettings != null) {
exportInformation.ExportMade = true;
}
ProcessExport(exportInformation, surface);

View file

@ -48,185 +48,203 @@ namespace Greenshot.Forms
/// </summary>
private void InitializeComponent()
{
this.checkbox_dontaskagain = new GreenshotPlugin.Controls.GreenshotCheckBox();
this.checkboxAllowShrink = new GreenshotPlugin.Controls.GreenshotCheckBox();
this.checkboxAllowEnlarge = new GreenshotPlugin.Controls.GreenshotCheckBox();
this.checkboxAllowCenter = new GreenshotPlugin.Controls.GreenshotCheckBox();
this.checkboxAllowRotate = new GreenshotPlugin.Controls.GreenshotCheckBox();
this.button_ok = new GreenshotPlugin.Controls.GreenshotButton();
this.checkboxDateTime = new GreenshotPlugin.Controls.GreenshotCheckBox();
this.button_cancel = new GreenshotPlugin.Controls.GreenshotButton();
this.checkboxPrintInverted = new GreenshotPlugin.Controls.GreenshotCheckBox();
this.checkbox_grayscale = new GreenshotPlugin.Controls.GreenshotCheckBox();
this.SuspendLayout();
//
// checkbox_dontaskagain
//
this.checkbox_dontaskagain.AutoSize = true;
this.checkbox_dontaskagain.CheckAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkbox_dontaskagain.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkbox_dontaskagain.LanguageKey = "printoptions_dontaskagain";
this.checkbox_dontaskagain.Location = new System.Drawing.Point(12, 191);
this.checkbox_dontaskagain.Name = "checkbox_dontaskagain";
this.checkbox_dontaskagain.Size = new System.Drawing.Size(240, 17);
this.checkbox_dontaskagain.TabIndex = 19;
this.checkbox_dontaskagain.Text = "Save options as default and do not ask again";
this.checkbox_dontaskagain.TextAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkbox_dontaskagain.UseVisualStyleBackColor = true;
//
// checkboxAllowShrink
//
this.checkboxAllowShrink.AutoSize = true;
this.checkboxAllowShrink.CheckAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxAllowShrink.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxAllowShrink.LanguageKey = "printoptions_allowshrink";
this.checkboxAllowShrink.Location = new System.Drawing.Point(12, 20);
this.checkboxAllowShrink.Name = "checkboxAllowShrink";
this.checkboxAllowShrink.PropertyName = "OutputPrintAllowShrink";
this.checkboxAllowShrink.Size = new System.Drawing.Size(168, 17);
this.checkboxAllowShrink.TabIndex = 21;
this.checkboxAllowShrink.Text = "Shrink printout to fit paper size";
this.checkboxAllowShrink.TextAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxAllowShrink.UseVisualStyleBackColor = true;
//
// checkboxAllowEnlarge
//
this.checkboxAllowEnlarge.AutoSize = true;
this.checkboxAllowEnlarge.CheckAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxAllowEnlarge.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxAllowEnlarge.LanguageKey = "printoptions_allowenlarge";
this.checkboxAllowEnlarge.Location = new System.Drawing.Point(12, 43);
this.checkboxAllowEnlarge.Name = "checkboxAllowEnlarge";
this.checkboxAllowEnlarge.PropertyName = "OutputPrintAllowEnlarge";
this.checkboxAllowEnlarge.Size = new System.Drawing.Size(174, 17);
this.checkboxAllowEnlarge.TabIndex = 22;
this.checkboxAllowEnlarge.Text = "Enlarge printout to fit paper size";
this.checkboxAllowEnlarge.TextAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxAllowEnlarge.UseVisualStyleBackColor = true;
//
// checkboxAllowCenter
//
this.checkboxAllowCenter.AutoSize = true;
this.checkboxAllowCenter.CheckAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxAllowCenter.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxAllowCenter.LanguageKey = "printoptions_allowcenter";
this.checkboxAllowCenter.Location = new System.Drawing.Point(12, 89);
this.checkboxAllowCenter.Name = "checkboxAllowCenter";
this.checkboxAllowCenter.PropertyName = "OutputPrintCenter";
this.checkboxAllowCenter.Size = new System.Drawing.Size(137, 17);
this.checkboxAllowCenter.TabIndex = 24;
this.checkboxAllowCenter.Text = "Center printout on page";
this.checkboxAllowCenter.TextAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxAllowCenter.UseVisualStyleBackColor = true;
//
// checkboxAllowRotate
//
this.checkboxAllowRotate.AutoSize = true;
this.checkboxAllowRotate.CheckAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxAllowRotate.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxAllowRotate.LanguageKey = "printoptions_allowrotate";
this.checkboxAllowRotate.Location = new System.Drawing.Point(12, 66);
this.checkboxAllowRotate.Name = "checkboxAllowRotate";
this.checkboxAllowRotate.PropertyName = "OutputPrintAllowRotate";
this.checkboxAllowRotate.Size = new System.Drawing.Size(187, 17);
this.checkboxAllowRotate.TabIndex = 23;
this.checkboxAllowRotate.Text = "Rotate printout to page orientation";
this.checkboxAllowRotate.TextAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxAllowRotate.UseVisualStyleBackColor = true;
//
// button_ok
//
this.button_ok.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button_ok.DialogResult = System.Windows.Forms.DialogResult.OK;
this.button_ok.LanguageKey = "OK";
this.button_ok.Location = new System.Drawing.Point(187, 224);
this.button_ok.Name = "button_ok";
this.button_ok.Size = new System.Drawing.Size(75, 23);
this.button_ok.TabIndex = 25;
this.button_ok.Text = "OK";
this.button_ok.UseVisualStyleBackColor = true;
this.button_ok.Click += new System.EventHandler(this.Button_okClick);
//
// checkboxDateTime
//
this.checkboxDateTime.AutoSize = true;
this.checkboxDateTime.CheckAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxDateTime.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxDateTime.LanguageKey = "printoptions_timestamp";
this.checkboxDateTime.Location = new System.Drawing.Point(12, 112);
this.checkboxDateTime.Name = "checkboxDateTime";
this.checkboxDateTime.PropertyName = "OutputPrintFooter";
this.checkboxDateTime.Size = new System.Drawing.Size(187, 17);
this.checkboxDateTime.TabIndex = 26;
this.checkboxDateTime.Text = "Print date / time at bottom of page";
this.checkboxDateTime.TextAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxDateTime.UseVisualStyleBackColor = true;
//
// button_cancel
//
this.button_cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button_cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.button_cancel.LanguageKey = "CANCEL";
this.button_cancel.Location = new System.Drawing.Point(268, 224);
this.button_cancel.Name = "button_cancel";
this.button_cancel.Size = new System.Drawing.Size(75, 23);
this.button_cancel.TabIndex = 27;
this.button_cancel.Text = "Cancel";
this.button_cancel.UseVisualStyleBackColor = true;
//
// checkboxPrintInverted
//
this.checkboxPrintInverted.AutoSize = true;
this.checkboxPrintInverted.CheckAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxPrintInverted.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxPrintInverted.LanguageKey = "printoptions_inverted";
this.checkboxPrintInverted.Location = new System.Drawing.Point(12, 135);
this.checkboxPrintInverted.Name = "checkboxPrintInverted";
this.checkboxPrintInverted.PropertyName = "OutputPrintInverted";
this.checkboxPrintInverted.Size = new System.Drawing.Size(141, 17);
this.checkboxPrintInverted.TabIndex = 28;
this.checkboxPrintInverted.Text = "Print with inverted colors";
this.checkboxPrintInverted.TextAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxPrintInverted.UseVisualStyleBackColor = true;
//
// checkbox_grayscale
//
this.checkbox_grayscale.AutoSize = true;
this.checkbox_grayscale.CheckAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkbox_grayscale.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkbox_grayscale.LanguageKey = "printoptions_printgrayscale";
this.checkbox_grayscale.Location = new System.Drawing.Point(12, 158);
this.checkbox_grayscale.Name = "checkbox_grayscale";
this.checkbox_grayscale.PropertyName = "OutputPrintGrayscale";
this.checkbox_grayscale.Size = new System.Drawing.Size(138, 17);
this.checkbox_grayscale.TabIndex = 29;
this.checkbox_grayscale.Text = "Force grayscale printing";
this.checkbox_grayscale.TextAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkbox_grayscale.UseVisualStyleBackColor = true;
//
// PrintOptionsDialog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.ClientSize = new System.Drawing.Size(355, 259);
this.Controls.Add(this.checkbox_grayscale);
this.Controls.Add(this.checkboxPrintInverted);
this.Controls.Add(this.button_cancel);
this.Controls.Add(this.checkboxDateTime);
this.Controls.Add(this.button_ok);
this.Controls.Add(this.checkbox_dontaskagain);
this.Controls.Add(this.checkboxAllowCenter);
this.Controls.Add(this.checkboxAllowRotate);
this.Controls.Add(this.checkboxAllowEnlarge);
this.Controls.Add(this.checkboxAllowShrink);
this.LanguageKey = "printoptions_title";
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "PrintOptionsDialog";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.Text = "Greenshot print options";
this.ResumeLayout(false);
this.PerformLayout();
this.checkbox_dontaskagain = new GreenshotPlugin.Controls.GreenshotCheckBox();
this.checkboxAllowShrink = new GreenshotPlugin.Controls.GreenshotCheckBox();
this.checkboxAllowEnlarge = new GreenshotPlugin.Controls.GreenshotCheckBox();
this.checkboxAllowCenter = new GreenshotPlugin.Controls.GreenshotCheckBox();
this.checkboxAllowRotate = new GreenshotPlugin.Controls.GreenshotCheckBox();
this.button_ok = new GreenshotPlugin.Controls.GreenshotButton();
this.checkboxDateTime = new GreenshotPlugin.Controls.GreenshotCheckBox();
this.button_cancel = new GreenshotPlugin.Controls.GreenshotButton();
this.checkboxPrintInverted = new GreenshotPlugin.Controls.GreenshotCheckBox();
this.checkbox_grayscale = new GreenshotPlugin.Controls.GreenshotCheckBox();
this.checkbox_monochrome = new GreenshotPlugin.Controls.GreenshotCheckBox();
this.SuspendLayout();
//
// checkbox_dontaskagain
//
this.checkbox_dontaskagain.AutoSize = true;
this.checkbox_dontaskagain.CheckAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkbox_dontaskagain.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkbox_dontaskagain.LanguageKey = "printoptions_dontaskagain";
this.checkbox_dontaskagain.Location = new System.Drawing.Point(12, 214);
this.checkbox_dontaskagain.Name = "checkbox_dontaskagain";
this.checkbox_dontaskagain.Size = new System.Drawing.Size(240, 17);
this.checkbox_dontaskagain.TabIndex = 19;
this.checkbox_dontaskagain.Text = "Save options as default and do not ask again";
this.checkbox_dontaskagain.TextAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkbox_dontaskagain.UseVisualStyleBackColor = true;
//
// checkboxAllowShrink
//
this.checkboxAllowShrink.AutoSize = true;
this.checkboxAllowShrink.CheckAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxAllowShrink.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxAllowShrink.LanguageKey = "printoptions_allowshrink";
this.checkboxAllowShrink.Location = new System.Drawing.Point(12, 20);
this.checkboxAllowShrink.Name = "checkboxAllowShrink";
this.checkboxAllowShrink.PropertyName = "OutputPrintAllowShrink";
this.checkboxAllowShrink.Size = new System.Drawing.Size(168, 17);
this.checkboxAllowShrink.TabIndex = 21;
this.checkboxAllowShrink.Text = "Shrink printout to fit paper size";
this.checkboxAllowShrink.TextAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxAllowShrink.UseVisualStyleBackColor = true;
//
// checkboxAllowEnlarge
//
this.checkboxAllowEnlarge.AutoSize = true;
this.checkboxAllowEnlarge.CheckAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxAllowEnlarge.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxAllowEnlarge.LanguageKey = "printoptions_allowenlarge";
this.checkboxAllowEnlarge.Location = new System.Drawing.Point(12, 43);
this.checkboxAllowEnlarge.Name = "checkboxAllowEnlarge";
this.checkboxAllowEnlarge.PropertyName = "OutputPrintAllowEnlarge";
this.checkboxAllowEnlarge.Size = new System.Drawing.Size(174, 17);
this.checkboxAllowEnlarge.TabIndex = 22;
this.checkboxAllowEnlarge.Text = "Enlarge printout to fit paper size";
this.checkboxAllowEnlarge.TextAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxAllowEnlarge.UseVisualStyleBackColor = true;
//
// checkboxAllowCenter
//
this.checkboxAllowCenter.AutoSize = true;
this.checkboxAllowCenter.CheckAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxAllowCenter.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxAllowCenter.LanguageKey = "printoptions_allowcenter";
this.checkboxAllowCenter.Location = new System.Drawing.Point(12, 89);
this.checkboxAllowCenter.Name = "checkboxAllowCenter";
this.checkboxAllowCenter.PropertyName = "OutputPrintCenter";
this.checkboxAllowCenter.Size = new System.Drawing.Size(137, 17);
this.checkboxAllowCenter.TabIndex = 24;
this.checkboxAllowCenter.Text = "Center printout on page";
this.checkboxAllowCenter.TextAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxAllowCenter.UseVisualStyleBackColor = true;
//
// checkboxAllowRotate
//
this.checkboxAllowRotate.AutoSize = true;
this.checkboxAllowRotate.CheckAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxAllowRotate.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxAllowRotate.LanguageKey = "printoptions_allowrotate";
this.checkboxAllowRotate.Location = new System.Drawing.Point(12, 66);
this.checkboxAllowRotate.Name = "checkboxAllowRotate";
this.checkboxAllowRotate.PropertyName = "OutputPrintAllowRotate";
this.checkboxAllowRotate.Size = new System.Drawing.Size(187, 17);
this.checkboxAllowRotate.TabIndex = 23;
this.checkboxAllowRotate.Text = "Rotate printout to page orientation";
this.checkboxAllowRotate.TextAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxAllowRotate.UseVisualStyleBackColor = true;
//
// button_ok
//
this.button_ok.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button_ok.DialogResult = System.Windows.Forms.DialogResult.OK;
this.button_ok.LanguageKey = "OK";
this.button_ok.Location = new System.Drawing.Point(187, 267);
this.button_ok.Name = "button_ok";
this.button_ok.Size = new System.Drawing.Size(75, 23);
this.button_ok.TabIndex = 25;
this.button_ok.Text = "Ok";
this.button_ok.UseVisualStyleBackColor = true;
this.button_ok.Click += new System.EventHandler(this.Button_okClick);
//
// checkboxDateTime
//
this.checkboxDateTime.AutoSize = true;
this.checkboxDateTime.CheckAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxDateTime.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxDateTime.LanguageKey = "printoptions_timestamp";
this.checkboxDateTime.Location = new System.Drawing.Point(12, 112);
this.checkboxDateTime.Name = "checkboxDateTime";
this.checkboxDateTime.PropertyName = "OutputPrintFooter";
this.checkboxDateTime.Size = new System.Drawing.Size(187, 17);
this.checkboxDateTime.TabIndex = 26;
this.checkboxDateTime.Text = "Print date / time at bottom of page";
this.checkboxDateTime.TextAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxDateTime.UseVisualStyleBackColor = true;
//
// button_cancel
//
this.button_cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button_cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.button_cancel.LanguageKey = "CANCEL";
this.button_cancel.Location = new System.Drawing.Point(268, 267);
this.button_cancel.Name = "button_cancel";
this.button_cancel.Size = new System.Drawing.Size(75, 23);
this.button_cancel.TabIndex = 27;
this.button_cancel.Text = "Cancel";
this.button_cancel.UseVisualStyleBackColor = true;
//
// checkboxPrintInverted
//
this.checkboxPrintInverted.AutoSize = true;
this.checkboxPrintInverted.CheckAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxPrintInverted.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxPrintInverted.LanguageKey = "printoptions_inverted";
this.checkboxPrintInverted.Location = new System.Drawing.Point(12, 135);
this.checkboxPrintInverted.Name = "checkboxPrintInverted";
this.checkboxPrintInverted.PropertyName = "OutputPrintInverted";
this.checkboxPrintInverted.Size = new System.Drawing.Size(141, 17);
this.checkboxPrintInverted.TabIndex = 28;
this.checkboxPrintInverted.Text = "Print with inverted colors";
this.checkboxPrintInverted.TextAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxPrintInverted.UseVisualStyleBackColor = true;
//
// checkbox_grayscale
//
this.checkbox_grayscale.AutoSize = true;
this.checkbox_grayscale.CheckAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkbox_grayscale.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkbox_grayscale.LanguageKey = "printoptions_printgrayscale";
this.checkbox_grayscale.Location = new System.Drawing.Point(12, 158);
this.checkbox_grayscale.Name = "checkbox_grayscale";
this.checkbox_grayscale.PropertyName = "OutputPrintGrayscale";
this.checkbox_grayscale.Size = new System.Drawing.Size(138, 17);
this.checkbox_grayscale.TabIndex = 29;
this.checkbox_grayscale.Text = "Force grayscale printing";
this.checkbox_grayscale.TextAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkbox_grayscale.UseVisualStyleBackColor = true;
//
// checkbox_monochrome
//
this.checkbox_monochrome.AutoSize = true;
this.checkbox_monochrome.CheckAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkbox_monochrome.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkbox_monochrome.LanguageKey = "printoptions_printmonochrome";
this.checkbox_monochrome.Location = new System.Drawing.Point(12, 181);
this.checkbox_monochrome.Name = "checkbox_monochrome";
this.checkbox_monochrome.PropertyName = "OutputPrintMonochrome";
this.checkbox_monochrome.Size = new System.Drawing.Size(149, 17);
this.checkbox_monochrome.TabIndex = 30;
this.checkbox_monochrome.Text = "Force black/white printing";
this.checkbox_monochrome.TextAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkbox_monochrome.UseVisualStyleBackColor = true;
//
// PrintOptionsDialog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.ClientSize = new System.Drawing.Size(355, 302);
this.Controls.Add(this.checkbox_monochrome);
this.Controls.Add(this.checkbox_grayscale);
this.Controls.Add(this.checkboxPrintInverted);
this.Controls.Add(this.button_cancel);
this.Controls.Add(this.checkboxDateTime);
this.Controls.Add(this.button_ok);
this.Controls.Add(this.checkbox_dontaskagain);
this.Controls.Add(this.checkboxAllowCenter);
this.Controls.Add(this.checkboxAllowRotate);
this.Controls.Add(this.checkboxAllowEnlarge);
this.Controls.Add(this.checkboxAllowShrink);
this.LanguageKey = "printoptions_title";
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "PrintOptionsDialog";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.Text = "Greenshot print options";
this.ResumeLayout(false);
this.PerformLayout();
}
private GreenshotPlugin.Controls.GreenshotCheckBox checkbox_grayscale;
private GreenshotPlugin.Controls.GreenshotCheckBox checkboxPrintInverted;
@ -238,5 +256,6 @@ namespace Greenshot.Forms
private GreenshotPlugin.Controls.GreenshotCheckBox checkboxAllowEnlarge;
private GreenshotPlugin.Controls.GreenshotCheckBox checkboxAllowShrink;
private GreenshotPlugin.Controls.GreenshotCheckBox checkbox_dontaskagain;
private GreenshotPlugin.Controls.GreenshotCheckBox checkbox_monochrome;
}
}

File diff suppressed because it is too large Load diff

View file

@ -112,15 +112,15 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="folderBrowserDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<metadata name="folderBrowserDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>116, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="colorButton_window_background.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABcAAAAYCAYAAAARfGZ1AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6

View file

@ -29,6 +29,7 @@ using Greenshot.Forms;
using Greenshot.Plugin;
using GreenshotPlugin.Core;
using Greenshot.IniFile;
using Greenshot.Core;
namespace Greenshot.Helpers {
/// <summary>
@ -38,13 +39,13 @@ namespace Greenshot.Helpers {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(PrintHelper));
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
private Image image;
private ISurface surface;
private ICaptureDetails captureDetails;
private PrintDocument printDocument = new PrintDocument();
private PrintDialog printDialog = new PrintDialog();
public PrintHelper(Image image, ICaptureDetails captureDetails) {
this.image = image;
public PrintHelper(ISurface surface, ICaptureDetails captureDetails) {
this.surface = surface;
this.captureDetails = captureDetails;
printDialog.UseEXDialog = true;
printDocument.DocumentName = FilenameHelper.GetFilenameWithoutExtensionFromPattern(conf.OutputFileFilenamePattern, captureDetails);
@ -74,8 +75,8 @@ namespace Greenshot.Helpers {
*/
protected virtual void Dispose(bool disposing) {
if (disposing) {
if (image != null) {
image.Dispose();
if (surface != null) {
surface.Dispose();
}
if (printDocument != null) {
printDocument.Dispose();
@ -84,7 +85,7 @@ namespace Greenshot.Helpers {
printDialog.Dispose();
}
}
image = null;
surface = null;
printDocument = null;
printDialog = null;
}
@ -100,7 +101,7 @@ namespace Greenshot.Helpers {
try {
if (printOptionsResult == null || printOptionsResult == DialogResult.OK) {
printDocument.PrinterSettings.PrinterName = printerName;
if (conf.OutputPrintGrayscale) {
if (!IsColorPrint()) {
printDocument.DefaultPageSettings.Color = false;
}
printDocument.Print();
@ -110,8 +111,8 @@ namespace Greenshot.Helpers {
LOG.Error("An error ocurred while trying to print", e);
MessageBox.Show(Language.GetString(LangKey.print_error), Language.GetString(LangKey.error));
}
image.Dispose();
image = null;
surface.Dispose();
surface = null;
return returnPrinterSettings;
}
@ -126,7 +127,7 @@ namespace Greenshot.Helpers {
DialogResult? printOptionsResult = ShowPrintOptionsDialog();
try {
if (printOptionsResult == null || printOptionsResult == DialogResult.OK) {
if (conf.OutputPrintGrayscale) {
if (IsColorPrint()) {
printDocument.DefaultPageSettings.Color = false;
}
printDocument.Print();
@ -138,11 +139,15 @@ namespace Greenshot.Helpers {
}
}
image.Dispose();
image = null;
surface.Dispose();
surface = null;
return returnPrinterSettings;
}
private bool IsColorPrint() {
return !conf.OutputPrintGrayscale && !conf.OutputPrintMonochrome;
}
/// <summary>
/// display print options dialog (if the user has not configured Greenshot not to)
/// </summary>
@ -158,62 +163,95 @@ namespace Greenshot.Helpers {
}
void DrawImageForPrint(object sender, PrintPageEventArgs e) {
ContentAlignment alignment = conf.OutputPrintCenter ? ContentAlignment.MiddleCenter : ContentAlignment.TopLeft;
// prepare timestamp
float footerStringWidth = 0;
float footerStringHeight = 0;
string footerString = null; //DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString();
if (conf.OutputPrintFooter) {
footerString = FilenameHelper.FillPattern(conf.OutputPrintFooterPattern, captureDetails, false);
using (Font f = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Regular)) {
footerStringWidth = e.Graphics.MeasureString(footerString, f).Width;
footerStringHeight = e.Graphics.MeasureString(footerString, f).Height;
// Create the output settins
SurfaceOutputSettings printOutputSettings = new SurfaceOutputSettings(OutputFormat.png, 100, false);
ApplyEffects(printOutputSettings);
Image image;
Boolean disposeImage = ImageOutput.CreateImageFromSurface(surface, printOutputSettings, out image);
try {
ContentAlignment alignment = conf.OutputPrintCenter ? ContentAlignment.MiddleCenter : ContentAlignment.TopLeft;
// prepare timestamp
float footerStringWidth = 0;
float footerStringHeight = 0;
string footerString = null; //DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString();
if (conf.OutputPrintFooter) {
footerString = FilenameHelper.FillPattern(conf.OutputPrintFooterPattern, captureDetails, false);
using (Font f = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Regular)) {
footerStringWidth = e.Graphics.MeasureString(footerString, f).Width;
footerStringHeight = e.Graphics.MeasureString(footerString, f).Height;
}
}
// Get a rectangle representing the printable Area
RectangleF pageRect = e.PageSettings.PrintableArea;
if(e.PageSettings.Landscape) {
float origWidth = pageRect.Width;
pageRect.Width = pageRect.Height;
pageRect.Height = origWidth;
}
// Subtract the dateString height from the available area, this way the area stays free
pageRect.Height -= footerStringHeight;
GraphicsUnit gu = GraphicsUnit.Pixel;
RectangleF imageRect = image.GetBounds(ref gu);
// rotate the image if it fits the page better
if (conf.OutputPrintAllowRotate) {
if ((pageRect.Width > pageRect.Height && imageRect.Width < imageRect.Height) || (pageRect.Width < pageRect.Height && imageRect.Width > imageRect.Height)) {
image.RotateFlip(RotateFlipType.Rotate90FlipNone);
imageRect = image.GetBounds(ref gu);
if (alignment.Equals(ContentAlignment.TopLeft)) {
alignment = ContentAlignment.TopRight;
}
}
}
RectangleF printRect = new RectangleF(0, 0, imageRect.Width, imageRect.Height);
// scale the image to fit the page better
if (conf.OutputPrintAllowEnlarge || conf.OutputPrintAllowShrink) {
SizeF resizedRect = ScaleHelper.GetScaledSize(imageRect.Size, pageRect.Size, false);
if ((conf.OutputPrintAllowShrink && resizedRect.Width < printRect.Width) || conf.OutputPrintAllowEnlarge && resizedRect.Width > printRect.Width) {
printRect.Size = resizedRect;
}
}
// align the image
printRect = ScaleHelper.GetAlignedRectangle(printRect, new RectangleF(0, 0, pageRect.Width, pageRect.Height), alignment);
if (conf.OutputPrintFooter) {
//printRect = new RectangleF(0, 0, printRect.Width, printRect.Height - (dateStringHeight * 2));
using (Font f = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Regular)) {
e.Graphics.DrawString(footerString, f, Brushes.Black, pageRect.Width / 2 - (footerStringWidth / 2), pageRect.Height);
}
}
e.Graphics.DrawImage(image, printRect, imageRect, GraphicsUnit.Pixel);
} finally {
if (disposeImage && image != null) {
image.Dispose();
image = null;
}
}
// Get a rectangle representing the printable Area
RectangleF pageRect = e.PageSettings.PrintableArea;
if(e.PageSettings.Landscape) {
float origWidth = pageRect.Width;
pageRect.Width = pageRect.Height;
pageRect.Height = origWidth;
}
// Subtract the dateString height from the available area, this way the area stays free
pageRect.Height -= footerStringHeight;
GraphicsUnit gu = GraphicsUnit.Pixel;
RectangleF imageRect = image.GetBounds(ref gu);
// rotate the image if it fits the page better
if (conf.OutputPrintAllowRotate) {
if ((pageRect.Width > pageRect.Height && imageRect.Width < imageRect.Height) || (pageRect.Width < pageRect.Height && imageRect.Width > imageRect.Height)) {
image.RotateFlip(RotateFlipType.Rotate90FlipNone);
imageRect = image.GetBounds(ref gu);
if (alignment.Equals(ContentAlignment.TopLeft)) {
alignment = ContentAlignment.TopRight;
}
}
}
RectangleF printRect = new RectangleF(0, 0, imageRect.Width, imageRect.Height);
// scale the image to fit the page better
if (conf.OutputPrintAllowEnlarge || conf.OutputPrintAllowShrink) {
SizeF resizedRect = ScaleHelper.GetScaledSize(imageRect.Size, pageRect.Size, false);
if ((conf.OutputPrintAllowShrink && resizedRect.Width < printRect.Width) || conf.OutputPrintAllowEnlarge && resizedRect.Width > printRect.Width) {
printRect.Size = resizedRect;
}
}
// align the image
printRect = ScaleHelper.GetAlignedRectangle(printRect, new RectangleF(0, 0, pageRect.Width, pageRect.Height), alignment);
if (conf.OutputPrintFooter) {
//printRect = new RectangleF(0, 0, printRect.Width, printRect.Height - (dateStringHeight * 2));
using (Font f = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Regular)) {
e.Graphics.DrawString(footerString, f, Brushes.Black, pageRect.Width / 2 - (footerStringWidth / 2), pageRect.Height);
}
}
e.Graphics.DrawImage(image, printRect, imageRect, GraphicsUnit.Pixel);
}
private void ApplyEffects(SurfaceOutputSettings printOutputSettings)
{
// TODO:
// add effects here
if (conf.OutputPrintMonochrome) {
byte threshold = conf.OutputPrintMonochromeThreshold;
printOutputSettings.Effects.Add(new MonochromeEffect(threshold));
printOutputSettings.ReduceColors = true;
}
// the invert effect should probably be the last
if (conf.OutputPrintInverted) {
printOutputSettings.Effects.Add(new InvertEffect());
}
}
}
}

View file

@ -5,18 +5,18 @@
<resource name="about_donations">If you like Greenshot, you are welcome to support us:</resource>
<resource name="about_host">Greenshot is hosted by sourceforge.net at</resource>
<resource name="about_icons">Icons from Yusuke Kamiyamane's Fugue icon set (Creative Commons Attribution 3.0 license)</resource>
<resource name="about_license">Copyright (C) 2007-2013 Thomas Braun, Jens Klingen, Robin Krom
Greenshot comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions.
<resource name="about_license">Copyright (C) 2007-2013 Thomas Braun, Jens Klingen, Robin Krom
Greenshot comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions.
Details about the GNU General Public License:</resource>
<resource name="about_title">About Greenshot</resource>
<resource name="application_title">Greenshot - the revolutionary screenshot utility</resource>
<resource name="bugreport_cancel">Close</resource>
<resource name="bugreport_info">Sorry, an unexpected error occured.
The good news is: you can help us getting rid of it by filing a bug report.
Please visit the URL below, create a new bug report and paste the contents from the text area into the description.
Please add a meaningful summary and enclose any information you consider to be helpful for reproducing the issue.
<resource name="bugreport_info">Sorry, an unexpected error occured.
The good news is: you can help us getting rid of it by filing a bug report.
Please visit the URL below, create a new bug report and paste the contents from the text area into the description.
Please add a meaningful summary and enclose any information you consider to be helpful for reproducing the issue.
Also, we would highly appreciate if you checked whether a tracker item already exists for this bug. (You can use the search to find those quickly.) Thank you :)</resource>
<resource name="bugreport_title">Error</resource>
<resource name="CANCEL">Cancel</resource>
@ -167,7 +167,7 @@ Also, we would highly appreciate if you checked whether a tracker item already e
<resource name="EmailFormat.OUTLOOK_TXT">Outlook with text</resource>
<resource name="error">Error</resource>
<resource name="error_multipleinstances">An instance of Greenshot is already running.</resource>
<resource name="error_nowriteaccess">Cannot save file to {0}.
<resource name="error_nowriteaccess">Cannot save file to {0}.
Please check write accessibility of the selected storage location.</resource>
<resource name="error_openfile">The file "{0}" could not be opened.</resource>
<resource name="error_openlink">Could not open link '{0}'.</resource>
@ -198,7 +198,8 @@ Please check write accessibility of the selected storage location.</resource>
<resource name="printoptions_dontaskagain">Save options as default and do not ask again</resource>
<resource name="printoptions_inverted">Print with inverted colors</resource>
<resource name="printoptions_printgrayscale">Force grayscale printing</resource>
<resource name="printoptions_timestamp">Print date / time at bottom of page</resource>
<resource name="printoptions_printmonochrome">Force black/white printing</resource>
<resource name="printoptions_timestamp">Print date / time at bottom of page</resource>
<resource name="printoptions_title">Greenshot print options</resource>
<resource name="qualitydialog_dontaskagain">Save as default quality and do not ask again</resource>
<resource name="qualitydialog_title">Greenshot quality</resource>
@ -227,22 +228,22 @@ Please check write accessibility of the selected storage location.</resource>
<resource name="settings_iecapture">Internet Explorer capture</resource>
<resource name="settings_jpegquality">JPEG quality</resource>
<resource name="settings_language">Language</resource>
<resource name="settings_message_filenamepattern">The following placeholders will be replaced automatically in the pattern defined:
${YYYY} year, 4 digits
${MM} month, 2 digits
${DD} day, 2 digits
${hh} hour, 2 digits
${mm} minute, 2 digits
${ss} second, 2 digits
${NUM} incrementing number, 6 digits
${title} Window title
${user} Windows user
${domain} Windows domain
${hostname} PC name
You can also have Greenshot create directories dynamically, simply use the backslash symbol (\) to separate folders and filename.
Example: the pattern ${YYYY}-${MM}-${DD}\${hh}-${mm}-${ss}
will generate a folder for the current day in your default storage location, e.g. 2008-06-29, the contained screenshot file's name will be based on the current
<resource name="settings_message_filenamepattern">The following placeholders will be replaced automatically in the pattern defined:
${YYYY} year, 4 digits
${MM} month, 2 digits
${DD} day, 2 digits
${hh} hour, 2 digits
${mm} minute, 2 digits
${ss} second, 2 digits
${NUM} incrementing number, 6 digits
${title} Window title
${user} Windows user
${domain} Windows domain
${hostname} PC name
You can also have Greenshot create directories dynamically, simply use the backslash symbol (\) to separate folders and filename.
Example: the pattern ${YYYY}-${MM}-${DD}\${hh}-${mm}-${ss}
will generate a folder for the current day in your default storage location, e.g. 2008-06-29, the contained screenshot file's name will be based on the current
time, e.g. 11_58_32 (plus extension defined in the settings)</resource>
<resource name="settings_network">Network and updates</resource>
<resource name="settings_output">Output</resource>
@ -277,8 +278,8 @@ time, e.g. 11_58_32 (plus extension defined in the settings)</resource>
<resource name="update_found">A newer version of Greenshot is available! Do you want to download Greenshot {0}?</resource>
<resource name="wait_ie_capture">Please wait while the page in Internet Explorer is captured...</resource>
<resource name="warning">Warning</resource>
<resource name="warning_hotkeys">The hotkey(s) "{0}" could not be registered. This problem is probably caused by another tool claiming usage of the same hotkey(s)! You could either change your hotkey settings or deactivate/change the software making use of the hotkey(s).
<resource name="warning_hotkeys">The hotkey(s) "{0}" could not be registered. This problem is probably caused by another tool claiming usage of the same hotkey(s)! You could either change your hotkey settings or deactivate/change the software making use of the hotkey(s).
All Greenshot features still work directly from the tray icon context menu without hotkeys.</resource>
<resource name="WindowCaptureMode.Aero">Use custom color</resource>
<resource name="WindowCaptureMode.AeroTransparent">Preserve transparency</resource>

View file

@ -11,6 +11,7 @@ Features:
* General: Added Special-Folder support for the OutputPath/Filenames, now one can use the following values: MyPictures, MyMusic, MyDocuments, Personal, Desktop, ApplicationData, LocalApplicationData. Meaning one can now set the output path to e.g. ${MyPictures}
* Editor: The capture is now displayed in the center of the editor, the code for this was supplied by Viktar Karpach.
* Editor: Added horizontal and vertical alignment for text boxes.
* Printing: Added option to force monochrome (black/white) print
* Plug-in: Added Photobucket plugin
* Plug-in: Removed unneeded code from the Confluence Plug-in, this makes the Greenshot installer / .zip a bit smaller.

View file

@ -137,9 +137,13 @@ namespace GreenshotPlugin.Core {
public bool OutputPrintCenter;
[IniProperty("OutputPrintInverted", LanguageKey="printoptions_inverted", Description="Print image inverted (use e.g. for console captures)", DefaultValue="false")]
public bool OutputPrintInverted;
[IniProperty("OutputPrintGrayscale", LanguageKey = "printoptions_printgrayscale", Description = "Force grayscale printing", DefaultValue = "false")]
public bool OutputPrintGrayscale;
[IniProperty("OutputPrintFooter", LanguageKey = "printoptions_timestamp", Description = "Print footer on print?", DefaultValue = "true")]
[IniProperty("OutputPrintGrayscale", LanguageKey = "printoptions_printgrayscale", Description = "Force grayscale printing", DefaultValue = "false")]
public bool OutputPrintGrayscale;
[IniProperty("OutputPrintMonochrome", LanguageKey = "printoptions_printmonochrome", Description = "Force monorchrome printing", DefaultValue = "false")]
public bool OutputPrintMonochrome;
[IniProperty("OutputPrintMonochromeThreshold", Description = "Threshold for monochrome filter (0 - 255), lower value means less black", DefaultValue = "127")]
public byte OutputPrintMonochromeThreshold;
[IniProperty("OutputPrintFooter", LanguageKey = "printoptions_timestamp", Description = "Print footer on print?", DefaultValue = "true")]
public bool OutputPrintFooter;
[IniProperty("OutputPrintFooterPattern", Description = "Footer pattern", DefaultValue = "${capturetime:d\"D\"} ${capturetime:d\"T\"} - ${title}")]
public string OutputPrintFooterPattern;

View file

@ -105,9 +105,14 @@ namespace Greenshot.Core {
/// MonochromeEffect
/// </summary>
public class MonochromeEffect : IEffect {
private byte threshold;
/// <param name="threshold">Threshold for monochrome filter (0 - 255), lower value means less black</param>
public MonochromeEffect(byte threshold) {
this.threshold = threshold;
}
public Image Apply(Image sourceImage, out Point offsetChange) {
offsetChange = Point.Empty;
return ImageHelper.CreateMonochrome(sourceImage);
return ImageHelper.CreateMonochrome(sourceImage, threshold);
}
}

View file

@ -883,15 +883,16 @@ namespace GreenshotPlugin.Core {
/// <summary>
/// Returns a b/w of Bitmap
/// </summary>
/// <param name="sourceImage">Bitmap to create a b/w off</param>
/// <param name="sourceImage">Bitmap to create a b/w of</param>
/// <param name="threshold">Threshold for monochrome filter (0 - 255), lower value means less black</param>
/// <returns>b/w bitmap</returns>
public static Bitmap CreateMonochrome(Image sourceImage) {
public static Bitmap CreateMonochrome(Image sourceImage, byte threshold) {
using (IFastBitmap fastBitmap = FastBitmap.CreateCloneOf(sourceImage, sourceImage.PixelFormat)) {
fastBitmap.Lock();
for (int y = 0; y < fastBitmap.Height; y++) {
for (int x = 0; x < fastBitmap.Width; x++) {
Color color = fastBitmap.GetColorAt(x, y);
int colorBrightness = (color.R + color.G + color.B > 382) ? 255 : 0;
int colorBrightness = ((color.R + color.G + color.B) / 3 > threshold) ? 255 : 0;
Color monoColor = Color.FromArgb(color.A, colorBrightness, colorBrightness, colorBrightness);
fastBitmap.SetColorAt(x, y, monoColor);
}