Creating, Viewing, and Merging Color Separations (Visual Basic)
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. |
|
3. |
In the Properties box, change the CommandButton control's Caption property to Do Separations. |
4. |
Add the LEAD RasterProcess Object Library to your project. |
|
On the Project pull-down menu, use the References option, and select the LEAD RasterProcess Object Library (14.5). |
5. |
Add the following code to the general declarations section of your project. |
Public RasterProc As LEADRasterProcess
6. |
Add the following code to the end of the Form_Load event handler. |
'Create the RasterProcess Object
Set RasterProc = CreateObject("LEADRasterProcess.LEADRasterProcess. ")
7. |
Add the following code to the CommandButton control's Click procedure. In online help, you can use the Edit pull-down menu to copy the block of code. |
Sub Command6_Click ()
Dim msg As String
' Count the button clicks and take the next step with each click
Static ClickCount As Integer
MousePointer = 11 ' hourglass
'Turn off the automatic display rectangles.
LEADRasterView1.AutoSetRects = False
LEADRasterView1.Raster.RefBitmap = False
Select Case ClickCount
Case 0
RasterProc.ColorSeparate LEADRasterView1.Raster, COLORSEP_CMYK
'Just for fun, add contrast to the K plane
LEADRasterView1.Raster.Bitmap = RasterProc.ColorPlanes(3) 'Copy the K plane
RasterProc.Contrast LEADRasterView1.Raster, 300 'Increase the contrast
RasterProc.ColorPlanes(3) = LEADRasterView1.Raster.Bitmap 'Update the K plane
msg = "Separated. Keep clicking to see separations, then merge"
MsgBox msg
Case 1
LEADRasterView1.Raster.Bitmap = RasterProc.ColorPlanes(0) 'Cyan
LEADRasterView1.ForceRepaint
Case 2
LEADRasterView1.Raster.Bitmap = RasterProc.ColorPlanes(1) ' Magenta
LEADRasterView1.ForceRepaint
Case 3
LEADRasterView1.Raster.Bitmap = RasterProc.ColorPlanes(2) ' Yellow
LEADRasterView1.ForceRepaint
Case 4
LEADRasterView1.Raster.Bitmap = RasterProc.ColorPlanes(3) ' K
LEADRasterView1.ForceRepaint
Case 5
RasterProc.ColorMerge LEADRasterView1.Raster, 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"
MsgBox msg
Case Else
ClickCount = -1
msg = "Cycle is finished"
MsgBox msg
End Select
ClickCount = ClickCount + 1
MousePointer = 0 ' default
End Sub
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. |