Skip to main content
December 1, 2011
Question

How to accelerate exporting of multiple layers to PNG-File?

  • December 1, 2011
  • 1 reply
  • 1250 views

Hello,

ai::int32 aint;

sAILayer->CountLayers(&aint);

for (int i = 0; i < (int) aint; i++){

      sAILayer->GetNthLayer((ai::int32) i,&layer);

      artSetSuite->LayerArtSet(layer, artSet);

}

AIArtHandle hand;

sAIArt->GetFirstArtOfLayer(layer, &hand);

e2 = sAIRasterize->Rasterize(artSet, &rs, &bounds, kPlaceAboveAll, hand, &art, MyRasterizeProgressProc);

sAILayer->GetFirstLayer(&layer);

e2 = sAIArt->GetLayerOfArt(art, &layer);

e2 = sAIArt->GetFirstArtOfLayer(layer, &art);

error = sAIImageOptSuite->MakePNG24(art, dstfilter, pngParams2, MyRasterizeProgressProc);

the code above shows how I managed to export a artboard with all layers to PNG-File. My question is, if there is a faster way to combine all layer before exporting, maybe a way without the "temporary layer" (Rasterize(...)-method)?

When I export with the standard-export-button in Adobe Illustrator, it runs fast and with all layers.

I hope you can help me.

Greatings from Germany, Dortmund

This topic has been closed for replies.

1 reply

A. Patterson
Inspiring
December 1, 2011

I'm confused. The code you quoted almost does exactly what I'd suggest, though the opening loop is odd. It seems to get each layer's artset and then do nothing with it (well, the last one would be rasterized). Why aren't you using AIArtSetSuite::UnionArtSet() to combine all the layer art sets into one art set and then rasterizing that? Then I'd make a PNG from the resultant kRasterArt just like you're doing.

I"m also not sure what you mean by 'temporary layer' -- you don't seem to be creating a temporary layer. A temporary raster object, sure, but I suspect that's unavoidable.

December 1, 2011

Thank you for yout answer. I will try this. But can be this a reason for the bad performance?

I must rasterize two times (sAIRasterize->Rasterize and makePNG24). And that's why the performance is really bad.

Without rasterizing the layers, I would get my PNG-Files fast, but only for one layer.