Esempio n. 1
0
        public Image Copy()
        {
            Gdk.Colormap colormap = Gdk.Colormap.System;

            /* FIXME: copying a surface to a pixbuf through a pixmap does not require writting / reading to a file,
             * but it does not handle transparencies correctly and draws transparent pixels in a black color, so
             * for now we force the first method */
            colormap = null;

            /* In unit tests running without a display, the default Screen is null and we can't get a valid colormap.
             * In this scenario we use a fallback that writes the surface to a temporary file */
            if (colormap == null)
            {
                string tempFile = System.IO.Path.GetTempFileName();
                surface.WriteToPng(tempFile);
                Gdk.Pixbuf pixbuf = new Gdk.Pixbuf(tempFile);
                return(new Image(pixbuf));
            }
            else
            {
                Gdk.Pixmap pixmap = new Gdk.Pixmap(null, Width, Height, 24);
                using (Context cr = Gdk.CairoHelper.Create(pixmap)) {
                    cr.Operator = Operator.Source;
                    cr.SetSource(surface);
                    cr.Paint();
                }
                return(new Image(Gdk.Pixbuf.FromDrawable(pixmap, Gdk.Colormap.System, 0, 0, 0, 0, Width, Height)));
            }
        }
Esempio n. 2
0
        private void Window_OnScreenChanged(object Send, ScreenChangedArgs args)
        {
            Gdk.Colormap cm = Screen.RgbaColormap;
            composeAvailable = cm != null;              // FIX: Do not seem to detect compose support in all cases

            if (!composeAvailable)
            {
                cm = Screen.RgbColormap;
            }
            Colormap = cm;

            Console.WriteLine("Compose Support: " + composeAvailable);
        }