Creating, Viewing, and Merging Color Separations (Access 95 and 97)

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. image\btncmd.gif Select the Command Button control; then add a control to your form. (Cancel the Command Button Wizard when it appears.) Put the control at the top of the form to keep it away from the image.

3. In the Properties box, change the Command Button control's Name property to DoSeparations and change the Caption property to Do Separations.

4. Click the Code Window icon on the toolbar.

image\btncode.gif For Access 95.

image\btncode2.gif For Access 97.

5. Select the Click procedure for the DoSeparations object, and add the following code. In online help, you can select the block of code with the mouse, then press Ctrl-C to copy it.

' Declare a local variable
Dim Msg

' Count the button clicks and take the next step with each click
Static ClickCount As Integer
DoCmd.Hourglass True

'Turn off the automatic display rectangles
Lead1.AutoSetRects = False

Select Case ClickCount
Case 0
  Lead1.ColorSeparate COLORSEP_CMYK

  'Just for fun, add contrast to the K plane
  Lead1.Bitmap = Lead1.ColorPlanes(3) 'Copy the K plane
  Lead1.Contrast 300 'Increase the contrast
  Lead1.ColorPlanes(3) = Lead1.Bitmap 'Update the K plane

  Msg = "Separated. Keep clicking to see separations, then merge"
  MsgBox Msg
Case 1
  Lead1.Bitmap = Lead1.ColorPlanes(0) 'Cyan
  Lead1.ForceRepaint
Case 2
  Lead1.Bitmap = Lead1.ColorPlanes(1) ' Magenta
  Lead1.ForceRepaint
Case 3
  Lead1.Bitmap = Lead1.ColorPlanes(2) ' Yellow
  Lead1.ForceRepaint
Case 4
  Lead1.Bitmap = Lead1.ColorPlanes(3) ' K
  Lead1.ForceRepaint
Case 5
  Lead1.ColorMerge COLORSEP_CMYK
  Lead1.ForceRepaint
  Lead1.ColorPlanes(0) = 0
  Lead1.ColorPlanes(1) = 0
  Lead1.ColorPlanes(2) = 0
  Lead1.ColorPlanes(3) = 0
  Msg = "Merged, with more contrast in the K plane"
  MsgBox Msg
Case Else
  ClickCount = -1
  Msg = "Cycle is finished"
  MsgBox Msg
End Select

ClickCount = ClickCount + 1
DoCmd.Hourglass False

6. image\btncmpl.gif Click the compile button on the toolbar; then close the code window.

7. Close the form designer, saving the changes.

8. With Form1 selected in the Database window, click the Open button to test the form. Notice that the text printed on the bitmap is scaled as part of the bitmap. If you zoom in, it becomes larger, and if you zoom out, it becomes smaller. The text printed on the control is the normal size for the system font and is not affected by zooming.