On 20/07/2015 at 04:56, xxxxxxxx wrote:
Hello,
as discussed on different threads, one must use a MultipassBitmap to render alpha layers with RenderDocument.
It seems there is no build-in functionality to handle your specific use case. So you might have to copy an alpha layer yourself into a BaseBitmap. This could look like this:
const Int32 alphaLayerCount = mpBitmap->GetAlphaLayerCount();
for(Int32 i = 0; i < alphaLayerCount; ++i)
{
MultipassBitmap* alphaChannel = mpBitmap->GetAlphaLayerNum(i);
const Int32 h = alphaChannel->GetBh();
const Int32 w = alphaChannel->GetBw();
// create basebitmap
BaseBitmap* temp = BaseBitmap::Alloc();
temp->Init(w, h, COLORMODE_RGBf);
// copy
UChar* buf= NewMem(UChar, w);
Float32* rgbBuf = NewMem(Float32, w * 3);
for(Int32 line = 0; line < h; ++line)
{
// get pixels
alphaChannel->GetPixelCnt(0, line, w, buf, 1, COLORMODE_GRAY, PIXELCNT_0);
for(Int32 x = 0; x < w; ++x)
{
// read
UChar grey = buf[x];
Float greyF = Float32(grey) / 256.0;
// write
rgbBuf[3*x] = greyF;
rgbBuf[3*x+1] = greyF;
rgbBuf[3*x+2] = greyF;
}
// set pixels
temp->SetPixelCnt(0,line,w,(UChar* )rgbBuf,3 * sizeof(Float32),COLORMODE_RGBf,PIXELCNT_0);
}
// free memory
DeleteMem(buf);
DeleteMem(rgbBuf);
// create small bitmap and scale
BaseBitmap* smallBitmap = BaseBitmap::Alloc();
smallBitmap->Init(400, 300, COLORMODE_RGBf);
temp->ScaleIt(smallBitmap, 256, true, false);
// show results
ShowBitmap(temp);
ShowBitmap(smallBitmap);
// free memory
BaseBitmap::Free(smallBitmap);
BaseBitmap::Free(temp);
}
best wishes,
Sebastian