mirror of
https://github.com/greenshot/greenshot
synced 2025-07-15 17:43:44 -07:00
Tested the fixes for bug #3576125, this now should work... although there might be some cases where reading the clipboard doesn't work as supposed. I added a configuration setting, but didn't add it to the expert settings due to a lack of "space". (Did fix the spacing of the checkboxes though)
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2198 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
cbf04192b6
commit
3e9b5b91c5
5 changed files with 57 additions and 34 deletions
|
@ -121,7 +121,7 @@ namespace Greenshot {
|
||||||
for(int argumentNr = 0; argumentNr < args.Length; argumentNr++) {
|
for(int argumentNr = 0; argumentNr < args.Length; argumentNr++) {
|
||||||
string argument = args[argumentNr];
|
string argument = args[argumentNr];
|
||||||
// Help
|
// Help
|
||||||
if (argument.ToLower().Equals("/help")) {
|
if (argument.ToLower().Equals("/help") || argument.ToLower().Equals("/h") || argument.ToLower().Equals("/?")) {
|
||||||
// Try to attach to the console
|
// Try to attach to the console
|
||||||
bool attachedToConsole = Kernel32.AttachConsole(Kernel32.ATTACHCONSOLE_ATTACHPARENTPROCESS);
|
bool attachedToConsole = Kernel32.AttachConsole(Kernel32.ATTACHCONSOLE_ATTACHPARENTPROCESS);
|
||||||
// If attach didn't work, open a console
|
// If attach didn't work, open a console
|
||||||
|
|
18
Greenshot/Forms/SettingsForm.Designer.cs
generated
18
Greenshot/Forms/SettingsForm.Designer.cs
generated
|
@ -1019,31 +1019,31 @@ namespace Greenshot {
|
||||||
// checkbox_reuseeditor
|
// checkbox_reuseeditor
|
||||||
//
|
//
|
||||||
this.checkbox_reuseeditor.LanguageKey = "expertsettings_reuseeditorifpossible";
|
this.checkbox_reuseeditor.LanguageKey = "expertsettings_reuseeditorifpossible";
|
||||||
this.checkbox_reuseeditor.Location = new System.Drawing.Point(10, 231);
|
this.checkbox_reuseeditor.Location = new System.Drawing.Point(10, 225);
|
||||||
this.checkbox_reuseeditor.Name = "checkbox_reuseeditor";
|
this.checkbox_reuseeditor.Name = "checkbox_reuseeditor";
|
||||||
this.checkbox_reuseeditor.PropertyName = "ReuseEditor";
|
this.checkbox_reuseeditor.PropertyName = "ReuseEditor";
|
||||||
this.checkbox_reuseeditor.SectionName = "Editor";
|
this.checkbox_reuseeditor.SectionName = "Editor";
|
||||||
this.checkbox_reuseeditor.Size = new System.Drawing.Size(394, 19);
|
this.checkbox_reuseeditor.Size = new System.Drawing.Size(394, 24);
|
||||||
this.checkbox_reuseeditor.TabIndex = 31;
|
this.checkbox_reuseeditor.TabIndex = 31;
|
||||||
this.checkbox_reuseeditor.UseVisualStyleBackColor = true;
|
this.checkbox_reuseeditor.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
// checkbox_minimizememoryfootprint
|
// checkbox_minimizememoryfootprint
|
||||||
//
|
//
|
||||||
this.checkbox_minimizememoryfootprint.LanguageKey = "expertsettings_minimizememoryfootprint";
|
this.checkbox_minimizememoryfootprint.LanguageKey = "expertsettings_minimizememoryfootprint";
|
||||||
this.checkbox_minimizememoryfootprint.Location = new System.Drawing.Point(10, 211);
|
this.checkbox_minimizememoryfootprint.Location = new System.Drawing.Point(10, 206);
|
||||||
this.checkbox_minimizememoryfootprint.Name = "checkbox_minimizememoryfootprint";
|
this.checkbox_minimizememoryfootprint.Name = "checkbox_minimizememoryfootprint";
|
||||||
this.checkbox_minimizememoryfootprint.PropertyName = "MinimizeWorkingSetSize";
|
this.checkbox_minimizememoryfootprint.PropertyName = "MinimizeWorkingSetSize";
|
||||||
this.checkbox_minimizememoryfootprint.Size = new System.Drawing.Size(394, 19);
|
this.checkbox_minimizememoryfootprint.Size = new System.Drawing.Size(394, 24);
|
||||||
this.checkbox_minimizememoryfootprint.TabIndex = 30;
|
this.checkbox_minimizememoryfootprint.TabIndex = 30;
|
||||||
this.checkbox_minimizememoryfootprint.UseVisualStyleBackColor = true;
|
this.checkbox_minimizememoryfootprint.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
// checkbox_checkunstableupdates
|
// checkbox_checkunstableupdates
|
||||||
//
|
//
|
||||||
this.checkbox_checkunstableupdates.LanguageKey = "expertsettings_checkunstableupdates";
|
this.checkbox_checkunstableupdates.LanguageKey = "expertsettings_checkunstableupdates";
|
||||||
this.checkbox_checkunstableupdates.Location = new System.Drawing.Point(10, 191);
|
this.checkbox_checkunstableupdates.Location = new System.Drawing.Point(10, 187);
|
||||||
this.checkbox_checkunstableupdates.Name = "checkbox_checkunstableupdates";
|
this.checkbox_checkunstableupdates.Name = "checkbox_checkunstableupdates";
|
||||||
this.checkbox_checkunstableupdates.PropertyName = "CheckUnstable";
|
this.checkbox_checkunstableupdates.PropertyName = "CheckUnstable";
|
||||||
this.checkbox_checkunstableupdates.Size = new System.Drawing.Size(394, 19);
|
this.checkbox_checkunstableupdates.Size = new System.Drawing.Size(394, 24);
|
||||||
this.checkbox_checkunstableupdates.TabIndex = 29;
|
this.checkbox_checkunstableupdates.TabIndex = 29;
|
||||||
this.checkbox_checkunstableupdates.UseVisualStyleBackColor = true;
|
this.checkbox_checkunstableupdates.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
|
@ -1064,7 +1064,7 @@ namespace Greenshot {
|
||||||
this.label_counter.LanguageKey = "expertsettings_counter";
|
this.label_counter.LanguageKey = "expertsettings_counter";
|
||||||
this.label_counter.Location = new System.Drawing.Point(7, 285);
|
this.label_counter.Location = new System.Drawing.Point(7, 285);
|
||||||
this.label_counter.Name = "label_counter";
|
this.label_counter.Name = "label_counter";
|
||||||
this.label_counter.Size = new System.Drawing.Size(0, 13);
|
this.label_counter.Size = new System.Drawing.Size(246, 13);
|
||||||
this.label_counter.TabIndex = 27;
|
this.label_counter.TabIndex = 27;
|
||||||
//
|
//
|
||||||
// textbox_counter
|
// textbox_counter
|
||||||
|
@ -1081,7 +1081,7 @@ namespace Greenshot {
|
||||||
this.label_footerpattern.LanguageKey = "expertsettings_footerpattern";
|
this.label_footerpattern.LanguageKey = "expertsettings_footerpattern";
|
||||||
this.label_footerpattern.Location = new System.Drawing.Point(7, 259);
|
this.label_footerpattern.Location = new System.Drawing.Point(7, 259);
|
||||||
this.label_footerpattern.Name = "label_footerpattern";
|
this.label_footerpattern.Name = "label_footerpattern";
|
||||||
this.label_footerpattern.Size = new System.Drawing.Size(0, 13);
|
this.label_footerpattern.Size = new System.Drawing.Size(103, 13);
|
||||||
this.label_footerpattern.TabIndex = 25;
|
this.label_footerpattern.TabIndex = 25;
|
||||||
//
|
//
|
||||||
// textbox_footerpattern
|
// textbox_footerpattern
|
||||||
|
@ -1128,7 +1128,7 @@ namespace Greenshot {
|
||||||
this.label_clipboardformats.LanguageKey = "expertsettings_clipboardformats";
|
this.label_clipboardformats.LanguageKey = "expertsettings_clipboardformats";
|
||||||
this.label_clipboardformats.Location = new System.Drawing.Point(7, 39);
|
this.label_clipboardformats.Location = new System.Drawing.Point(7, 39);
|
||||||
this.label_clipboardformats.Name = "label_clipboardformats";
|
this.label_clipboardformats.Name = "label_clipboardformats";
|
||||||
this.label_clipboardformats.Size = new System.Drawing.Size(0, 13);
|
this.label_clipboardformats.Size = new System.Drawing.Size(88, 13);
|
||||||
this.label_clipboardformats.TabIndex = 20;
|
this.label_clipboardformats.TabIndex = 20;
|
||||||
//
|
//
|
||||||
// checkbox_enableexpert
|
// checkbox_enableexpert
|
||||||
|
|
|
@ -38,8 +38,7 @@ namespace GreenshotPlugin.Core {
|
||||||
int size = Marshal.SizeOf(typeof(T));
|
int size = Marshal.SizeOf(typeof(T));
|
||||||
ptr = Marshal.AllocHGlobal(size);
|
ptr = Marshal.AllocHGlobal(size);
|
||||||
Marshal.Copy(bytes, 0, ptr, size);
|
Marshal.Copy(bytes, 0, ptr, size);
|
||||||
object obj = Marshal.PtrToStructure(ptr, typeof(T));
|
return FromIntPtr<T>(ptr);
|
||||||
return (T)obj;
|
|
||||||
} finally {
|
} finally {
|
||||||
if (ptr != IntPtr.Zero) {
|
if (ptr != IntPtr.Zero) {
|
||||||
Marshal.FreeHGlobal(ptr);
|
Marshal.FreeHGlobal(ptr);
|
||||||
|
@ -47,6 +46,17 @@ namespace GreenshotPlugin.Core {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get a struct from a byte array
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">typeof struct</typeparam>
|
||||||
|
/// <param name="bytes">byte[]</param>
|
||||||
|
/// <returns>struct</returns>
|
||||||
|
public static T FromIntPtr<T>(IntPtr intPtr) where T : struct {
|
||||||
|
object obj = Marshal.PtrToStructure(intPtr, typeof(T));
|
||||||
|
return (T)obj;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// copy a struct to a byte array
|
/// copy a struct to a byte array
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -59,14 +69,25 @@ namespace GreenshotPlugin.Core {
|
||||||
int size = Marshal.SizeOf(typeof(T));
|
int size = Marshal.SizeOf(typeof(T));
|
||||||
ptr = Marshal.AllocHGlobal(size);
|
ptr = Marshal.AllocHGlobal(size);
|
||||||
Marshal.StructureToPtr(obj, ptr, true);
|
Marshal.StructureToPtr(obj, ptr, true);
|
||||||
byte[] bytes = new byte[size];
|
return FromPtrToByteArray<T>(ptr);
|
||||||
Marshal.Copy(ptr, bytes, 0, size);
|
|
||||||
return bytes;
|
|
||||||
} finally {
|
} finally {
|
||||||
if (ptr != IntPtr.Zero) {
|
if (ptr != IntPtr.Zero) {
|
||||||
Marshal.FreeHGlobal(ptr);
|
Marshal.FreeHGlobal(ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// copy a struct from a pointer to a byte array
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">typeof struct</typeparam>
|
||||||
|
/// <param name="ptr">IntPtr to struct</param>
|
||||||
|
/// <returns>byte[]</returns>
|
||||||
|
public static byte[] FromPtrToByteArray<T>(IntPtr ptr) where T : struct {
|
||||||
|
int size = Marshal.SizeOf(typeof(T));
|
||||||
|
byte[] bytes = new byte[size];
|
||||||
|
Marshal.Copy(ptr, bytes, 0, size);
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,31 +241,33 @@ EndSelection:<<<<<<<4
|
||||||
// If the EnableSpecialDIBClipboardReader flag in the config is set, use the code from:
|
// If the EnableSpecialDIBClipboardReader flag in the config is set, use the code from:
|
||||||
// http://www.thomaslevesque.com/2009/02/05/wpf-paste-an-image-from-the-clipboard/
|
// http://www.thomaslevesque.com/2009/02/05/wpf-paste-an-image-from-the-clipboard/
|
||||||
// to read the DeviceIndependentBitmap from the clipboard, this might fix bug 3576125
|
// to read the DeviceIndependentBitmap from the clipboard, this might fix bug 3576125
|
||||||
if (config.EnableSpecialDIBClipboardReader) {
|
if (config.EnableSpecialDIBClipboardReader && formats.Contains("DeviceIndependentBitmap")) {
|
||||||
MemoryStream ms = Clipboard.GetData("DeviceIndependentBitmap") as MemoryStream;
|
MemoryStream ms = GetClipboardData("DeviceIndependentBitmap") as MemoryStream;
|
||||||
if (ms != null) {
|
if (ms != null) {
|
||||||
byte[] dibBuffer = new byte[ms.Length];
|
byte[] dibBuffer = new byte[ms.Length];
|
||||||
ms.Read(dibBuffer, 0, dibBuffer.Length);
|
ms.Read(dibBuffer, 0, dibBuffer.Length);
|
||||||
BitmapInfoHeader infoHeader = BinaryStructHelper.FromByteArray<BitmapInfoHeader>(dibBuffer);
|
BitmapInfoHeader infoHeader = BinaryStructHelper.FromByteArray<BitmapInfoHeader>(dibBuffer);
|
||||||
|
// Only use this code, when the biCommpression != 0 (BI_RGB)
|
||||||
|
if (infoHeader.biCompression != 0) {
|
||||||
|
int fileHeaderSize = Marshal.SizeOf(typeof(BitmapFileHeader));
|
||||||
|
uint infoHeaderSize = infoHeader.biSize;
|
||||||
|
int fileSize = (int)(fileHeaderSize + infoHeader.biSize + infoHeader.biSizeImage);
|
||||||
|
|
||||||
int fileHeaderSize = Marshal.SizeOf(typeof(BitmapFileHeader));
|
BitmapFileHeader fileHeader = new BitmapFileHeader();
|
||||||
uint infoHeaderSize = infoHeader.biSize;
|
fileHeader.bfType = BitmapFileHeader.BM;
|
||||||
int fileSize = (int)(fileHeaderSize + infoHeader.biSize + infoHeader.biSizeImage);
|
fileHeader.bfSize = fileSize;
|
||||||
|
fileHeader.bfReserved1 = 0;
|
||||||
|
fileHeader.bfReserved2 = 0;
|
||||||
|
fileHeader.bfOffBits = (int)(fileHeaderSize + infoHeaderSize + infoHeader.biClrUsed * 4);
|
||||||
|
|
||||||
BitmapFileHeader fileHeader = new BitmapFileHeader();
|
byte[] fileHeaderBytes = BinaryStructHelper.ToByteArray<BitmapFileHeader>(fileHeader);
|
||||||
fileHeader.bfType = BitmapFileHeader.BM;
|
|
||||||
fileHeader.bfSize = fileSize;
|
|
||||||
fileHeader.bfReserved1 = 0;
|
|
||||||
fileHeader.bfReserved2 = 0;
|
|
||||||
fileHeader.bfOffBits = (int)(fileHeaderSize + infoHeaderSize + infoHeader.biClrUsed * 4);
|
|
||||||
|
|
||||||
byte[] fileHeaderBytes = BinaryStructHelper.ToByteArray<BitmapFileHeader>(fileHeader);
|
using (MemoryStream msBitmap = new MemoryStream()) {
|
||||||
|
msBitmap.Write(fileHeaderBytes, 0, fileHeaderSize);
|
||||||
using (MemoryStream msBitmap = new MemoryStream()) {
|
msBitmap.Write(dibBuffer, 0, dibBuffer.Length);
|
||||||
msBitmap.Write(fileHeaderBytes, 0, fileHeaderSize);
|
msBitmap.Seek(0, SeekOrigin.Begin);
|
||||||
msBitmap.Write(dibBuffer, 0, dibBuffer.Length);
|
return Image.FromStream(msBitmap);
|
||||||
msBitmap.Seek(0, SeekOrigin.Begin);
|
}
|
||||||
return Image.FromStream(msBitmap);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,7 +191,7 @@ namespace GreenshotPlugin.Core {
|
||||||
[IniProperty("ExperimentalFeatures", Description="A list of experimental features, this allows us to test certain features before releasing them.", ExcludeIfNull=true)]
|
[IniProperty("ExperimentalFeatures", Description="A list of experimental features, this allows us to test certain features before releasing them.", ExcludeIfNull=true)]
|
||||||
public List<string> ExperimentalFeatures;
|
public List<string> ExperimentalFeatures;
|
||||||
|
|
||||||
[IniProperty("EnableSpecialDIBClipboardReader", Description = "Enable a special DIB clipboard reader", DefaultValue="False")]
|
[IniProperty("EnableSpecialDIBClipboardReader", Description = "Enable a special DIB clipboard reader", DefaultValue="True")]
|
||||||
public bool EnableSpecialDIBClipboardReader;
|
public bool EnableSpecialDIBClipboardReader;
|
||||||
|
|
||||||
// Specify what THIS build is
|
// Specify what THIS build is
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue