Copy link to clipboard
Copied
Dear Friend,
How to Rasterize the ai Files in Grayscale Using the function sAIRasterize->Rasterize().
If anybody knows the Rasterize the ai file. please guide me.
Regards,
Jayashree.J
Copy link to clipboard
Copied
You can use Rasterize Suite. You should call AIRasterizeSuite::Rasterize() with AIRasterizeSettings provided, where you can set type (AIRasterizeType) to kRasterizeGrayscale.
Quick example:
group should bee existing AIArtHandle - with type kGroupArt
AIErr error;
AIRasterizeSettings settings;
AIColorConvertOptions colorConvertOptions;
AIArtHandle art;
settings.type = kRasterizeGrayscale;
settings.resolution = <desired resolution>; // here enter resolution
settings.antialiasing = 5;
settings.options = kRasterizeOptionsDoLayers;
settings.ccoptions = colorConvertOptions;
settings.preserveSpotColors = true;
error = sAIRasterize->Rasterize(
artSet,
&settings,
&rect,
kPlaceInsideOnTop,
group,
&art,
NULL,
);
You will then get art with type kRasterArt. You can write it to file with compression (JPEG, PNG) using Data Filter Suite.
Copy link to clipboard
Copied
Thanks for your reply..!
I tried these code but Error is occur
Please clarify the below code has any mistake.
AppContext appContext(g_SPPluginRef);
AIErr result = kNoErr;
ArtMatcher artMatcher(1);
artMatcher.SetSpec(0, kAnyArt, 0, 0);
artMatcher.GetMatchingArt();
AIArtSet artset;
sAIArtSet->NewArtSet(&artset);
AIRealRect artBounds;
for (int nIndex = 0; nIndex < artMatcher.GetNumMatches(); ++nIndex)
{
short type;
ai::FilePath fPath;
AIArtHandle art = artMatcher.GetMatchedArt(nIndex);
sAIArt->GetArtType(art,&type);
sAIArtset->AddArtToArtSet(artset, art);
}
AIArtHandle artHandle, rasterHandle;
sAIArt->GetFirstArtOfLayer(NULL, &artHandle);
AIRasterizeSettings settings;
AIColorConvertOptions colorConvertOptions;
AIArtHandle art;
settings.type = kRasterizeGrayscale;
settings.resolution = 72; // here enter resolution
settings.antialiasing = 5;
settings.options = kRasterizeOptionsDoLayers;
settings.ccoptions = colorConvertOptions;
settings.preserveSpotColors = true;
result = sAIRasterize->Rasterize(
artset,
&settings,
&artBounds,
kPlaceInsideOnTop,
artHandle,
&art,
NULL
);
Copy link to clipboard
Copied
I forgot to mention you about ArtSet, but I see you find it out. You didn't set artBounds, call AIRasterizeSuite::ComputeArtBounds to calculate art bounds. Which error code you get?