mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-02 18:26:27 +13:00
Merge pull request #1203 from oxysoft/master
Fixed transparency for clipboard upload
This commit is contained in:
commit
1445b11727
1 changed files with 31 additions and 1 deletions
|
@ -29,8 +29,10 @@ You should have received a copy of the GNU General Public License
|
||||||
using ShareX.UploadersLib;
|
using ShareX.UploadersLib;
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
@ -173,7 +175,35 @@ public static void ClipboardUpload(TaskSettings taskSettings = null)
|
||||||
|
|
||||||
if (Clipboard.ContainsImage())
|
if (Clipboard.ContainsImage())
|
||||||
{
|
{
|
||||||
Image img = Clipboard.GetImage();
|
IDataObject data = Clipboard.GetDataObject();
|
||||||
|
|
||||||
|
byte[] stream = ((MemoryStream)Clipboard.GetData(DataFormats.Dib)).ToArray();
|
||||||
|
int w = BitConverter.ToInt32(stream, 4);
|
||||||
|
int h = BitConverter.ToInt32(stream, 8);
|
||||||
|
short bpp = BitConverter.ToInt16(stream, 14);
|
||||||
|
|
||||||
|
Image img = null;
|
||||||
|
|
||||||
|
if (bpp == 32)
|
||||||
|
{
|
||||||
|
var gch = GCHandle.Alloc(stream, GCHandleType.Pinned);
|
||||||
|
Bitmap bmp = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var ptr = new IntPtr((long)gch.AddrOfPinnedObject() + 40);
|
||||||
|
bmp = new Bitmap(w, h, w * 4, PixelFormat.Format32bppArgb, ptr);
|
||||||
|
img = (Image) bmp.Clone();
|
||||||
|
img.RotateFlip(RotateFlipType.Rotate180FlipX);
|
||||||
|
} finally
|
||||||
|
{
|
||||||
|
gch.Free();
|
||||||
|
if (bmp != null) bmp.Dispose();
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
img = Clipboard.GetImage();
|
||||||
|
}
|
||||||
|
|
||||||
if (img != null)
|
if (img != null)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue