[Spice-devel] [vdagent-win PATCH] vdagent: use HBITMAP instead of DIB for image encoding

Arnon Gilboa agilboa at redhat.com
Tue Mar 12 05:00:01 PDT 2013


CxImage DIB to PNG encoding seems to ignore pallete in some scenarios.
This issue happens when copying a png from FireFox, but with IE it's ok.

rhbz #919150
---
 vdagent/vdagent.cpp |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp
index 722815c..6f2a49c 100644
--- a/vdagent/vdagent.cpp
+++ b/vdagent/vdagent.cpp
@@ -42,7 +42,7 @@ typedef struct VDClipboardFormat {
 VDClipboardFormat clipboard_formats[] = {
     {CF_UNICODETEXT, {VD_AGENT_CLIPBOARD_UTF8_TEXT, 0}},
     //FIXME: support more image types
-    {CF_DIB, {VD_AGENT_CLIPBOARD_IMAGE_PNG, VD_AGENT_CLIPBOARD_IMAGE_BMP, 0}},
+    {CF_BITMAP, {VD_AGENT_CLIPBOARD_IMAGE_PNG, VD_AGENT_CLIPBOARD_IMAGE_BMP, 0}},
 };
 
 #define clipboard_formats_count (sizeof(clipboard_formats) / sizeof(clipboard_formats[0]))
@@ -1025,8 +1025,13 @@ bool VDAgent::handle_clipboard_request(VDAgentClipboardRequest* clipboard_reques
     case VD_AGENT_CLIPBOARD_IMAGE_PNG:
     case VD_AGENT_CLIPBOARD_IMAGE_BMP: {
         DWORD cximage_format = get_cximage_format(clipboard_request->type);
-        ASSERT(cximage_format);
-        if (!image.CreateFromHANDLE(clip_data)) {
+        HPALETTE pal = 0;
+
+        ASSERT(cximage_format);
+        if (IsClipboardFormatAvailable(CF_PALETTE)) {
+            pal = (HPALETTE)GetClipboardData(CF_PALETTE);
+        }
+        if (!image.CreateFromHBITMAP((HBITMAP)clip_data, pal)) {
             vd_printf("Image create from handle failed");
             break;
         }
-- 
1.7.7.6



More information about the Spice-devel mailing list