winex11: Use the create_pixmap_from_image helper to export XA_PIXMAP clipboard formats.

This commit is contained in:
Alexandre Julliard 2012-05-11 15:27:04 +02:00
parent bf2ad337b5
commit e85895e4c5

View File

@ -1758,7 +1758,6 @@ static HANDLE X11DRV_CLIPBOARD_ExportString(Display *display, Window requestor,
static HANDLE X11DRV_CLIPBOARD_ExportXAPIXMAP(Display *display, Window requestor, Atom aTarget, Atom rprop, static HANDLE X11DRV_CLIPBOARD_ExportXAPIXMAP(Display *display, Window requestor, Atom aTarget, Atom rprop,
LPWINE_CLIPDATA lpdata, LPDWORD lpBytes) LPWINE_CLIPDATA lpdata, LPDWORD lpBytes)
{ {
HDC hdc, memdc;
HANDLE hData; HANDLE hData;
unsigned char* lpData; unsigned char* lpData;
@ -1770,33 +1769,26 @@ static HANDLE X11DRV_CLIPBOARD_ExportXAPIXMAP(Display *display, Window requestor
if (!lpdata->drvData) /* If not already rendered */ if (!lpdata->drvData) /* If not already rendered */
{ {
/* Create a DDB from the DIB */ Pixmap pixmap;
XVisualInfo vis;
Pixmap pixmap = 0;
X_PHYSBITMAP *physBitmap;
HBITMAP hBmp;
LPBITMAPINFO pbmi; LPBITMAPINFO pbmi;
struct gdi_image_bits bits;
memset( &vis, 0, sizeof(vis) );
vis.visual = visual;
vis.depth = screen_depth;
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;
hdc = GetDC(0);
pbmi = GlobalLock( lpdata->hData ); pbmi = GlobalLock( lpdata->hData );
hBmp = CreateDIBitmap( hdc, &pbmi->bmiHeader, CBM_INIT, bits.ptr = (LPBYTE)pbmi + bitmap_info_size( pbmi, DIB_RGB_COLORS );
(LPBYTE)pbmi + bitmap_info_size( pbmi, DIB_RGB_COLORS ), bits.free = NULL;
pbmi, DIB_RGB_COLORS ); bits.is_copy = FALSE;
pixmap = create_pixmap_from_image( 0, &vis, pbmi, &bits, DIB_RGB_COLORS );
GlobalUnlock( lpdata->hData ); GlobalUnlock( lpdata->hData );
/* make sure it's owned by x11drv */
memdc = CreateCompatibleDC( hdc );
SelectObject( memdc, hBmp );
DeleteDC( memdc );
/* clear the physBitmap so that we can steal its pixmap */
if ((physBitmap = X11DRV_get_phys_bitmap( hBmp )))
{
pixmap = physBitmap->pixmap;
physBitmap->pixmap = 0;
}
DeleteObject( hBmp );
ReleaseDC( 0, hdc );
lpdata->drvData = pixmap; lpdata->drvData = pixmap;
} }