Creating, Viewing, and Merging Color Separations (JavaScript)
Take the following steps to add code that creates CMYK color separations, displays each of the color planes, merges the planes, and displays the result. The code increases the contrast of the K plane to demonstrate how you can manipulate the color separations:
1. |
Start with the project that you created in Loading and Displaying an Image. |
2. |
Add the following code between the <BODY> </BODY> tags to add a LEAD Raster Process object named RasterProc: |
<OBJECT ID="RasterProc" NAME="RasterProc"
CLASSID="CLSID:00140712-B1BA-11CE-ABC6-F5B2E79D9E3F"
CODEBASE="path to CAB file/Ltrpr14n.cab">
<P>This is not supported in the web browser.</P>
</OBJECT><BR>
3. |
Add the following code between the <FORM> </FORM> tags to add the button btnColorSeparate: |
<INPUT TYPE="button" NAME="btnColorSeparate" VALUE="Color Separate" LANGUAGE="JavaScript"
OnClick="ColorSeparate()">
4. |
Add the following code between the <SCRIPT> </SCRIPT> tags: |
var ClickCount = 0;
5. |
Add the following code between the <SCRIPT> </SCRIPT> tags for btnColorSeparate button: |
function ColorSeparate()
{
var msg;
var COLORSEP_CMYK = 1;
//Turn off the automatic display rectangles.
LEADRasterView1.AutoSetRects = false;
LEADRasterView1.RasterUnk.RefBitmap = false;
switch(ClickCount)
{
case 0:
RasterProc.ColorSeparate(LEADRasterView1.RasterUnk, COLORSEP_CMYK);
//Just for fun, add contrast to the K plane
LEADRasterView1.RasterUnk.Bitmap = RasterProc.ColorPlanes(3); //Copy the K plane
RasterProc.Contrast(LEADRasterView1.RasterUnk, 300); //Increase the contrast
RasterProc.ColorPlanes(3) = LEADRasterView1.RasterUnk.Bitmap; //Update the K plane
msg = "Separated. Keep clicking to see separations, then merge";
alert(msg);
break;
case 1:
LEADRasterView1.RasterUnk.Bitmap = RasterProc.ColorPlanes(0); //Cyan
LEADRasterView1.ForceRepaint ();
break;
case 2:
LEADRasterView1.RasterUnk.Bitmap = RasterProc.ColorPlanes(1); //Magenta
LEADRasterView1.ForceRepaint ();
break;
case 3:
LEADRasterView1.RasterUnk.Bitmap = RasterProc.ColorPlanes(2); //Yellow
LEADRasterView1.ForceRepaint ();
break;
case 4:
LEADRasterView1.RasterUnk.Bitmap = RasterProc.ColorPlanes(3); //K
LEADRasterView1.ForceRepaint ();
break;
case 5:
RasterProc.ColorMerge(LEADRasterView1.RasterUnk, COLORSEP_CMYK);
LEADRasterView1.ForceRepaint ();
RasterProc.ColorPlanes(0) = 0;
RasterProc.ColorPlanes(1) = 0;
RasterProc.ColorPlanes(2) = 0;
RasterProc.ColorPlanes(3) = 0;
msg = "Merged, with more contrast in the K plane";
alert(msg);
break;
default:
ClickCount = -1;
msg = "Cycle is finished";
alert(msg);
}
ClickCount = ClickCount + 1;
}
6. |
Run your page to test it. |