[cairo] cairo linear gradient with BUG?

Chris Wilson chris at chris-wilson.co.uk
Mon Jun 17 05:57:27 PDT 2013


On Mon, Jun 17, 2013 at 07:34:36PM +0800, 丹青(Hishop) wrote:
>    Hello, this is google translation, sorry!
>    I realize SWF To bitmap conversion is found a problem, the code is as
>    follows (using C # call cairo.dll,v1.12.14)
>      Cairo.Context c = new Context (new ImageSurface (Format.ARGB32, 150,
>    150));
>                 Matrix m1 = new Matrix ();
>                 m1.Scale (0.1, 0.1);
>                 / / m1.Scale (0.5, 0.5);
>                 / / m1.Scale (1, 1);
>                 c.Matrix = m1;
>                 Cairo.LinearGradient lg = new LinearGradient (-16384, 0,
>    16384, 0);
>                 Cairo.Matrix m2 = new Matrix ();
>                 m2.Scale (0.01220703125, 0.01220703125);
>                 m2.Translate (3896.0, 0);
>                 m2.Invert ();
>                 lg.Extend = Extend.Repeat;
>                 lg.Matrix = m2;
>                 lg.AddColorStop (0, new Cairo.Color (0, 0, 0));
>                 lg.AddColorStop (0.4, new Cairo.Color (1, 0, 0));
>                 lg.AddColorStop (0.8, new Cairo.Color (1, 1, 0));
>                 lg.AddColorStop (1, new Cairo.Color (1, 1, 1));
>                 c.Pattern = lg;
>                 c.MoveTo (0, 0);
>                 c.LineTo (4096, 0);
>                 c.LineTo (4096, 4096);
>                 c.LineTo (0, 4096);
>                 c.LineTo (0, 0);
>                 c.ClosePath ();
>                 c.FillPreserve ();
>                 c.Color = new Cairo.Color (0, 0, 0, 1);
>                 c.Stroke ();
>                 c.Target.WriteToPng (@ "c: \ test.png");
>                 c.Target.Dispose ();
>    In the above code, if you use m1.Scale (1, 1); m1.Scale (0.5, 0.5);
>    gradient effect with the normal output picture, but if you use m1.Scale
>    (0.1,0.1); or low scaling, such as m1.Scale (0.05,0.05), the picture
>    output is blank.
>    I do not know whether this is a BUG, please test it yourself and give
>    back. Thank you!

It is a known failure due to the limited precision we use in the
gradient walker. Different backends will have different failure modes and
lifting the limits will require some careful analysis of the precision.
-Chris


-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the cairo mailing list