Skip to main content
systems01h61704443
Known Participant
August 5, 2020
Question

How to Rasterize the ai File in Grayscale

  • August 5, 2020
  • 1 reply
  • 477 views

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

This topic has been closed for replies.

1 reply

MilosR
Inspiring
August 6, 2020

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.

systems01h61704443
Known Participant
August 6, 2020

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
);

MilosR
Inspiring
August 7, 2020

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?