[Mono-bugs] [Bug 404608] New: Changes to draw metafiles are needed

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Fri Jun 27 12:13:28 EDT 2008


https://bugzilla.novell.com/show_bug.cgi?id=404608


           Summary: Changes to draw metafiles are needed
           Product: Mono: Class Libraries
           Version: 1.9.0
          Platform: x86
        OS/Version: Windows XP
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Sys.Drawing.
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: MikeGratsas at techemail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: Third Party Developer/Partner


Please correct the implementation of several methods used to draw images.
Changes are needed to ensure proper processing of metafiles since origin point
for metafiles can be not equal to {0, 0}.

1. System.Drawing.Image class:

        public Image GetThumbnailImage (int thumbWidth, int thumbHeight,
Image.GetThumbnailImageAbort callback, IntPtr callbackData)
        {
                if ((thumbWidth <= 0) || (thumbHeight <= 0))
                        throw new OutOfMemoryException ("Invalid thumbnail
size");

                GraphicsUnit pageUnit = GraphicsUnit.Pixel;
                RectangleF srcRect = GetBounds(ref pageUnit);
                Image ThumbNail = new Bitmap (thumbWidth, thumbHeight);

                using (Graphics g = Graphics.FromImage (ThumbNail)) {
                        Status status =
GDIPlus.GdipDrawImageRectRect(g.nativeObject, nativeObject,
                                0, 0, thumbWidth, thumbHeight,
                                srcRect.X, srcRect.Y, srcRect.Width,
srcRect.Height,
                                pageUnit, IntPtr.Zero, null, IntPtr.Zero);

                        GDIPlus.CheckStatus (status);
                }

                return ThumbNail;
        }

2. Windows.Forms.ThemeWin32Classic class:

                public override void CPDrawImageDisabled (Graphics graphics,
Image image, int x, int y, Color background) {
                        /*
                                Microsoft seems to ignore the background and
simply make
                                the image grayscale. At least when having > 256
colors on
                                the display.
                        */

                        if (imagedisabled_attributes == null) {                 
                                imagedisabled_attributes = new ImageAttributes
();
                                ColorMatrix colorMatrix=new ColorMatrix(new
float[][] {
                                          // This table would create a perfect
grayscale image, based on luminance
                                          //                            new
float[]{0.3f,0.3f,0.3f,0,0},
                                          //                            new
float[]{0.59f,0.59f,0.59f,0,0},
                                          //                            new
float[]{0.11f,0.11f,0.11f,0,0},
                                          //                            new
float[]{0,0,0,1,0,0},
                                          //                            new
float[]{0,0,0,0,1,0},
                                          //                            new
float[]{0,0,0,0,0,1}

                                          // This table generates a image that
is grayscaled and then
                                          // brightened up. Seems to match MS
close enough.
                                          new float[]{0.2f,0.2f,0.2f,0,0},
                                          new float[]{0.41f,0.41f,0.41f,0,0},
                                          new float[]{0.11f,0.11f,0.11f,0,0},
                                          new float[]{0.15f,0.15f,0.15f,1,0,0},
                                          new float[]{0.15f,0.15f,0.15f,0,1,0},
                                          new float[]{0.15f,0.15f,0.15f,0,0,1}
                                  });

                                 imagedisabled_attributes.SetColorMatrix
(colorMatrix);
                        }

                        GraphicsUnit pageUnit = GraphicsUnit.Pixel;
                        RectangleF srcRect = image.GetBounds(ref pageUnit);
                        graphics.DrawImage(image, new Rectangle(x, y,
image.Width, image.Height), srcRect.X, srcRect.Y, srcRect.Width,
srcRect.Height, pageUnit, imagedisabled_attributes);

                }


-- 
Configure bugmail: https://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