ImageControls:
Product
Support Overview
ImageControls 3:
Product
Support Overview
Application
Notes
Downloads
Library
Error
Codes
FAQs
Revision
Levels
Supported
Configurations
Technical
Documentation
OTHER TOOLS:
Knowledgebase
Support
Request
PRODUCT INFO:
Product
Overview
IC Toolkit 3.1 is the most recent release of the ImageControls Toolkit.
If you are running a previous version of Kofax ImageControls, refer to the ImageControls How to Buy Web page for details on how to obtain the appropriate ImageControls 3 release for your configuration.
ImageControls developers have expressed great interest in being able to manipulate images after they have been scanned and saved. Though v2.x and v3.x of the ImageControls Toolkit includes the ability to perform some image enhancement, it is designed to primarily provide the ability to capture image data. The ability to manipulate image data is considered secondary.
Previously, ImageControls allowed a developer to display images that were shown in reverse color. This capability is not presently functioning in the ImageControls KView control. This will be corrected in the future, but the following project will demonstrate how, through the use of Microsoft's own Windows 95, Windows 98 and Windows NT 4.0 built in imaging capabilities, a developer would be able to create a temporary "workaround" solution. One typical use of displaying a image in inverted format would be for viewing images stored on microfilm or microfiche, where the background is black and image is not easily read.
This project modifies the original demonstration utility, VBDEM32x.EXE, source code as provided with the ImageControls Toolkit. It consists of the following:
Figure 1 displays the placement of these objects on the form.
This form is accessed from the main form, frmMain, of VBDemo. A menu selection was added to the View pull down menu of the main form. When this is selected, frmInvert is displayed along with the inverted image. The active image, g_ActiveKview object, in the main form contains the original image. The item mnuViewInvert is added after the item mnuViewDisplayProperties in the Menu Editor for the menu of the main form.
The following code was created so that the new form would be displayed when this menu item was selected:
Private Sub mnuViewInvert_Click()
Load frmInvert
frmInvert.Show vbModal
End Sub
The form is displayed in application modal format. This form must be closed to continue.
The procedure Private Sub mnuView_Click()was modified with the following:
'***** Update Invert Image Availability
mnuViewInvert.Enabled = g_ActiveKView.Displayed
This change was added to the end of the procedure so that the menu item would only become available when a active image was being viewed and ready to be inverted.
After this point, all additional code is contained in its own module with its own form, its own KScan control and its own ImgAdmin and ImgEdit controls.
The only module global variable is g_FileName, which is declared in the General Declarations:
'***** Global variable filename of inverted image for module
Dim g_InvFileName As String
The size and placement of the form is first step when the form is loaded. The second step includes reserving the import source. This project uses file importation, and will select the first file import source setup in the Kofax Source Manager (KSM). This will normally be the default "Software File Import" source. A software file import source must be defined in the KSM. The import settings are set to overwrite and a single image, then the import process is started. The import process, using the KScan control, will import the active image in the main form and set the image photometric interpretation to inverted. Once this import process is completed, the source is unreserved. Finally, the ImgEdit control is used to display this new inverted image.
Private Sub Form_Load()
'***** Set size of Inverted View form.
Width = Screen.Width * 0.43 ' Set width of form.
Height = Screen.Height * 0.8 ' Set height of form.
Left = (Screen.Width - Width) / 2 ' Center form horizontally.
Top = (Screen.Height - Height) / 2 ' Center form vertically.
'***** Select first software import source as engine. System must
'***** have a software import source in KSM.
If Not KScanInvert.DeviceReserved Then
KScanInvert.DeviceAlias = frmInvert!KScanInvert.DeviceDiskCap(1)
KScanInvert.ActiveDevice = KSACTIVEDEVICEDISK
KScanInvert.Action = KSACTIONRESERVE
End If
'***** Import settings to insert image from KViewLeft to
'***** Wang/Eastman/Kodak Image view
KScanInvert.IOWriteMode = KGIOWRITEMODEOVERWRITE
KScanInvert.DeviceMethod = KSDEVICEMETHODSINGLE
KScanInvert.Action = KSACTIONSTART
KScanInvert.Action = KSACTIONUNRESERVE
'***** Initial settings for Wang/Eastman Image view
ImgEdit1.SelectionRectangle = False
ImgEdit1.Image = g_InvFileName
ImgEdit1.FitTo (2)
ImgEdit1.Display
End Sub
During the import process, the active image contained in the main form is set for import, and the caption for the form is set to display the path and filename of this image. A software engine performing a import will copy the data from the original image source file to the selected source file. As a result, if the user selects to invert a image that cannot be inverted, such as a JPEG format image or a greyscale or color TIFF image, then the image will be copied over without inverting the image data.
Private Sub KScanInvert_PageStart()
'***** Set to import image contained in the main viewer, KViewLeft.
KScanInvert.PSFileName = g_ActiveKView.FileName
KScanInvert.PSPage = g_ActiveKView.Page
'***** Set caption of Inverted Image form to show filename.
frmInvert.Caption = KScanInvert.PSFileName
End Sub
The image is imported to a temporary file "invtemp.tif". The property PEColor is set to invert the bit color (photometric interpretation) of the image data that is to be saved. This property is only valid during the KScan_PageEnd event. The global variable name is set to the temporary file. This module global variable is used instead of a constant value as it also acts as a flag for the ImgEdit1.Display statement during the frmInvert_Resize event.
Private Sub KScanInvert_PageEnd()
'***** Set temporary file to save out inverted image data.
KScanInvert.PEFileName = "invtemp.tif"
'***** Set the bit color, photometric interpretation, so that
'***** the data will saved in a inverted format.
KScanInvert.PEColor = KGCOLORINVERTED
'***** Set the global variable name to the temporary file
'***** containing the inverted image data.
g_InvFileName = KScanInvert.PEFileName
End Sub
The KScan controls Error event contains simple code to handle an error if one is encountered in importing the image.
Private Sub KScanInvert_Error(nError As Integer, strError As String)
Dim errmsg As String
'***** If error returned
If nError <> 0 Then
'***** Handle VB standard errors as special case
If nError < 20000 Then
Err = nError
strError = Error
End If
'***** Some type of imaging error occurred.
Debug.Print "KScan1 -- Error Event: " & strError
errmsg = Format$(nError) & " : " & strError
Call KFErrorMsgBoxWithString(errmsg)
End If
End Sub
The form may be resized. If the form is resized, so is the ImgEdit control and the image being displayed. The image will either be set to fit to width or fit to height.
Private Sub Form_Resize()
'***** If window is being minimized, skip Resize of controls
If Me.WindowState = 1 Then
Exit Sub
End If
'***** Resize view controls based on window size and Picture bar
ImgEdit1.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight
'***** If image is in ImgEdit, display it at new size.
If g_InvFileName <> "" Then
ImgEdit1.Display
End If
End Sub
The form displaying the inverted image includes a menu. This menu consists of:
Caption Name
&File mnuFile
…&Print mnuFilePrint
…- mnuSEPERATOR1
…E&xit mnuExit
&View mnuView
…Fit to &Height mnuViewFitHeight
…Fit to &Width mnuViewFitWidth
…- mnuSEPERATOR0
…Scale &1:1 (100%) mnuView1to1
…Scale &2:1 (50%) mnuView2to1
…Scale &4:1 (25%) mnuView4to1
The menu selections are used to print the inverted image, exit the form and adjust the scale of the view. ImgAdmin is used to display the Print dialog box.
Private Sub mnuFilePrint_Click()
'***** Open ImgAdmin's Print dialog and call ImgEdit Print function.
Dim Prnt_Format As Integer
Dim Prnt_Annotation As Boolean
'***** Set Image Filename to administrate with the ImgEdit
ImgAdmin1.Image = ImgEdit1.Image
'***** Clear Flags in ImgAdmin so Print Dialog box will display
ImgAdmin1.Flags = 0
'***** Set default values for printing
ImgAdmin1.PrintOutputFormat = OutFitPage
ImgAdmin1.PrintAnnotations = False
'***** Handle Error in case of Cancel on Print Dialog
On Error Resume Next
'***** Display Print Dialog box
ImgAdmin1.ShowPrintDialog frmInvert.hWnd
'***** If OK button selected in Print Dialog box, Print Image
If ImgAdmin1.StatusCode = SUCCESS Then
Prnt_Format = ImgAdmin1.PrintOutputFormat
Prnt_Annotation = ImgAdmin1.PrintAnnotations
ImgEdit1.PrintImage ImgEdit1.Page, ImgEdit1.Page, Prnt_Format,
Prnt_Annotation
End If
End Sub
When exiting the invert form is unloaded and the VBDemo main form displayed.
Private Sub mnuFileExit_Click()
'***** Unload the inverted view form.
Unload Me
frmMain.Show
End Sub
Private Sub Form_Unload(Cancel As Integer)
'***** Remove temporary file created for inverted view.
Kill g_InvFileName
'***** Initialize Global Filename variable
g_InvFileName = ""
'***** Unload the inverted view form.
Unload Me
End Sub
The various view selections are used to dynamically fit the image to the ImgEdit control height or width, or to view the image at 100%, 50% or 25% scale.
Private Sub mnuViewFitHeight_Click()
'***** Set to fit dynamically at control height.
ImgEdit1.FitTo (2)
End Sub
Private Sub mnuViewFitWidth_Click()
'***** Set to fit dynamically at control width.
ImgEdit1.FitTo (1)
End Sub
Private Sub mnuView1To1_Click()
'***** Set zoom to image actual size. Display at new setting.
ImgEdit1.Zoom = 100
ImgEdit1.Display
End Sub
Private Sub mnuView2To1_Click()
'***** Set zoom to half size actual and display.
ImgEdit1.Zoom = 50
ImgEdit1.Display
End Sub
Private Sub mnuView4To1_Click()
'***** Set zoom to quarter of actual size and display.
ImgEdit1.Zoom = 25
ImgEdit1.Display
End Sub

You can also download the .frm used to build this project and add it to the VBDEMO code that ships with ImageControls 3.x.
This article contributed by Harold Gue, Developer Support Engineer.
The Kofax ImageControls support group is skilled in Visual Basic and Visual C++ development and can assist developers in building their custom imaging applications. Our engineers can also point developers to source code samples on the Kofax FTP site.
The ImageControls 3 Technical Support Web pages have been kept up to date. We encourage ImageControls developers to investigate the information in these Web pages before looking for other sources of support. Use the menu options in the upper left side of this page to access additional product support Web pages for this product.
For details regarding technical support available for all Kofax products, please review the current Support Overview & Options and Product Support Eligibility Matrix Web pages.
