|
From: Lorne L. <lo...@in...> - 2009-04-28 13:51:46
|
On Tue, Apr 28, 2009 at 8:27 AM, Vinnie <th...@ya...> wrote: > >> From: Lorne Laliberte <lo...@in...> >> I should clarify: in practical terms, the anti-aliasing >> coverage information is preserved if you output onto a 32-bit >> surface with a transparent background, i.e. a buffer that has >> been cleared with a transparent color(0,0,0,0). > > So you are saying that agg already supports the feature I need? Well that will save me time. Just to be clear, I am currently using: > > typedef agg::pixfmt_bgr24 pfmt_type; > typedef agg::renderer_base<pfmt_type> rbase_type; > typedef agg::renderer_scanline_aa_solid<rbase_type> rsolid_type; > > So all I would need to do is switch to: > typedef agg::pixfmt_bgra32 pfmt_type; > > That would be pretty sweet! You just saved me a few days of frustration! :) > Whats with all the "premultiply" variations? And whats the difference between regular and "plain"? Ah, that's a million dollar question. The short answer: I'd recommend doing everything in premultiplied colors (use the _pre versions), and just use color(r,g,b,a).premultiply() whenever you specify a color. Longer answer: You will probably find this post in the mailing list very useful: http://thread.gmane.org/gmane.comp.graphics.agg/3110/focus=3112 If you're drawing images and doing any kind of filtering or interpolation on them (resizing, etc.), you'll need to use a premultiplied image format. For "normal" drawing of solid shapes, you can choose to use either the regular pixel format or the _pre ones. Using the regular pixel format lets you specify non-premultiplied colors, and they'll basically be premultiplied for you as they're blended in. You can attach pre and non-pre pixel formats to the same buffer; they basically affect how (or whether) the alpha channel is applied during the drawing operation. The result of the draw operation (the contents of the buffer) is always premultiplied, unless you use the _plain versions of the pixel formats I believe. Note that only the pixel format attached to the destination buffer matters. C++ templates being as they are, I found it simpler overall to just use premultiplied pixel formats throughout my graphics engine, and simply enforce a rule that all input colors need to be premultiplied. Lorne Laliberte Senior Software Developer, Indigo Rose Software |