[Mono-bugs] [Bug 535942] New: LinearGradientBrush on OS X drawable: wrong result for some rect coordinates

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Sep 1 09:48:41 EDT 2009


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


           Summary: LinearGradientBrush on OS X drawable: wrong result for
                    some rect coordinates
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.4.x
          Platform: x86
        OS/Version: Mac OS X 10.5
            Status: NEW
          Severity: Major
          Priority: P5 - None
         Component: libgdiplus
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: alexander.shulgin at yessoftware.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: Community User


Created an attachment (id=316187)
 --> (http://bugzilla.novell.com/attachment.cgi?id=316187)
Sample code, screenshots.

The result of using LinearGradientBrush-based Pen to draw rectangle (or some
arbitrary path) depends on coordinates of rectangle.

For most of the possible coordinates it works correctly, but there's clearly
areas where it produces no gradient at all, but single-colored lines.

This happens only on OS X (tried Linux, OK there).

This happens only when drawing on WinForms control--the same code drawing in
Graphics.FromImage(bitmap) works OK.

Sample code:

using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;

namespace test {
    public class MainForm : Form {
        public static void Main() {
            Application.Run(new MainForm());
        }

        protected override void OnSizeChanged(EventArgs e) {
            base.OnSizeChanged(e);
            Invalidate();
        }

        protected override void OnPaint(PaintEventArgs e) {
            for (int i = 0; i < ClientSize.Width / 2; ++i) {
                Rectangle r = Rectangle.FromLTRB(ClientSize.Width / 2 - i,
ClientSize.Height / 2 - i,
                                                 ClientSize.Width / 2 + i,
ClientSize.Height / 2 + i);

                using (LinearGradientBrush b = new LinearGradientBrush(r,
Color.White, Color.Black, 90)) {
                    using (Pen p = new Pen(b)) {
                        e.Graphics.DrawRectangle(p, r);
                    }
                }
            }
        }
    }
}

Note: the same result is produced when using the brush with FillRectangle
(direction of for loop has to be inverted then).

Screenshots from Linux and Mac OS 10.5 are attached.

Looks much like the cairo bug.  Posting this here because I still need to
figure out how to setup a sample with cairo drawing on OS X drawable.

-- 
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