Copy link to clipboard
Copied
I tried 2 methods, none of them worked.
1:
- AVDoc avDoc = AVAppGetActiveDoc();
- PDDoc pdDoc = AVDocGetPDDoc(avDoc);
- PDColorConvertParams colorParams = (PDColorConvertParams) calloc( 1 , sizeof(PDColorConvertParamsRec) );
- PDColorConvertAction colorConvertAction = (PDColorConvertAction) calloc( 1 , sizeof( PDColorConvertActionRec ) );
- ASBool pageChanged = false;
- AC_Profile workingProfile;
- ACGetWorkingSpaceProfile (kACWorkingCMYK, &workingProfile);
- //Populate the PDColorConvertAction data members
- colorConvertAction[0].mMatchAttributesAny = -1;//kColorConvObj_AnyObject;
- colorConvertAction[0].mMatchSpaceTypeAny = -1;//kColorConvAnySpace;
- colorConvertAction[0].mMatchIntent= AC_UseProfileIntent;
- colorConvertAction[0].mConvertIntent = AC_UseProfileIntent;
- colorConvertAction[0].mConvertProfile= workingProfile;
- colorConvertAction[0].mEmbed = true;
- colorConvertAction[0].mPreserveBlack = true;
- colorConvertAction[0].mUseBlackPointCompensation= true;
- colorConvertAction[0].mAction = kColorConvConvert;
- colorConvertAction[0].mIsProcessColor = false;
- colorParams->mActions = colorConvertAction;
- colorParams->mNumActions = 1;
- colorParams->mInks = NULL;
- colorParams->mNumInks = 0;
- pageChanged = false;
- PDDocColorConvertPage( pdDoc , colorParams , 0 , NULL , NULL , 0 , NULL , &pageChanged );
2:
- AVDoc avDoc = AVAppGetActiveDoc();
- PDDoc pdDoc = AVDocGetPDDoc(avDoc);
- int pageCount = PDDocGetNumPages(pdDoc);
- for(int i=0;i<pageCount;i++)
- {
- PDPage page = PDDocAcquirePage(pdDoc, i);
- PDEContent pdeContent = PDPageAcquirePDEContent(page, gExtensionID);
- ASInt32 elementCount = PDEContentGetNumElems(pdeContent);
- for(int j=0;j<elementCount;j++)
- {
- PDEElement e = PDEContentGetElem(pdeContent, j);
- ASInt32 t = PDEObjectGetType(e);
- if(t == kPDEImage)
- {
- PDEImage pdeImage = (PDEImage)element;
- PDEColorSpace space = PDEImageGetColorSpace(pdeImage);
- ASAtom spaceName = PDEColorSpaceGetName(space);
- if(std::string(ASSAtomGetString(spaceName)) == "DeviceCMYK")
- {
- PDEColorSpace cmyk = PDEColorSpaceCreateFromName(ASAtomFromString("DeviceCMYK"));
- PDEImageSetColorSpace(pdeImage, cmyk);
- }
- }
- }
- PDPageSetPDEContent(page, gExtensionID);
- PDPageNotifyContentsDidChange(page);
- PDPageReleasePDEContent(page, gExtensionID);
- PDPageRelease(page)
- }
1 Correct answer
The second method is a definitely fail – that won’t do any color conversion. There is an API for color converting a single PDEElement, though can’t recall it offhand.
On #1
- the BIG issue is that you aren’t setting a value for the mSize member in the ActionRec
- The second issue is that you aren’t clearing the memory and/or setting all unused fields to 0. Memory is a funny thing ☺.
- Finally, not sure why you are using -1’s instead of the proper kColorConvObj_AnyObject, etc. Use the constants,
...Copy link to clipboard
Copied
The second method is a definitely fail – that won’t do any color conversion. There is an API for color converting a single PDEElement, though can’t recall it offhand.
On #1
- the BIG issue is that you aren’t setting a value for the mSize member in the ActionRec
- The second issue is that you aren’t clearing the memory and/or setting all unused fields to 0. Memory is a funny thing ☺.
- Finally, not sure why you are using -1’s instead of the proper kColorConvObj_AnyObject, etc. Use the constants, they are there for a reason
Copy link to clipboard
Copied
I didn't find mSize member in the PDColorConvertActionRec
I've changed like this, but still not:
- AVDoc avDoc = AVAppGetActiveDoc();
- PDDoc pdDoc = AVDocGetPDDoc(avDoc);
- ASBool pageChanged = false;
- PDColorConvertParamsRec colorParams = {0};
- PDColorConvertActionRec colorConvertAction = {0};
- AC_Profile workingProfile;
- ACGetWorkingSpaceProfile(kACWorkingCMYK, &workingProfile);
- colorConvertAction.mMatchAttributesAny = kColorConvObj_AnyObject;
- colorConvertAction.mMatchSpaceTypeAny = kColorConvAnySpace;
- colorConvertAction.mMatchIntent= AC_UseProfileIntent;
- colorConvertAction.mConvertIntent = AC_UseProfileIntent;
- colorConvertAction.mConvertProfile= workingProfile;
- colorConvertAction.mEmbed = true;
- colorConvertAction.mPreserveBlack = true;
- colorConvertAction.mUseBlackPointCompensation= true;
- colorConvertAction.mAction = kColorConvConvert;
- colorConvertAction.mIsProcessColor = false;
- colorParams.mActions = &colorConvertAction;
- colorParams.mNumActions = 1;
- colorParams.mInks = NULL;
- colorParams.mNumInks = 0;
- PDDocColorConvertPage( pdDoc , &colorParams , 0 , NULL , NULL , 0 , NULL , &pageChanged );
Copy link to clipboard
Copied
Ah, I see now.
I am looking at the Ex versions of these structures and APIs…

