|
From: Pierre A. <pie...@op...> - 2004-06-20 13:54:17
|
Maxim wrote:
> BTW, what about trying to use IPPI as a low level back-end for AGG?
> Are there simple functions for blending horizontal/vertical spans?
> All we need is to write an agg_pixfmt_ippi.h and maybe agg_color_ippi.h
> to represent colors in more optimized way (say, use the IPPI-specific
> byte order).
There are no span optimized versions, but one can safely use the
generic alpha-composition functions. Here is the (edited) documentation
for 'AlphaComp' which blends two sources to a destination, just so you
get a real feeling of the beast (works on R,G,B,A memory layout) :
-----------------------------------------------------------------------
AlphaComp
---------
Combines two images using alpha (opacity) values of both images.
IppStatus ippiAlphaComp_<mod>(const Ipp<datatype>* pSrc1,
int src1Step,
const Ipp<datatype>* pSrc2,
int src2Step,
Ipp<datatype>* pDst,
int dstStep,
IppiSize roiSize,
IppiAlphaType alphaType);
Supported values for <mod> :
8u_AC1R --> 8-bit unsigned, Alpha, 1 component, uses ROI
8u_AC4R --> 8-bit unsigned, Alpha, 4 components, uses ROI
16u_AC1R --> 16-bit...
16u_AC4R --> 16-bit...
ROI =3D Region of Interest
(I have only used the ippiAlphaComp_8u_AC4R variant).
IppStatus ippiAlphaComp_<mod>(const Ipp<datatype>* const pSrc1[4],
int src1Step,
const Ipp<datatype>* const pSrc2[4],
int src2Step,
Ipp<datatype>* const pDst[4],
int dstStep,
IppiSize roiSize,
IppiAlphaType alphaType);
Supported values for mod :
8u_AP4R --> 8-bit unsigned, Alpha, 4 planes
16u_AP4R --> 16-bit...
Arguments
---------
pSrc1, pSrc2
Pointer to the source buffer for pixel-order data.
An array of pointers to separate source color planes in case
of planar data.
src1Step, src2Step
Steps in bytes through the source image buffers
pDst
Pointer to the destination buffer for pixel-order data.
An array of pointers to separate destination color planes in
case of planar data.
dstStep
Step in bytes through the destination image buffer
roiSize
Size of the source and destination ROI in pixels
alphaType
The composition type to perform. See Table 5-4 for the
type value and description.
Discussion
----------
The function ippiAlphaComp is declared in the ippi.h file. This
function performs an image compositing operation on RGBA images
using alpha values of both images. The compositing is done by
overlaying pixels (rA ,gA ,bA , =CE=B1A ) from the foreground image
pSrc1 with pixels (rB ,gB ,bB , =CE=B1B ) from the background image
pDst2 to produce pixels (rC ,gC ,bC , =CE=B1C ) in the resultant
image pDst.
The alpha values are assumed to be normalized to the range
[0..1]. The type of the compositing operation is indicated by
the alphaType parameter.
Use Table 5-4 to choose a valid alphaType value depending
on the required composition type.
(here, I use ippAlphaOver which does the blending)
For example, the resulting pixel color components for the
OVER operation (see Table 5-3 ) are computed as follows:
rC =3D =CE=B1A *rA +(1 - =CE=B1A )* =CE=B1B *rB
gC =3D =CE=B1A *gA +(1 - =CE=B1A )* =CE=B1B *gB
bC =3D =CE=B1A *bA +(1 - =CE=B1A )* =CE=B1B *bB
The resulting (normalized) alpha value is computed as
=CE=B1C =3D =CE=B1A +(1 - =CE=B1A )* =CE=B1B
This function can be used for unsigned pixel data only.
-----------------------------------------------------------------------
> Well, there are some difficulties with image transformations, but
> it's all doable.
The only problem is, you have to *pay* for the IPPI. The compiled code
can be redistributed royalty free, but the SDK may not be redistributed.
A 30-day demo of the full IPP library can be downloaded from the Intel
developer web site.
Kind regards.
Pierre
|