• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to Rasterize the ai File in Grayscale

Community Beginner ,
Aug 05, 2020 Aug 05, 2020

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

TOPICS
SDK

Views

249

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Participant ,
Aug 06, 2020 Aug 06, 2020

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 06, 2020 Aug 06, 2020

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 07, 2020 Aug 07, 2020

Copy link to clipboard

Copied

LATEST

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines