Commit 95de085e authored by Alexandre Julliard's avatar Alexandre Julliard

winex11: Use the get_pixmap_image helper to import XA_PIXMAP clipboard formats.

parent f99af0bb
...@@ -1328,10 +1328,10 @@ static HANDLE X11DRV_CLIPBOARD_ImportXAPIXMAP(Display *display, Window w, Atom p ...@@ -1328,10 +1328,10 @@ static HANDLE X11DRV_CLIPBOARD_ImportXAPIXMAP(Display *display, Window w, Atom p
if (X11DRV_CLIPBOARD_ReadProperty(display, w, prop, &lpdata, &cbytes)) if (X11DRV_CLIPBOARD_ReadProperty(display, w, prop, &lpdata, &cbytes))
{ {
HDC hdcMem; XVisualInfo vis;
X_PHYSBITMAP *physBitmap; char buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )];
Pixmap orig_pixmap; BITMAPINFO *info = (BITMAPINFO *)buffer;
HBITMAP hBmp = 0; struct gdi_image_bits bits;
Window root; Window root;
int x,y; /* Unused */ int x,y; /* Unused */
unsigned border_width; /* Unused */ unsigned border_width; /* Unused */
...@@ -1349,37 +1349,54 @@ static HANDLE X11DRV_CLIPBOARD_ImportXAPIXMAP(Display *display, Window w, Atom p ...@@ -1349,37 +1349,54 @@ static HANDLE X11DRV_CLIPBOARD_ImportXAPIXMAP(Display *display, Window w, Atom p
TRACE("\tPixmap properties: width=%d, height=%d, depth=%d\n", TRACE("\tPixmap properties: width=%d, height=%d, depth=%d\n",
width, height, depth); width, height, depth);
/* memset( &vis, 0, sizeof(vis) );
* Create an HBITMAP with the same dimensions and BPP as the pixmap, vis.depth = depth;
* and make it a container for the pixmap passed. if (depth == screen_depth)
*/ {
if (!(hBmp = CreateBitmap( width, height, 1, pixmap_formats[depth]->bits_per_pixel, NULL ))) vis.visual = visual;
vis.visualid = visual->visualid;
vis.class = visual->class;
vis.red_mask = visual->red_mask;
vis.green_mask = visual->green_mask;
vis.blue_mask = visual->blue_mask;
}
else switch (pixmap_formats[depth]->bits_per_pixel)
{
case 1:
case 4:
case 8:
break;
case 16: /* assume R5G5B5 */
vis.red_mask = 0x7c00;
vis.green_mask = 0x03e0;
vis.blue_mask = 0x001f;
break;
case 24: /* assume R8G8B8 */
case 32: /* assume A8R8G8B8 */
vis.red_mask = 0xff0000;
vis.green_mask = 0x00ff00;
vis.blue_mask = 0x0000ff;
break;
default:
return 0; return 0;
}
/* force bitmap to be owned by a screen DC */ if (!get_pixmap_image( *pPixmap, width, height, &vis, info, &bits ))
hdcMem = CreateCompatibleDC( 0 ); {
SelectObject( hdcMem, SelectObject( hdcMem, hBmp )); DWORD info_size = bitmap_info_size( info, DIB_RGB_COLORS );
DeleteDC( hdcMem ); BYTE *ptr;
physBitmap = X11DRV_get_phys_bitmap( hBmp );
/* swap the new pixmap in */
orig_pixmap = physBitmap->pixmap;
physBitmap->pixmap = *pPixmap;
/*
* Create a packed DIB from the Pixmap wrapper bitmap created above.
* A packed DIB contains a BITMAPINFO structure followed immediately by
* an optional color palette and the pixel data.
*/
hClipData = create_dib_from_bitmap( hBmp );
/* we can now get rid of the HBITMAP and its original pixmap */
physBitmap->pixmap = orig_pixmap;
DeleteObject(hBmp);
/* Free the retrieved property data */ hClipData = GlobalAlloc( GMEM_MOVEABLE | GMEM_DDESHARE,
HeapFree(GetProcessHeap(), 0, lpdata); info_size + info->bmiHeader.biSizeImage );
if (hClipData)
{
ptr = GlobalLock( hClipData );
memcpy( ptr, info, info_size );
memcpy( ptr + info_size, bits.ptr, info->bmiHeader.biSizeImage );
GlobalUnlock( hClipData );
}
if (bits.free) bits.free( &bits );
}
} }
return hClipData; return hClipData;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment