Ejemplo n.º 1
0
        // Load builtin bitmaps for a particular display.
        public BuiltinBitmaps(Display display)
        {
            IntPtr    dpy      = display.dpy;
            XDrawable drawable = display.DefaultRootWindow.handle;

            RadioBottom = Xlib.XCreateBitmapFromData
                              (dpy, drawable, radio_b_bits, (uint)12, (uint)12);
            RadioBottomEnhanced = Xlib.XCreateBitmapFromData
                                      (dpy, drawable, radio_B_bits, (uint)12, (uint)12);
            RadioTop = Xlib.XCreateBitmapFromData
                           (dpy, drawable, radio_t_bits, (uint)12, (uint)12);
            RadioTopEnhanced = Xlib.XCreateBitmapFromData
                                   (dpy, drawable, radio_T_bits, (uint)12, (uint)12);
            RadioBackground = Xlib.XCreateBitmapFromData
                                  (dpy, drawable, radio_w_bits, (uint)12, (uint)12);
            RadioForeground = Xlib.XCreateBitmapFromData
                                  (dpy, drawable, radio_f_bits, (uint)12, (uint)12);
            Close = Xlib.XCreateBitmapFromData
                        (dpy, drawable, close_button_bits, (uint)9, (uint)9);
            Minimize = Xlib.XCreateBitmapFromData
                           (dpy, drawable, minimize_button_bits, (uint)9, (uint)9);
            Maximize = Xlib.XCreateBitmapFromData
                           (dpy, drawable, maximize_button_bits, (uint)9, (uint)9);
            Restore = Xlib.XCreateBitmapFromData
                          (dpy, drawable, restore_button_bits, (uint)9, (uint)9);
            Help = Xlib.XCreateBitmapFromData
                       (dpy, drawable, help_button_bits, (uint)9, (uint)9);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// <para>Constructs a new <see cref="T:Xsharp.Bitmap"/> instance
 /// that represents an off-screen bitmap.  The bitmap is created
 /// on the specified <paramref name="screen"/>, using the
 /// supplied bitmap data.</para>
 /// </summary>
 ///
 /// <param name="screen">
 /// <para>The screen upon which to create the new bitmap.</para>
 /// </param>
 ///
 /// <param name="width">
 /// <para>The width of the new bitmap.</para>
 /// </param>
 ///
 /// <param name="height">
 /// <para>The height of the new bitmap.</para>
 /// </param>
 ///
 /// <param name="bits">
 /// <para>The bits that make up the data.</para>
 /// </param>
 ///
 /// <exception cref="T:System.ArgumentNullException">
 /// <para>Raised if <paramref name="bits"/> is <see langword="null"/>.
 /// </para>
 /// </exception>
 ///
 /// <exception cref="T:Xsharp.XException">
 /// <para>The <paramref name="width"/> or <paramref name="height"/>
 /// values are out of range, or <paramref name="bits"/> is invalid
 /// in some way.</para>
 /// </exception>
 public Bitmap(Screen screen, int width, int height, byte[] bits)
     : base(GetDisplay(screen), screen, DrawableKind.Bitmap)
 {
     if (width < 1 || width > 32767 ||
         height < 1 || height > 32767)
     {
         throw new XException(S._("X_InvalidBitmapSize"));
     }
     if (bits == null)
     {
         throw new ArgumentNullException("bits");
     }
     if (((((width + 15) & ~15) * height) / 8) > bits.Length)
     {
         throw new XException(S._("X_InvalidBitmapBits"));
     }
     try
     {
         IntPtr    display  = dpy.Lock();
         XDrawable drawable = (XDrawable)
                              Xlib.XRootWindowOfScreen(screen.screen);
         SetPixmapHandle(Xlib.XCreateBitmapFromData
                             (display, drawable, bits, (uint)width, (uint)height));
         this.width  = width;
         this.height = height;
     }
     finally
     {
         dpy.Unlock();
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// <para>Constructs a new <see cref="T:Xsharp.Bitmap"/> instance
        /// that represents an off-screen bitmap.  The bitmap is created
        /// on the default screen of the primary display, using the
        /// supplied bitmap data.</para>
        /// </summary>
        ///
        /// <param name="width">
        /// <para>The width of the new bitmap.</para>
        /// </param>
        ///
        /// <param name="height">
        /// <para>The height of the new bitmap.</para>
        /// </param>
        ///
        /// <param name="bits">
        /// <para>The bits that make up the data.</para>
        /// </param>
        ///
        /// <exception cref="T:System.ArgumentNullException">
        /// <para>Raised if <paramref name="bits"/> is <see langword="null"/>.
        /// </para>
        /// </exception>
        ///
        /// <exception cref="T:Xsharp.XException">
        /// <para>The <paramref name="width"/> or <paramref name="height"/>
        /// values are out of range, or <paramref name="bits"/> is invalid
        /// in some way.</para>
        /// </exception>
        public Bitmap(int width, int height, byte[] bits)
            : base(Xsharp.Application.Primary.Display,
                   Xsharp.Application.Primary.Display.DefaultScreenOfDisplay,
                   DrawableKind.Bitmap)
        {
            if (width < 1 || width > 32767 ||
                height < 1 || height > 32767)
            {
                throw new XException(S._("X_InvalidBitmapSize"));
            }
            if (bits == null)
            {
                throw new ArgumentNullException("bits");
            }
            int unit = (width <= 8 ? 7 : 15);

            if (((((width + unit) & ~unit) * height) / 8) > bits.Length)
            {
                throw new XException(S._("X_InvalidBitmapBits"));
            }
            try
            {
                IntPtr    display  = dpy.Lock();
                XDrawable drawable = (XDrawable)
                                     Xlib.XRootWindowOfScreen(screen.screen);
                SetPixmapHandle(Xlib.XCreateBitmapFromData
                                    (display, drawable, bits, (uint)width, (uint)height));
                this.width  = width;
                this.height = height;
            }
            finally
            {
                dpy.Unlock();
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// <para>Constructs a new <see cref="T:Xsharp.Image"/> instance
        /// that represents an off-screen image on a particular screen.</para>
        /// </summary>
        ///
        /// <param name="screen">
        /// <para>The screen upon which to create the new pixmap.</para>
        /// </param>
        ///
        /// <param name="width">
        /// <para>The width of the new image.</para>
        /// </param>
        ///
        /// <param name="height">
        /// <para>The height of the new image.</para>
        /// </param>
        ///
        /// <param name="image">
        /// <para>The bits that make up the image.</para>
        /// </param>
        ///
        /// <param name="mask">
        /// <para>The bits that make up the mask.</para>
        /// </param>
        ///
        /// <exception cref="T:Xsharp.XException">
        /// <para>The <paramref name="width"/> or <paramref name="height"/>
        /// values are out of range.</para>
        /// </exception>
        public Image(Screen screen, int width, int height, byte[] image, byte[] mask)
        {
            Display dpy;

            if (screen != null)
            {
                dpy = screen.DisplayOfScreen;
            }
            else
            {
                dpy    = Application.Primary.Display;
                screen = dpy.DefaultScreenOfDisplay;
            }
            this.screen = screen;
            if (width < 1 || width > 32767 ||
                height < 1 || height > 32767)
            {
                throw new XException(S._("X_InvalidBitmapSize"));
            }
            if (image == null)
            {
                throw new ArgumentNullException("bits");
            }
            if (((((width + 15) & ~15) * height) / 8) > image.Length)
            {
                throw new XException(S._("X_InvalidBitmapBits"));
            }
            try
            {
                IntPtr    display  = dpy.Lock();
                XDrawable drawable = (XDrawable)
                                     Xlib.XRootWindowOfScreen(screen.screen);
                XPixmap pixmap = Xlib.XCreateBitmapFromData
                                     (display, drawable, image, (uint)width, (uint)height);
                this.pixmap = new Pixmap(dpy, screen, pixmap);
            }
            finally
            {
                dpy.Unlock();
            }
            if (mask != null)
            {
                this.mask = new Bitmap(screen, width, height, mask);
            }
        }