|
From: Maxim S. <mcs...@ya...> - 2005-11-14 17:13:50
|
Hi Ken, The problem is that applying gamma on the fly in RGBA is nontrivial. RGB assumes implicit alpha always equal to 255, so that it's easy to apply gamma via a LUT. In premultiplied RGBA we would need to use 256 LUTs for every alpha value. So that it's expensive. However, you can use full color gamma correction in RGBA too. For that you need the LUT: agg::gamma_lut<> m_lut(2.2); Then you modify every input color as: color.r = m_lut.dir(color.r); color.g = m_lut.dir(color.g); color.b = m_lut.dir(color.b); And use pixfmt_rgba32 as usual. Finally you need to display the resulting buffer without the alpha channel (or ignoring alpha). So that, after the image is fully composed you simply apply the inverse gamma: pixf.apply_gamma_inv(m_lut); But I don't know what to do with gamma if you still need the actual alpha channel in the final output (you use WinAPI AlphaBlend() or write a PNG with alpha). Does anyone have a clue? McSeem --- Ken Resander <res...@sp...> wrote: > I have a procedure 'text' based on the TrueType example that > uses agg::pixfmt_bgr24_gamma<gamma_type> and procedures rect, > circle etc that use pixfmt_bgra32 pixf(rbuf). These procedures put data > into a rendering buffer, which is bitblted onto the screen as a last > and separate step. > > My application puts shapes annotated by text in a single > rendering buffer with pixel width 4 bytes (opacity needed), > but the text procedure does not work.The texts do not go > where I want them, there are stripes and the colors are wrong. > I think the pixfmt in the text procedure needs to be > replaced by a 32 bit format with gamma, such as > agg::pixfmt_bgra32_gamma<gamma_type>, but I have not been > able to find that. I have no knowledge about gamma, so cannot > write it myself (if indeed this is the way to solve it). > > How can I make text coexist with shapes (with opacity) in a single > rendering buffer? > __________________________________ Yahoo! FareChase: Search multiple travel sites in one click. http://farechase.yahoo.com |