THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 25/11/2008 at 10:30, xxxxxxxx wrote:
Sorry, the last example was missing a line. Please use this one :
void C4dMaterial::StepThruLayers(PaintLayer *layer)
{
while (layer)
{
if (layer)
{
LONG sb = SAVEBIT_16b*tchANNELS;
PaintTexture *pntTexture = layer->GetPaintTexture();
if ( pntTexture )
{
AutoAlloc<BaseBitmap> bitmap;
if (layer->ReCalc(NULL,0,0,layer->GetBw(),layer->GetBh(), bitmap,RECALC_NOGRID|RECALC_INITBMP,0))
{
std::string tmpPath_tif_str = "/mcp/" + CspUtilsGeneral::ToStdString( layer->GetName() ) + "_" + ".tif";
Filename tmpPath_tif = Filename( tmpPath_tif_str.c_str() );
BaseContainer data;
if (!bitmap->Save(tmpPath_tif, FILTER_TIF, &data;, sb))
{
std::cerr << "Error saving image \n";
}
}
} else
{
std::cerr << "No Paint Texture!!!!!" << std::endl;
}
}
StepThruLayers((PaintLayer* )layer->GetDown());
layer = (PaintLayer* )layer->GetNext();
}
}
bool C4dMaterial::printLayers(BaseDocument *doc)
{
Filename fn;
if(!fn.FileSelect(FSTYPE_IMAGES, 0, NULL)) return TRUE;
PaintTexture *tex = NULL;
BaseContainer bc;
bc.SetFilename(LOADTEXTURE_FILENAME, fn);
tex = (PaintTexture* )SendPainterCommand(PAINTER_LOADTEXTURE, doc, NULL, &bc;);
if(!tex) return TRUE;
PaintLayer *layer = NULL;
layer = tex->GetFirstLayer();
StepThruLayers(layer);
return TRUE;
}
Here's the deal - when I call Recalc on the PaintTexture object :
(pntTexture->ReCalc(NULL,0,0,pntTexture->GetBw(),pntTexture->GetBh(), bitmap,RECALC_NOGRID|RECALC_INITBMP,0))
I get a valid BaseBitmap object back (bitmap), and can save out a texture (which of course is the entire .psd flattened down).
So, in attempting to save out each individual layer, I am calling ReCalc on each PaintLayer object in the above example (it is inherited from PaintBitmap, after all) :
(layer->ReCalc(NULL,0,0,layer->GetBw(),layer->GetBh(), bitmap,RECALC_NOGRID|RECALC_INITBMP,0))
This ReCalc call returns true, but I am not able to save the bitmap to disk.
Any help is appreciated!!!