[Mono-bugs] [Bug 521718] New: System.Drawing.Graphics.CopyFromScreenX11

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon Jul 13 17:02:20 EDT 2009


http://bugzilla.novell.com/show_bug.cgi?id=521718

User jon_james at dell.com added comment
http://bugzilla.novell.com/show_bug.cgi?id=521718#c479037

           Summary: System.Drawing.Graphics.CopyFromScreenX11
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.4.x
          Platform: 64bit
        OS/Version: RHEL 5
            Status: NEW
          Severity: Critical
          Priority: P5 - None
         Component: Sys.Drawing.
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: jon_james at dell.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: Development


Description of Problem:
I believe this problem is related to bug #479037

Unable to capture screen shot on rhel5.3 with mono 2.4.2.1. Results in
exception thrown.  .net code compiles and works as needed on MS platform

Steps to reproduce the problem:
1. Install Mono 2.4.2 and libgdiplus 2.4.2
2. compile and run:

namespace SSUtil
{
    class Program
    {
        public enum TermMsg
        {
            Error,
            Info,
            Warning,
            Debug,
            NULL
        }
        static void Main(string[] args)
        {
            Bitmap bmpScreenshot = null;
            Graphics gfxScreenshot = null;
            string Path;
            int exitcode = 1;

            try
            {
                NotifyTerminal(TermMsg.Info, "ScreenShot Utility");

                if (args.Length != 1)
                    NotifyTerminal(TermMsg.Error, "Usage: " +
Environment.GetCommandLineArgs()[0] + " <filename>");                
                else
                {
                    // Extract path
                    Path = args[0];

                    // Set the bitmap object to the size of the screen
                    bmpScreenshot = new
Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height,
PixelFormat.Format32bppArgb);
                    Console.WriteLine("Screen width:" +
Screen.PrimaryScreen.Bounds.Width + " Screen height: " +
Screen.PrimaryScreen.Bounds.Height + " pixel format: " +
PixelFormat.Format32bppArgb);


                    // Create a graphics object from the bitmap
                    gfxScreenshot = Graphics.FromImage(bmpScreenshot);

                    // Take the screenshot from the upper left corner to the
right bottom corner
                    gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X,
Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size,
CopyPixelOperation.SourceCopy);

                    // Save the screenshot to the specified path that the user
has chosen
                    bmpScreenshot.Save(Path, ImageFormat.Jpeg);

                    exitcode = 0;
                    NotifyTerminal(TermMsg.Info, "Successfully captured
ScreenShot at: " + Path);                    
                }                
            }
            catch (Exception E)
            {
                NotifyTerminal(TermMsg.Error, "Fatal Error: " + E.ToString());  
            }
            finally
            {
                if (bmpScreenshot != null) { bmpScreenshot.Dispose(); }
                if (gfxScreenshot != null) { gfxScreenshot.Dispose(); }
            }

            System.Environment.Exit(exitcode);
        }

        // ScreenShotTerminal
        public static void NotifyTerminal(TermMsg msgType, string message)
        {            
            switch (msgType)
            {
                case TermMsg.NULL:
                    Console.WriteLine(">");
                    break;
                case TermMsg.Info:
                    Console.WriteLine(">" + Indent(13) + message);
                    break;
                case TermMsg.Debug:
                    Console.WriteLine("< " + msgType.ToString().ToUpper() + "
>" + Indent(5) + message);
                    break;
                case TermMsg.Error:
                    Console.WriteLine("< " + msgType.ToString().ToUpper() + "
>" + Indent(5) + message);
                    break;
                case TermMsg.Warning:
                    Console.WriteLine("< " + msgType.ToString().ToUpper() + "
>" + Indent(3) + message);
                    break;
            }                    
        }

        // Indentation
        private static string Indent(int count)
        {
            return "".PadLeft(count);
        }
    }
}

Actual Results:
Fatal Error: System.NotImplementedException: 0bbp depth not supported 

Expected Results:
root screen capture

How often does this happen? 
Always

Additional Information:
looking at the source code, looks like my platform the XVisualInfo visual = new
XVisualInfo object within the System.Drawing.Graphics.CopyFromScreenX11 may be
having troubles with bitmap function as it looks like it's falling through the
switch:

                    switch (visual.depth) {
                        case 16: /* 16bbp pixel transformation */
                            red = (int) ((pixel & visual.red_mask ) >> 8) &
0xff;
                            green = (int) (((pixel & visual.green_mask ) >> 3
)) & 0xff;
                            blue = (int) ((pixel & visual.blue_mask ) << 3 ) &
0xff;
                            break;
                        case 24:
                        case 32:
                            red = (int) ((pixel & visual.red_mask ) >> 16) &
0xff;
                            green = (int) (((pixel & visual.green_mask ) >> 8
)) & 0xff;
                            blue = (int) ((pixel & visual.blue_mask )) & 0xff;
                            break;
                        default:
                            string text = Locale.GetText ("{0}bbp depth not
supported.", visual.depth);
                            throw new NotImplementedException (text);
                    }

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list