Exemple #1
0
        /// <summary>
        /// <para>Constructs a new <see cref="T:Xsharp.Image"/> instance
        /// from a <see cref="T:DotGNU.Images.Frame"/> instance.</para>
        /// </summary>
        ///
        /// <param name="screen">
        /// <para>The screen upon which to create the new image.</para>
        /// </param>
        ///
        /// <param name="frame">
        /// <para>The frame to load the image from.</para>
        /// </param>
        ///
        /// <exception cref="T:System.ArgumentNullException">
        /// <para>The <paramref name="frame"/> parameter is
        /// <see langword="null"/>.</para>
        /// </exception>
        ///
        /// <exception cref="T:Xsharp.XInvalidOperationException">
        /// <para>Raised if <paramref name="filename"/> could not be
        /// loaded for some reason.</para>
        /// </exception>
        public Image(Screen screen, Frame frame)
        {
            Display dpy;

            if (frame == null)
            {
                throw new ArgumentNullException("frame");
            }
            if (screen != null)
            {
                dpy = screen.DisplayOfScreen;
            }
            else
            {
                dpy    = Application.Primary.Display;
                screen = dpy.DefaultScreenOfDisplay;
            }
            this.screen = screen;
            try
            {
                dpy.Lock();
                pixmapXImage = ConvertImage.FrameToXImage(screen, frame);
                maskXImage   = ConvertImage.MaskToXImage(screen, frame);
            }
            finally
            {
                dpy.Unlock();
            }
        }
Exemple #2
0
        /// <summary>
        /// <para>Constructs a new <see cref="T:Xsharp.Image"/> instance
        /// that represents an off-screen image that was loaded
        /// from a file.</para>
        /// </summary>
        ///
        /// <param name="screen">
        /// <para>The screen upon which to create the new pixmap.</para>
        /// </param>
        ///
        /// <param name="filename">
        /// <para>The file to load the image from.</para>
        /// </param>
        ///
        /// <exception cref="T:System.ArgumentNullException">
        /// <para>The <paramref name="filename"/> parameter is
        /// <see langword="null"/>.</para>
        /// </exception>
        ///
        /// <exception cref="T:System.FormatException">
        /// <para>The image format is not recognized.</para>
        /// </exception>
        ///
        /// <exception cref="T:Xsharp.XInvalidOperationException">
        /// <para>Raised if <paramref name="filename"/> could not be
        /// loaded for some reason.</para>
        /// </exception>
        public Image(Screen screen, String filename)
        {
            Display dpy;

            if (filename == null)
            {
                throw new ArgumentNullException("filename");
            }
            if (screen != null)
            {
                dpy = screen.DisplayOfScreen;
            }
            else
            {
                dpy    = Application.Primary.Display;
                screen = dpy.DefaultScreenOfDisplay;
            }
            this.screen = screen;
            DotGNU.Images.Image img = new DotGNU.Images.Image();
            img.Load(filename);
            Frame frame = img.GetFrame(0);

            try
            {
                dpy.Lock();
                pixmapXImage = ConvertImage.FrameToXImage(screen, frame);
                maskXImage   = ConvertImage.MaskToXImage(screen, frame);
            }
            finally
            {
                dpy.Unlock();
            }
        }