Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
What's the value of error?
Copy link to clipboard
Copied
I get 1346458189 value in error.
Can it be possible that if any value in bounds is negative, then it gives error?
Copy link to clipboard
Copied
shouldnt all "versionOneSuiteParams" be filled?
params.versionOneSuiteParams.interlaced = ;
params.versionOneSuiteParams.numberOfColors = ;
params.versionOneSuiteParams.transparentIndex = ;
params.versionOneSuiteParams.resolution = ;
params.versionOneSuiteParams.outAlpha = ;
params.versionOneSuiteParams.outWidth = ;
params.versionOneSuiteParams.outHeight = ;
params.antialias = ;
Copy link to clipboard
Copied
1346458189 is 'PARM'. It looks like 'tempRaster' might not be initialized. I'm not sure if the RasterizeSuite->Rasterize(...) does that for you. Passing a null art handle in there is likely to cause problems.
Copy link to clipboard
Copied
Also can't tell from that code snippet if you're initializing your ArtSet correctly. Perhaps MakePNG24(...) doesn't like being passed a NULL parameter for AIRasterizeProgressProc?
Copy link to clipboard
Copied
Mr Big Templeton is absolutely right. AIRasterizeProgressProc shouldnt be null or nil or 0 etc.
static AIBoolean progressProc(long current, long total)
{
return true;
}