From 5f10407c8c988041cb41db14e1bfc6be46415b11 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Thu, 14 Feb 2019 22:42:55 +0100 Subject: [PATCH] Preserve transparency when copying a DIB to/from the clipboard. In order to get the alpha channel when encoding BMP images from a surface, we need to supply bmp=32 in the encoder options. --- widget/windows/nsDataObj.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/widget/windows/nsDataObj.cpp b/widget/windows/nsDataObj.cpp index f5470e828e..a1be1f96e1 100644 --- a/widget/windows/nsDataObj.cpp +++ b/widget/windows/nsDataObj.cpp @@ -921,7 +921,7 @@ nsDataObj::GetDib(const nsACString& inFlavor, if ( image ) { nsCOMPtr imgTools = do_CreateInstance("@mozilla.org/image/tools;1"); - nsAutoString options; + nsAutoString options(NS_LITERAL_STRING("bpp=32;")); if (aFormat.cfFormat == CF_DIBV5) { options.AppendLiteral("version=5"); } else { @@ -1581,7 +1581,7 @@ HRESULT nsDataObj::DropImage(FORMATETC& aFE, STGMEDIUM& aSTG) nsCOMPtr imgTools = do_CreateInstance("@mozilla.org/image/tools;1"); nsCOMPtr inputStream; rv = imgTools->EncodeImage(image, NS_LITERAL_CSTRING(IMAGE_BMP), - NS_LITERAL_STRING("version=3"), + NS_LITERAL_STRING("bpp=32;version=3"), getter_AddRefs(inputStream)); if (NS_FAILED(rv) || !inputStream) { return E_FAIL;