I've created my own custom BitmapEffect based on the RGBFilter example from
MSDN. However, I've noticed that both my effect and the RGBFilter effect
fail to pay attention to the BitmapEffectInput, and always process the entire
image.
For example, add this:
<Image.BitmapEffectInput>
<BitmapEffectInput AreaToApplyEffect=".25,.25,.50,.50"
AreaToApplyEffectUnits="RelativeToBoundingBox"/>
</Image.BitmapEffectInput>
and it will be ignored.
Does anyone know how I can get the BitmapEffectInput from inside my
implementation of IMILBitmapEffectPrimitive?
Ike Starnes - 01 Mar 2008 01:31 GMT
Here is the solution:
In the GetOutput implementation I used the IMILBitmapEffectRenderContext.
To take the area of interest into account, I got the
IMILBitampEffectRenderContextImpl from IMILBitmapEffectRenderContext.
Code Snippet
//**********************************************************************
// Get our render context's implementation interface
//**********************************************************************
CComPtr<IMILBitmapEffectRenderContextImpl> spRenderContextImpl;
if (SUCCEEDED(hr))
{
hr = pRenderContext->QueryInterface(__uuidof
IMILBitmapEffectRenderContextImpl),
reinterpret_cast<void**>(&spRenderContextImpl));
}
Then, I used the GetOutputBounds method of the
IMILBitmapEffectRenderContextImpl.
Using that, I can apply the effect only to the output bounds specified by
the BitmapEffectInput.