On Fri, Nov 28, 2008 at 8:47 AM, Stephan Assmus <
superstippi@...> wrote:
> Hi all,
>
> has anyone worked with on-the-fly colorspace conversions, or using images with different colorspaces within the same rendering pipeline?
Hi Stephan,
I wanted to let you know what I learned when I implemented real-time
RGB->HSL->RGB conversions in my draw engine.
For smaller areas, doing the conversion in real time works quite well,
actually. I implemented it using a span generator "adaptor" very
similar to the span_converter template in AGG. This is what the
generate function looks like:
void generate(agg::rgba8* span, int x, int y, unsigned len)
{
m_sourceFill->generate(span, x, y, len);
for(unsigned i = 0; i < len; ++i, ++span)
{
if(span->a != 0)
{
span->demultiply();
HSL hsl = RGB2HSL(*span);
m_op->Adjust(hsl);
*span = HSL2RGB(hsl);
span->premultiply();
}
}
}
In my case I'm using a shared_ptr to the source span generator,
"m_sourceFill" which is essentially a custom span generator derived
from a "Fill" abstract base class. (I needed a generalized "fill" type
in order to support the compound rasterizer in my engine. These fill
types can be strung together to produce compound span generators. For
example, the above code is from an "HSLAdaptorFill" class template,
which I can attach to any other fill type in order to perform a
real-time HSL color model adjustment to each span.)
m_op in the above code points to an "HSL operator," which is
essentially a policy functor implementing some kind of HSL adjustment,
or a unique "chain" of them (similar to AGG's coordinate conversion
pipeline).
The above method -- performing the RGB to HSL to RGB conversion on the
fly -- is pretty quick, all things considered, but it isn't fast
enough for larger areas, or when there is a lot of interpolation going
on. I ended up storing a colorized version of the full source image,
processing each pixel as it's copied over from the original source
image into another buffer. This allows me to just use the colorized
version in place of the original source image and pay only a one-time
processing cost for the color conversion. (At the expense of greater
memory use, of course.)
I still use both methods in my app -- for example the real-time method
is faster than converting the entire source image whenever a
downscaled image is being drawn, so I use that method to improve
responsiveness while the user is adjusting HSL conversion parameters
in the GUI.
Not sure how relevant this is to your situation, Stephan, but
hopefully it helps.
Lorne Laliberte
Senior Software Developer, Indigo Rose Software
------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial.
http://p.sf.net/sfu/www-adobe-com_______________________________________________
Vector-agg-general mailing list
Vector-agg-general@...
https://lists.sourceforge.net/lists/listinfo/vector-agg-general