Creating, Viewing, and Merging Color Separations (Delphi 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 select the LEAD Raster Process object library (14.5).

4.

Select LEAD Raster Process from the ActiveX tab and add it to your form.

5.

Add the following variables to the Main Form’s private declarations section.

//Count the button clicks and take the next step with each click
ClickCount: Integer;

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.

procedure TForm1.btnDoSeparationsClick(Sender: TObject); 
var
   Msg: String; 
begin
   Cursor := crHourGlass; 
   //Turn off the automatic display rectangles. 
   LEADRasterView1.AutoSetRects := False; 
   LEADRasterView1.Raster.RefBitmap := False; 
   Case ClickCount of
      0: 
      begin
         LEADRasterProcess1.ColorSeparate ( LEADRasterView1.Raster, COLORSEP_CMYK ) ; 
           //Just for fun, add contrast to the K plane
           LEADRasterView1.Raster.Bitmap := LEADRasterProcess1.ColorPlanes [3] ;//Copy the K plane
           LEADRasterProcess1.Contrast (LEADRasterView1.Raster, 300) ;//Increase the contrast
           LEADRasterProcess1.ColorPlanes[3] := LEADRasterView1.Raster.Bitmap ;//Update the K plane
           Msg := 'Separated. Keep clicking to see separations, then merge'; 
           ShowMessage ( Msg ) ; 
      end; 
      1: 
      begin
         LEADRasterView1.Raster.Bitmap := LEADRasterProcess1.ColorPlanes [0]; //Cyan
           LEADRasterView1.ForceRepaint (  ) ; 
      end; 
      2: 
      begin
         LEADRasterView1.Raster.Bitmap := LEADRasterProcess1.ColorPlanes[1]; //Magenta
           LEADRasterView1.ForceRepaint (  ) ; 
      end; 
      3: 
      begin
         LEADRasterView1.Raster.Bitmap := LEADRasterProcess1.ColorPlanes[2]; //Yellow
         LEADRasterView1.ForceRepaint (  ); 
      end; 
      4: 
      begin
         LEADRasterView1.Raster.Bitmap := LEADRasterProcess1.ColorPlanes[3]; // K
         LEADRasterView1.ForceRepaint (  ); 
      end; 
      5: 
      begin
           LEADRasterProcess1.ColorMerge ( LEADRasterView1.Raster, COLORSEP_CMYK ) ; 
           LEADRasterView1.ForceRepaint (  ); 
           LEADRasterProcess1.ColorPlanes[0] := 0; 
           LEADRasterProcess1.ColorPlanes[1] := 0; 
           LEADRasterProcess1.ColorPlanes[2] := 0; 
           LEADRasterProcess1.ColorPlanes [3] := 0; 
           msg := 'Merged, with more contrast in the K plane'; 
           ShowMessage (Msg); 
      end; 
      else
      begin
        ClickCount := -1; 
        msg := 'Cycle is finished'; 
        ShowMessage ( Msg ) ; 
      end; 
   end; 
   ClickCount:= ClickCount + 1; 
   Cursor:= crDefault; 

end; 

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. Put it at the top of the form to keep it away from the image.