Creating, Viewing, and Merging Color Separations (C++ Builder 6.0)
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 a button to your form and name it as follows: |
|
|
Put it at the top of the form to keep it away from the image. |
|
|
Name |
Caption |
|
btnDoSeparations |
Do Separations |
3. |
On the Project pull-down menu, use the Import Type library… and install the LEAD Raster Process object library (14.5). Press OK. |
|
4. |
Select LEAD Raster Process from the ActiveX tab and add it to your form. |
|
5. |
Add the following variables to “Unit1.h” file private declarations section. |
//Count the button clicks and take the next step with each click
int ClickCount;
6. |
Add the following code to the end of the form's Create procedure. |
ClickCount:= 0 ;
7. |
Code the btnDoSeparations click’s procedure as the following. In online help, you can use the Edit pull-down menu to copy the block of code. |
void __fastcall TForm1::btnDoSeparationsClick(TObject *Sender)
{
AnsiString Msg;
Cursor = crHourGlass;
//Turn off the automatic display rectangles.
LEADRasterView1->AutoSetRects = False;
LEADRasterView1->Raster->RefBitmap = False;
switch (ClickCount)
{
case 0:
{
LEADRasterProcess1->ColorSeparate ( LEADRasterView1->Raster, COLORSEP_CMYK ) ;
//Just for fun, add contrast to the K plane
LEADRasterView1->Raster->Bitmap = LEADRasterProcess1->get_ColorPlanes(3) ;//Copy the K plane
LEADRasterProcess1->Contrast(LEADRasterView1->Raster, 300) ;//Increase the contrast
LEADRasterProcess1->set_ColorPlanes (3, LEADRasterView1->Raster->Bitmap) ;//Update the K plane
Msg = "Separated. Keep clicking to see separations, then merge";
ShowMessage (Msg) ;
}
break;
case 1:
{
LEADRasterView1->Raster->Bitmap = LEADRasterProcess1->get_ColorPlanes(0); //Cyan
LEADRasterView1->ForceRepaint ( );
}
break;
case 2:
{
LEADRasterView1->Raster->Bitmap = LEADRasterProcess1->get_ColorPlanes(1); //Magenta
LEADRasterView1->ForceRepaint ( ) ;
}
break;
case 3:
{
LEADRasterView1->Raster->Bitmap = LEADRasterProcess1->get_ColorPlanes (2); //Yellow
LEADRasterView1->ForceRepaint ( );
}
break;
case 4:
{
LEADRasterView1->Raster->Bitmap = LEADRasterProcess1->get_ColorPlanes(3); // K
LEADRasterView1->ForceRepaint ( );
}
break;
case 5:
{
LEADRasterProcess1->ColorMerge ( LEADRasterView1->Raster, COLORSEP_CMYK ) ;
LEADRasterView1->ForceRepaint ( );
LEADRasterProcess1->set_ColorPlanes(0, 0);
LEADRasterProcess1->set_ColorPlanes(1, 0);
LEADRasterProcess1->set_ColorPlanes(2, 0);
LEADRasterProcess1->set_ColorPlanes (3, 0);
Msg = "Merged, with more contrast in the K plane";
ShowMessage (Msg);
}
break;
default:
{
ClickCount = -1;
Msg = "Cycle is finished";
ShowMessage ( Msg ) ;
}
}
ClickCount++;
Cursor= crDefault;
}
8. |
Run your program to test it. Notice that you can click the button several times to create the separations, view each of them, and merge them to recreate the original bitmap. |