// Convert an XImage into a Pixmap object. public static Pixmap XImageToPixmap(Screen screen, IntPtr ximage) { int width, height; Xlib.XSharpGetImageSize(ximage, out width, out height); Pixmap pixmap = new Pixmap(screen, width, height); Graphics graphics = new Graphics(pixmap); graphics.PutXImage(ximage, 0, 0, 0, 0, width, height); graphics.Dispose(); return pixmap; }
// Convert an XImage mask into a Bitmap object. public static Bitmap XImageMaskToBitmap(Screen screen, IntPtr ximage) { int width, height; Xlib.XSharpGetImageSize(ximage, out width, out height); Bitmap bitmap = new Bitmap(screen, width, height); Graphics graphics = new Graphics(bitmap); graphics.PutXImage(ximage, 0, 0, 0, 0, width, height); graphics.Dispose(); return bitmap; }