6 Replies Latest reply on Sep 17, 2016 10:46 AM by tomr11694738

    How to export contents of a artset as png?

    poortip87 Level 1

      Hi

       

      I want to export the contents of a artset as jpg. I am rasterizing the artset and then exporting it as JPG. But nothing happens.

       

      Here is the code,

       

      AIRasterizeSettings rastSettings;
      AIArtHandle tempRaster = 0;
      AIArtHandle layerGroup = 0;
      error = sAIArtSet->IndexArtSet(artSet, 0, &layerGroup);
      
      AIRealRect bounds;
      error = sAIRasterize->ComputeArtBounds(artSet, &bounds, false);
      
      rastSettings.type = kRasterizeRGB;
      rastSettings.resolution = 72;
      rastSettings.antialiasing = 2;
      rastSettings.options = kRasterizeOptionsNone;
      error = sAIRasterize->Rasterize(artSet, &rastSettings, &bounds, kPlaceInsideOnTop, layerGroup, &tempRaster, 0);
      
      ai::FilePath ioFilePath(ai::UnicodeString("D:\\Samples\\TestSample\\export\\1.png"));
      
      AIDataFilter* dstfilter = NULL;
      AIDataFilter* filter = NULL;
      
      error = sAIDataFilter->NewFileDataFilter(ioFilePath, "write", 'prw', 'PNGf', &filter);
      error = sAIDataFilter->LinkDataFilter(dstfilter, filter);
      dstfilter = filter;
      
      AIImageOptPNGParams2 params;
      params.versionOneSuiteParams.interlaced = true;
      params.versionOneSuiteParams.transparentIndex = 0;
      params.versionOneSuiteParams.resolution = 300;
      params.versionOneSuiteParams.outAlpha = false;
      params.antialias = 0;
      
      params.cropBox = bounds;
      params.backgroundIsTransparent = true;
      error = sAIImageOpt->MakePNG24(tempRaster, dstfilter, params, NULL);
      
      
      
      
      
      
      
      

       

       

      I get an exception in the last line "MakePNG24".

       

      What am I missing?