[cairo] cairo linear gradient with BUG?

丹青(Hishop) hishop at gmail.com
Mon Jun 17 04:34:36 PDT 2013


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!

Mail attachment in my test pictures, please check.

[image: 内嵌图片 2][image: 内嵌图片 3][image: 内嵌图片 1]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20130617/b369ea4d/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: s1.png
Type: image/png
Size: 1532 bytes
Desc: not available
URL: <http://lists.cairographics.org/archives/cairo/attachments/20130617/b369ea4d/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: s2.png
Type: image/png
Size: 1483 bytes
Desc: not available
URL: <http://lists.cairographics.org/archives/cairo/attachments/20130617/b369ea4d/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: s4.png
Type: image/png
Size: 1344 bytes
Desc: not available
URL: <http://lists.cairographics.org/archives/cairo/attachments/20130617/b369ea4d/attachment-0002.png>


More information about the cairo mailing list