[Spice-commits] vdagent/vdagent.cpp

Arnon Gilboa agilboa at kemper.freedesktop.org
Tue Mar 12 06:26:51 PDT 2013


 vdagent/vdagent.cpp |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

New commits:
commit da07ced71c864992a5806524f010fd8c2fb8c835
Author: Arnon Gilboa <agilboa at redhat.com>
Date:   Tue Mar 12 13:01:03 2013 +0200

    vdagent: use HBITMAP instead of DIB for image encoding
    
    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

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;
         }


More information about the Spice-commits mailing list