/// <summary> Provide a bitmap, containing the transparent graphic, that can be used independent from this class. </summary> /// <param name="display"> The display pointer, that specifies the connection to the X server. <see cref="System.IntPtr"/> </param> /// <param name="window"> The target window to create the pixmap for. <see cref="IntPtr"/> </param> /// <param name="backgroundColorPixel"> The background color behind any transparent pixel. <see cref="TPixel"/> </param> /// <param name="maskPixmap"> The mask pixmap to distinguish transparent from intransparent pixel. <see cref="IntPtr"/> </param> /// <returns> The (server side) pixmap (that must be feed) on success, or IntPtr.Zero otherwise. <see cref="IntPtr"/> </returns> public IntPtr CreateIndependentPixmap(IntPtr display, IntPtr window, TPixel backgroundColorPixel, IntPtr maskPixmap) { if (_graphicXImage == IntPtr.Zero) { return(IntPtr.Zero); } IntPtr pixmap = X11lib.XCreatePixmap(display, window, (TUint)_width, (TUint)_height, (TUint)_graphicDepth); // Fill pixmap with background color. IntPtr bgGc = X11lib.XCreateGC(display, window, (TUlong)0, IntPtr.Zero); X11lib.XSetForeground(display, bgGc, backgroundColorPixel); X11lib.XFillRectangle(display, pixmap, bgGc, (TInt)0, (TInt)0, (TUint)_width, (TUint)_height); X11lib.XFreeGC(display, bgGc); bgGc = IntPtr.Zero; // Overlay the image. IntPtr pixmapGc = X11lib.XCreateGC(display, window, (TUlong)0, IntPtr.Zero); if (pixmapGc != IntPtr.Zero) { if (maskPixmap != IntPtr.Zero) { // Prepare the clipping graphics context. IntPtr graphicGc = X11lib.XCreateGC(display, window, (TUlong)0, IntPtr.Zero); if (graphicGc != IntPtr.Zero) { X11lib.XSetClipMask(display, graphicGc, maskPixmap); X11lib.XSetClipOrigin(display, graphicGc, (TInt)0, (TInt)0); // Draw graphic using the clipping graphics context. X11lib.XPutImage(display, pixmap, graphicGc, _graphicXImage, (TInt)0, (TInt)0, (TInt)0, (TInt)0, (TUint)_width, (TUint)_height); // Restore previous behaviour and clean up. X11lib.XSetClipMask(display, graphicGc, IntPtr.Zero); X11lib.XSetClipOrigin(display, graphicGc, (TInt)0, (TInt)0); // Console.WriteLine (CLASS_NAME + "::Draw () Delete clipping image GC."); X11lib.XFreeGC(display, graphicGc); graphicGc = IntPtr.Zero; } else { Console.WriteLine(CLASS_NAME + "::Draw () ERROR: Can not create graphics context for transparency application."); } } else { X11lib.XPutImage(display, pixmap, pixmapGc, _graphicXImage, (TInt)0, (TInt)0, (TInt)0, (TInt)0, (TUint)_width, (TUint)_height); // Console.WriteLine (CLASS_NAME + "::CreateIndependentGraphicPixmap () Delete graphic image GC."); X11lib.XFreeGC(display, pixmapGc); pixmapGc = IntPtr.Zero; } } else { Console.WriteLine(CLASS_NAME + "::CreateIndependentGraphicPixmap () ERROR: Can not create graphics context for graphic pixmap."); } return(pixmap); }