Skip to main content
fumi_t
Participant
April 5, 2017
Question

A spot color isn't applied to PDEImage.

  • April 5, 2017
  • 1 reply
  • 411 views

I want to apply a spot color to an image object(PDEImage).

- Case gray scale, apply a spot color to the whole image.

- Case binary image, apply a spot color to only a black part(value == 0).

I programed as follows, but  a spot color isn't applied to an image object.

But, when I check it by the Output Preview, the name of a spot color is applied.

It could be applied by processing similar to PDEPath.

Is processing needed additionally to apply it to PDEImage?

Or is it necessary to use other API?

Would you let me know, please?

-------------------------------------------------------------------

// create PDEColorSpace

ColorSpaceSettingInfo colorSpaceSettingInfo = comEnvironment.getObjectObjColorInfo();

PDEColorSpace colorSpace = createRGBSpotColor(pdDoc, colorSpaceSettingInfo);

// create PDEColorValue

PDEColorValue pdeColorvalue;

memset(&pdeColorvalue, 0, sizeof(PDEColorValue));

pdeColorvalue.color[0] = FloatToASFixed(Tint / 100.0f);

// apply PDEColorSpace and PDEColorValue to PDEImage

PDEGraphicState gstate;

PDEElementGetGState((PDEElement)pdeImage, &gstate, sizeof(gstate));

PDEColorSpec colourSpec;

colourSpec.space = colorSpace;

colourSpec.value = pdeColorvalue;

gstate.strokeColorSpec = gstate.fillColorSpec = colourSpec;

gstate.miterLimit = fixedTen;

gstate.flatness = fixedOne;

gstate.lineWidth = fixedOne;

gstate.extGState = pdeExtGState;

gstate.wasSetFlags = kPDEFillCSpaceWasSet | kPDEFillCValueWasSet | kPDEStrokeCSpaceWasSet | kPDEStrokeCValueWasSet |

  kPDELineWidthWasSet | kPDEMiterLimitWasSet | kPDEFlatnessWasSet | kPDEExtGStateWasSet;

PDEElementSetGState((PDEElement)pdeImage, &gstate, sizeof(gstate));

// create PDEColorSpace

PDEColorSpace OCMDesigner::createRGBSpotColor(PDDoc argPdDoc, ColorSpaceSettingInfo argColorSpaceValue)

{

  /** @par 処理 */

  PDEColorSpace spotColorSpace = NULL;

  try{

  CosDoc cosDoc = PDDocGetCosDoc(argPdDoc);

  std::string colorName = argColorSpaceValue.colorName;

  // C0

  CosObj C0 = CosNewArray(cosDoc, false, 3);

  CosArrayPut(C0, 0, CosNewFloat(cosDoc, false, 1.00f));

  CosArrayPut(C0, 1, CosNewFloat(cosDoc, false, 1.00f));

  CosArrayPut(C0, 2, CosNewFloat(cosDoc, false, 1.00f));

  // C1

  CosObj C1 = CosNewArray(cosDoc, false, 3);

  CosArrayPut(C1, 0, CosNewFloat(cosDoc, false, argColorSpaceValue.colorValue_RCL));

  CosArrayPut(C1, 1, CosNewFloat(cosDoc, false, argColorSpaceValue.colorValue_GMa));

  CosArrayPut(C1, 2, CosNewFloat(cosDoc, false, argColorSpaceValue.colorValue_BYb));

  // Domain

  CosObj domain = CosNewArray(cosDoc, false, 2);

  CosArrayPut(domain, 0, CosNewFloat(cosDoc, false, 0.0f));

  CosArrayPut(domain, 1, CosNewFloat(cosDoc, false, 1.0f));

  // Range

  CosObj range = CosNewArray(cosDoc, false, 6);

  CosArrayPut(range, 0, CosNewFloat(cosDoc, false, 0.0f));

  CosArrayPut(range, 1, CosNewFloat(cosDoc, false, 1.0f));

  CosArrayPut(range, 2, CosNewFloat(cosDoc, false, 0.0f));

  CosArrayPut(range, 3, CosNewFloat(cosDoc, false, 1.0f));

  CosArrayPut(range, 4, CosNewFloat(cosDoc, false, 0.0f));

  CosArrayPut(range, 5, CosNewFloat(cosDoc, false, 1.0f));

  // create dictionary

  CosObj dict = CosNewDict(cosDoc, false, 6);

  CosDictPut(dict, ASAtomFromString("C0"), C0);

  CosDictPut(dict, ASAtomFromString("C1"), C1);

  CosDictPut(dict, ASAtomFromString("Domain"), domain);

  CosDictPut(dict, ASAtomFromString("FunctionType"), CosNewInteger(cosDoc, false, 2));

  CosDictPut(dict, ASAtomFromString("N"), CosNewInteger(cosDoc, false, 1.0f));

  CosDictPut(dict, ASAtomFromString("Range"), range);

  ASStm asStm = ASMemStmRdOpen(TINTTRANSFORM_RGB, strlen(TINTTRANSFORM_RGB));

  CosObj function = CosNewStream(cosDoc, true, asStm, 0, true, dict, CosNewNull(), -1);

  ASStmClose(asStm);

  PDEColorSpace altSpace = PDEColorSpaceCreateFromName(ASAtomFromString("DeviceRGB"));

  PDESeparationColorData data;

  data.alt = altSpace;

  data.name = ASAtomFromString(colorName.c_str());

  data.size = sizeof(data);

  data.tintTransform = function;

  PDEColorSpaceStruct clrStruct;

  clrStruct.sep = &data;

  // create a spot color

  spotColorSpace = PDEColorSpaceCreate(ASAtomFromString("Separation"), &clrStruct);

  }

  catch (bad_alloc& err) {

  TC_ASSERT(MEMORY_ERR, err.what());

  }

  return spotColorSpace;

}

This topic has been closed for replies.

1 reply

Legend
April 5, 2017

I haven't studied your code in detail, but I think you need to read up on image dictionaries in the PDF Reference. In particular, some kinds of image (image masks) will take their colour from the graphics state, like a path. But most images have their own colour space, independent of the graphics state. I think the term "binary image" you use is in PDF terms "image mask".