Skip to main content
Participant
August 18, 2010
Question

Filter plug-in: How to mix my RGB image with source document image properly?

  • August 18, 2010
  • 1 reply
  • 905 views

Hi All,

My problem seems to be very common, but I can't find any answers in documentation.

I made Filter plug-in. It composes RGB image and mixes it with user source image in the document.

Now I load FilterRecord->

inData to byte array and recode each pixel with HostCSConvertColor function.

My code looks like that:

  byte

*input = (byte*)filter_record->inData;

  int

width = filter_record->inRect.right - filter_record->inRect.left;

  int height = filter_record->inRect.bottom - filter_record->inRect.top;

  byte

*transfer_buffer;

  int size = width * height * 4;

  transfer_buffer = new byte[size];

  byte *output = transfer_buffer;

  int

planes = CSPlanesFromMode(fpb->imageMode, 3);

  int16 color[4];

  for(j = 0; j < height; j++)

  {

    for(i = 0; i < width; i++)

    {

      for(k = 0; k < planes; k++)

      {

        color[k] = input[i * align + k];

      }

      HostCSConvertColor(filter_record->colorServices, space, plugIncolorServicesRGBSpace, color);

      *

output = (byte)color[0]; output++;

      *

output = (byte)color[1]; output++;

      *

output = (byte)color[2]; output++;

      *

output = 255; output++;

    }

// for width

    input += line;

  } // for height

After that I mix my RGB image with output buffer and make back transition via

HostCSConvertColor to the document Color Space.

It works very slow and looks ugly.

But I can't find any other way to mix my RGB image with photoshop image which can be not RGB Color Mode.

Your help will be very appreciated.

Sofia

This topic has been closed for replies.

1 reply

Noel Carboni
Legend
August 20, 2010

Is it important to you to be able to process input color spaces other than RGB?

You can limit your filter to accept only RGB data if you set things up properly in the PiPL resource (e.g., yourfiltername.r file).

Here's an example for a filter that accepts only RGB or grayscale images:

SupportedModes

{

noBitmap,

doesSupportGrayScale,

noIndexedColor,

doesSupportRGBColor,

noCMYKColor,

noHSLColor,

noHSBColor,

noMultichannel,

noDuotone,

noLABColor

},

EnableInfo { "in (PSHOP_ImageMode, RGBMode, GrayScaleMode, RGB48Mode, Gray16Mode, RGB96Mode, Gray32Mode)" },

With the above, the filter will be disabled (grayed-out in the menu) for modes other than those listed.

-Noel

Participant
August 24, 2010

Thank you very much for your answer.
You are right, I really should inactivate my plugin in non RGB mode. It's better than making Color Space back and forth transitions hidden for user.

Sofia