Issue Retrieving Alpha Layer from a Layer in MultipassBitmap
-
Hello,
I'm experiencing an issue with the Cinema 4D SDK when working with layers and alpha layers in MultipassBitmap objects. Specifically, after adding an alpha layer to a layer within a MultipassBitmap, I'm unable to retrieve it using the available functions.
Here's a simple code snippet demonstrating the problem:
// Allocate a MultipassBitmap AutoFree<MultipassBitmap> bmp = MultipassBitmap::Alloc(800, 600, COLORMODE::ARGBf); if (!bmp) return; // Set parameters for the MultipassBitmap bmp->SetParameter(MPBTYPE_NAME, "bitmap"); bmp->SetParameter(MPBTYPE_SAVE, TRUE); bmp->SetParameter(MPBTYPE_SHOW, TRUE); // Get the first layer of the MultipassBitmap // The first layer is automatically created at the [bmp] allocation time MultipassBitmap* layer = bmp->GetLayerNum(0); if (!layer) return; // Set parameters for the layer layer->SetParameter(MPBTYPE_NAME, "layer0"); layer->SetParameter(MPBTYPE_SAVE, TRUE); layer->SetParameter(MPBTYPE_SHOW, TRUE); // Get the initial alpha layer count Int32 cn = layer->GetAlphaLayerCount(); // Returns 0 as expected // Add an alpha channel to the layer MultipassBitmap* alpha = layer->AddAlpha(nullptr, COLORMODE::GRAYf); if (!alpha) return; // Set parameters for the alpha layer alpha->SetParameter(MPBTYPE_NAME, "alpha0"); alpha->SetParameter(MPBTYPE_SAVE, TRUE); alpha->SetParameter(MPBTYPE_SHOW, TRUE); // Get the updated alpha layer count cn = layer->GetAlphaLayerCount(); // Now returns 1, which is correct // Attempt to get the alpha layer MultipassBitmap* tmpAlpha = layer->GetAlphaLayerNum(0); // Returns null pointer unexpectedly if (!tmpAlpha) { // tmpAlpha is null, even though we just added an alpha layer // This is unexpected behavior } else { // Proceed with tmpAlpha }
Issue:
- After adding an alpha layer to bitmap layer, layer->GetAlphaLayerCount() correctly returns 1.
- However, when I call layer->GetAlphaLayerNum(0), it returns a null pointer.
- It seems that GetAlphaLayerNum() does not retrieve the alpha layer from within the layer, or perhaps I'm using it incorrectly.
Questions:
- How can I retrieve the alpha layer that I've added to a layer within a MultipassBitmap?
- Is there a specific function to access alpha layers within layers of a MultipassBitmap?
- Am I missing any steps or using the functions incorrectly in this context?
Additional Information
- I'm using Cinema 4D SDK version [2024].
- The AddAlpha method seems to work correctly, as the layer count increases after calling it.
- The documentation isn't clear on how to retrieve alpha layers from layers within a MultipassBitmap.
Any insights or solutions would be greatly appreciated!
Thank you in advance for your assistance.