Esempio n. 1
0
        private void WithExtraCanvas(Rectangle rect, Action <X11Canvas> action)
        {
            using (X11Image tempImage = X11Image.Create(display, visual, drawableId, rect.Width, rect.Height))
            {
                var gcValues = new XGCValues();
                gcValues.foreground = ToPArgb(Color.Transparent);
                var gcValueMask = XGCValueMask.GCForeground;
                var gc          = LibX11.XCreateGC(display, drawableId, gcValueMask, ref gcValues);
                try
                {
                    // todo: check int -> uint conversion
                    LibX11.XFillRectangle(display, tempImage.PixmapId, gc, 0, 0, (uint)rect.Width, (uint)rect.Height);
                }
                finally
                {
                    LibX11.XFreeGC(display, gc);
                }

                using (var innerCanvas = X11Canvas.CreateForDrawable(display, screenNum, objectCache, visual, colormap, pictFormatPtr, tempImage.PixmapId))
                {
                    action(innerCanvas);
                    DrawImage(tempImage, rect.X + origin.X, rect.Y + origin.Y);
                }
            }
        }
Esempio n. 2
0
        public INativeImage CreateImage(int width, int height)
        {
            // todo: what is the best place for this validation
            if (width < 0 || height < 0)
            {
                throw new ArgumentException($"Image dimensions cannot be negative ({width} x {height}).");
            }

            if (width * 4L > int.MaxValue || height * 4L > int.MaxValue || 4L * width * height > int.MaxValue)
            {
                throw new ArgumentException($"Image dimensions are too large ({width} x {height}).");
            }

            return(X11Image.Create(display, visual, rootWindow, width, height));
        }
Esempio n. 3
0
 public INativeImage LoadImageFromStream(Stream stream)
 {
     using (GdkPixBufBitmapSource source = LoadSourceFromStream(stream))
     {
         X11Image disposableImage = X11Image.Create(display, visual, rootWindow, source.Width, source.Height);
         try
         {
             source.CopyToImage(disposableImage);
             X11Image image = disposableImage;
             disposableImage = null;
             return(image);
         }
         finally
         {
             disposableImage?.Dispose();
         }
     }
 }
Esempio n. 4
0
 internal X11Image CreateImage(int width, int height)
 {
     return(X11Image.Create(display, visual, rootWindow, width, height));
 }