示例#1
0
        // Convert an image frame into an XImage.
        public static IntPtr FrameToXImage(Screen screen, Frame frame)
        {
            int[]    fpalette;
            XPixel[] palette;
            int      index, color;
            Colormap colormap = screen.DefaultColormap;

            // Create a palette to use to render the image.
            fpalette = frame.Palette;
            if (fpalette != null)
            {
                // Convert the palette within the image frame itself.
                palette = new XPixel [256];
                for (index = 0; index < 256 && index < fpalette.Length;
                     ++index)
                {
                    color          = fpalette[index];
                    palette[index] = colormap.RGBToPixel
                                         (new Color((color >> 16) & 0xFF,
                                                    (color >> 8) & 0xFF, color & 0xFF));
                }
            }
            else
            {
                // We have an RGB image: use a standard palette.
                palette = colormap.GetStandardPalette();
            }

            // Convert the frame into an XImage and return it.
            return(Xlib.XSharpCreateImageFromDIB
                       (screen.screen, frame.Width, frame.Height,
                       frame.Stride, (int)(frame.PixelFormat),
                       frame.Data, 0, palette));
        }
	// Convert an image frame into an XImage.
	public static IntPtr FrameToXImage(Screen screen, Frame frame)
			{
				int[] fpalette;
				XPixel[] palette;
				int index, color;
				Colormap colormap = screen.DefaultColormap;

				// Create a palette to use to render the image.
				fpalette = frame.Palette;
				if(fpalette != null)
				{
					// Convert the palette within the image frame itself.
					palette = new XPixel [256];
					for(index = 0; index < 256 && index < fpalette.Length;
						++index)
					{
						color = fpalette[index];
						palette[index] = colormap.RGBToPixel
							(new Color((color >> 16) & 0xFF,
									   (color >> 8) & 0xFF, color & 0xFF));
					}
				}
				else
				{
					// We have an RGB image: use a standard palette.
					palette = colormap.GetStandardPalette();
				}

				// Convert the frame into an XImage and return it.
				return Xlib.XSharpCreateImageFromDIB
						(screen.screen, frame.Width, frame.Height,
						 frame.Stride, (int)(frame.PixelFormat),
						 frame.Data, 0, palette);
			}
示例#3
0
	extern public static XStatus XagCreateEmbeddedApplicationGroup
			(IntPtr display, XVisualID root_visual, XColormap default_colormap,
			 XPixel black_pixel, XPixel white_pixel, out XAppGroup app_group);
示例#4
0
	extern public static IntPtr XSharpCreateImageFromDIB
			(IntPtr screen, int width, int height,
			 int stride, int pixelFormat, byte[] data,
			 int isMask, XPixel[] palette);
示例#5
0
	extern public static int XSetBackground
			(IntPtr display, IntPtr gc, XPixel background);
示例#6
0
	extern public static int XSetForeground
			(IntPtr display, IntPtr gc, XPixel foreground);
示例#7
0
	extern public static int XSetWindowBackground
			(IntPtr display, XWindow w, XPixel background_pixel);
示例#8
0
	// Draw a radio button.
	private void DrawRadio(IntPtr display,
						   int x, int y, int width, int height,
						   XPixel topShadow,
						   XPixel topShadowEnhanced,
						   XPixel bottomShadow,
						   XPixel bottomShadowEnhanced,
						   XPixel foreground,
						   XPixel background)
			{
				// Adjust the top-left position of the radio button.
				x += (width - BuiltinBitmaps.RadioWidth) / 2;
				y += (height - BuiltinBitmaps.RadioHeight) / 2;
				width = BuiltinBitmaps.RadioWidth;
				height = BuiltinBitmaps.RadioHeight;

				// Draw the bitmaps.
				BuiltinBitmaps bitmaps = dpy.bitmaps;
				Xlib.XSetStipple(display, gc, bitmaps.RadioBottom);
				Xlib.XSetTSOrigin(display, gc, x, y);
				Xlib.XSetForeground(display, gc, bottomShadow);
				Xlib.XSetFillStyle(display, gc, (int)(FillStyle.FillStippled));
				Xlib.XFillRectangle(display, drawableHandle, gc,
									x, y, width, height);

				Xlib.XSetStipple(display, gc, bitmaps.RadioBottomEnhanced);
				Xlib.XSetForeground(display, gc, bottomShadowEnhanced);
				Xlib.XFillRectangle(display, drawableHandle, gc,
									x, y, width, height);

				Xlib.XSetStipple(display, gc, bitmaps.RadioTop);
				Xlib.XSetForeground(display, gc, topShadow);
				Xlib.XFillRectangle(display, drawableHandle, gc,
									x, y, width, height);

				Xlib.XSetStipple(display, gc, bitmaps.RadioTopEnhanced);
				Xlib.XSetForeground(display, gc, topShadowEnhanced);
				Xlib.XFillRectangle(display, drawableHandle, gc,
									x, y, width, height);

				Xlib.XSetStipple(display, gc, bitmaps.RadioForeground);
				Xlib.XSetForeground(display, gc, foreground);
				Xlib.XFillRectangle(display, drawableHandle, gc,
									x, y, width, height);

				Xlib.XSetStipple(display, gc, bitmaps.RadioBackground);
				Xlib.XSetForeground(display, gc, background);
				Xlib.XFillRectangle(display, drawableHandle, gc,
									x, y, width, height);

				// Restore the previously stipple pixmap.
				if(stipple != null)
				{
					Xlib.XSetStipple(display, gc, stipple.GetPixmapHandle());
				}
			}