Creating, Viewing, and Merging Color Separations (Access 2.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. image\btncmd.gif Select the Command Button control; then add the control to your main form. 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 Do Separations.

4. Add the following code to the Command Button control's Click procedure. In online help, you can use the Edit pull-down menu to copy the block of code.

Sub Command6_Click ()

' 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
Me![LEAD1].Object.AutoSetRects = False

Select Case ClickCount
Case 0
  Me![LEAD1].Object.ColorSeparate COLORSEP_CMYK

  'Just for fun, add contrast to the K plane
  Me![LEAD1].Object.Bitmap = Me![LEAD1].Object.ColorPlanes(3) 'Copy the K plane
  Me![LEAD1].Object.Contrast 300 'Increase the contrast
  Me![LEAD1].Object.ColorPlanes(3) = Me![LEAD1].Object.Bitmap 'Update the K plane

  Msg = "Separated. Keep clicking to see separations, then merge"
  MsgBox Msg
Case 1
  Me![LEAD1].Object.Bitmap = Me![LEAD1].Object.ColorPlanes(0) 'Cyan
  Me![LEAD1].Object.ForceRepaint
Case 2
  Me![LEAD1].Object.Bitmap = Me![LEAD1].Object.ColorPlanes(1) ' Magenta
  Me![LEAD1].Object.ForceRepaint
Case 3
  Me![LEAD1].Object.Bitmap = Me![LEAD1].Object.ColorPlanes(2) ' Yellow
  Me![LEAD1].Object.ForceRepaint
Case 4
  Me![LEAD1].Object.Bitmap = Me![LEAD1].Object.ColorPlanes(3) ' K
  Me![LEAD1].Object.ForceRepaint
Case 5
  Me![LEAD1].Object.ColorMerge COLORSEP_CMYK
  Me![LEAD1].Object.ForceRepaint
  Me![LEAD1].Object.ColorPlanes(0) = 0
  Me![LEAD1].Object.ColorPlanes(1) = 0
  Me![LEAD1].Object.ColorPlanes(2) = 0
  Me![LEAD1].Object.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

End Sub

5. 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.