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

How to solve this??convert CMYKBlack to grayscale

New Here ,
Oct 30, 2008 Oct 30, 2008

Copy link to clipboard

Copied

Hi i need to convert CMYKBlack to grayscale.here is the code im using....
in case of textart..

if(style.fillPaint==1)
{
if( style.fill.color.kind == kFourColor &&
((style.fill.color.c.f.black>0 && style.fill.color.c.f.cyan==0 &&
style.fill.color.c.f.yellow==0 && style.fill.color.c.f.magenta==0) ||
(style.fill.color.c.f.black==0 && style.fill.color.c.f.cyan==0 &&
style.fill.color.c.f.yellow==0 && style.fill.color.c.f.magenta==0)))
{
style.fill.color.kind=kGrayColor;
percentageOfGray=0;

percentageOfGray=(style.fill.color.c.f.cyan) * 30/100;
percentageOfGray=percentageOfGray + ((style.fill.color.c.f.magenta) * 59/100);
percentageOfGray=percentageOfGray + ((style.fill.color.c.f.yellow) * 11/100);
percentageOfGray=percentageOfGray + (style.fill.color.c.f.black);
if (percentageOfGray*100 >100)
{
percentageOfGray=1;
}
style.fill.color.c.g.gray=percentageOfGray;
error = sAITextRun->SetTextRunPathStyle (line,&style );

}
}

error = sAITextRun->SetTextRunPathStyle (line,&style )---------This syntax is used in illustrator 10 for setting the converted color..what is the similar syntax to be used in illustrator cs2.

Please someone help me.......

Thanks in advance......
Subha.....
TOPICS
SDK

Views

660
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
Guide ,
Nov 07, 2008 Nov 07, 2008

Copy link to clipboard

Copied

Sorry, I've been sick for a few days, just got back. Hopefully this will still be useful to you (or someone else!).

First, I just want to mention that there's a suite for doing this kind of thing, the AIColorConversionSuite (AIColourConversion.h). I'd take a look at that; it might simply your conversion code.

As for setting the text colour in CS on, here's the code we use in our application for setting text's stroke colour:

------------- snip --------------
ASSERT(sATEPaint);
ASSERT(sAITextFrame);

TextRangeRef textRangeRef = 0;

// this code is inside an object that represents
// text art, so it has a member that has the art
// handle. This handle is retrieved using GetHandle()
// so just replace 'GetHandle()' with your AIArtHandle
// variable
AIErr error = sAITextFrame->GetATETextRange(GetHandle(), &textRangeRef);
THROW_EXCEP_IF(error);

ATE::ITextRange textRange(textRangeRef);
ATE::ICharFeatures charFeatures = textRange.GetUniqueLocalCharFeatures();

// colour is a pointer to our own colour object; its
// a pointer so that a 'null' stroke can be set
if (colour) {
ATE::ApplicationPaintRef paintRef = 0;
AIColor aiColour;

// this is the colour model of the document,
// which is either CMYK or RGB
EColourModel model = CDocumentList::GetCurrentDocument().GetColourModel();

// we have classes, CRGBColour & CCMYKColour that automatically do
// colour conversion for us -- they use the AIColorConversionSuite
if (eColourModelRGB == model) {
aiColour = (AIColor)(*colour);
} else if (eColourModelCMYK == model) {
aiColour = (AIColor)(CCMYKColour(*colour));
}

error = sATEPaint->CreateATEApplicationPaint(&aiColour, &paintRef);
THROW_EXCEP_IF(error);

ATE::IApplicationPaint paint(paintRef);

// obviously you'd use SetFillColor here if you wanted fill
charFeatures.SetStrokeColor(paint);
charFeatures.SetStroke(true);
} else {
charFeatures.SetStroke(false);
}

textRange.SetLocalCharFeatures(charFeatures);
------------- snip --------------

Note that THROW_EXCEP_IF is a macro of ours that throws an exception if error != kNoErr.

Votes

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
Guide ,
Nov 07, 2008 Nov 07, 2008

Copy link to clipboard

Copied

LATEST
I should also mention that that colour conversion code in the middle is because there used to be (still is?) a bug wherein if you used a colour model different from the document's to set the colour on objects (maybe just text, it's been a while since we had this problem) you'd get complaints the next time the document opened (nothing fatal). We got around it by simply automatically converting to the appropriate colour model. You may have to do the same even though you just want grayscale.

Also note that if you want to set the colour of part of a text object, it's more complicated that what I've outlined above. That requires you to get to know TextRuns & GlyphRuns, etc. If you just want all of some text to be a certain colour though, the above code works great.

Votes

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