Image of Navigational Map linked to Home / Contents / Search Image(Man) is Everything

by Ian Rodda - GUI Computing
Image of Line Break

Need easy to use support for image processing and Twain scanner interface?
You've found it.

ImageMan has been around for a long time (we first reviewed its VBX brother in 1993), but the lastest incarnation - ImageMan ActiveX Suite - has some very nice features. And the stability that such a (for VB) lengthy history endows makes for an easy to use and developer-friendly image solution.

The suite includes support for for the normal huge range of image formats - FlashPix, Photo CD, JPEG, TIFF, BMP, RLE, DIB, EPS, GIF, PNG, TGA, IMG, DXF, PCX, DCX - so if you can't handle it from here, you have a pretty unusual image. And it supports most of the "usual suspects" when it comes to compression as well - Packbits, Group 3, Group 4, Modified Huffman, JPEG, RLE and LZW.

The suite contains four controls : an Image Control, a Twain Control, what ImageMan call a Special Effects control and, perhaps most interestingly, a Plug-In cntrol which enables you to use any of the thousands of Photoshop plugins in your application.

Let's have a look at each in turn.

Image Control

Image controls are in most ways pretty standard fare these days, and ImageMan's doesn't add much to the list, but it certainly doesn't lose anything by comparison with the alternatives, either.

Solid support for loading images, printing and using the clipboard is augmented by image Filters like embossing, edge detection, blur, sharpen, and more as well Brightness, Contrast and Gamma adjustment, image rotation by hundredths of degrees, mirror, flip, invert and automatic Thumbnail generation.

The many image processing features (rotate, mirror, brightness, dithe, etc) are implemented via methods like :-

' Rotate image 45 degrees (in hundredths of degrees) and specify a Red background
ImageMan1.Rotate  4500, RGB(255,0,0)

'Mirror image vertically
ImageMan1.MirrorVertical

The control goes through its paces very nicely, and is certainly brisk in performance terms. As the 'bread and butter' member of the suite, the Image control provides a solid basis.

TWAIN Control

TWAIN devices are all the rage nowadays, with digital cameras and scanners abounding as well as TWAIN support being offered in the newer all-in-one printer/scanner/fax units. The ImageMan TWAIN compatible does a good job of simplifying the process of talking to all these devices, and it only takes a few lines of code to acquire an image from any supported device. ImageMan also has lower level functions that allow you to scan from an Automatic Document Feeder(ADF) and control image attributes such as resolution, color depth, scan area and more.

Includes support for both 16 & 32 bit TWAIN Sources.

'Initiate a scan
TwainControl.Scan bShowUI
'BShowUI specifies if the scanner should show it's user interface when scanning

'Displays dialog to select default Twain device 
Twain1.SelectSources

You can minimize user interaction with the scanner by disabling the scanner's dialog and controlling the scan process with code.

'Disable scan dialog
Twain1.Scan = False

When using your scanner's Automatic Document Feeder to scan multiple pages, set the following properties:

'set to number of pages
Twain1.MaxPages = 2      
'Use Auto Document Feeder
Twain1.UseADF = True

If the actual number of pages is less than the MaxPages value then the scanner control will stop scanning after the last page. If using the scanner's dialog then the dialog will remain open until either MaxPages has been scanned or the user closes the dialog manually. This is a sensibly-implemented control which worked a charm with the (admittedly small) number of TWAIN devices I tested it on.

Special Effects Control

The special effects control lets you create slide shows with transitional effects between images. You add the required images to a play list in a base directory, are then ready to play the list.

Transition directions and effects offer a decent range of choices :
SettingDirectionSettingEffect
0Random0Random
1All1Wipe
2Left2Curtains
3Right3Mosaic
4Up4Blur
5Down5Shapes
6In6Blinds
7Out
This is so easy it's almost sinful :

'Set base directory
FX1.BaseDir = "c:\Images"

'Add image to playlist
FX1.AddImage ("d:\newlogo.gif")
FX1.AddImage ("c:\oldlogo.gif")

'the -1 parameter will play the entire playlist
FX1.Play -1

'Specify the direction of the effect for the specified image:
FX1.Direction[0] = 5 ' Down

' Specify the type of effect for the specified image:
FX1.Effect[0] = 0 ' Random

To enable users to create, edit and save image playlists you just need to invoke the WorkShop method.

'Display Special Effects workshop
FX1.WorkShop

You can also invoke the workshop during runtime to make it easy to edit your playlist. To do this right click on the control and select Workshop. Simple.

This control is never going to replace PowerPoint (or use as much memory!) but as a way to provide some pretty reasonable slide shows within your application at minimum pain to you, it works very well.

Plug-in Control

This control got my attention - you can add support for hosting Adobe Photoshop PlugIns, giving your applications access to thousands of weird and cool image filters like these. Now, I'm no image guru, but this seems a great way to (to use a good Microsoft word) leverage a huge array of existing technology within your own app. And the code isn't at all difficult to master.

You keep all of your PlugIns (file extension of .8BF) in the same directory on your system, and the first step is to set the Directory property to the directory containing your PlugIns.

'set the PlugIn directory
PlugIn.Directory = c:\myplugins

Then it's simply a matter of selecting a PlugIn and processing the image - typically with just a few lines of code:

 'get image from imageman control
hDIB = ImageMan1.hDIB
    
 'invoke plug-in
PlugIn1.InvokePlugIn "myplugin.8bf", hDIB

'or select a plugin from the selection dialog before invoking
Filename = PlugIn1.SelectPlugIns
If Filename <> "" Then
	PlugIn1.InvokePlugIn Filename, hDIB
End If
    
'put the processed image back in the ImageMan control and refresh
'to draw the new image
ImageMan1.hDIB = hDIB
ImageMan1.Refresh
You can find out information about the available PlugIns with three properties:
PlugIn1.Category   'Indicates the type of transformation the PlugIn performs
PlugIn1.Filename   'Returns the filename of the specified PlugIn
PlugIn1.Title      'Returns the title of the specified PlugIn

This has all sorts of potential.

Summing Up

As you can see from the above code examples, ImageMan is quite simple to use, so you won't need to spend days reading help files to achieve results. There's also plenty of sample code in the online help and the user manual, helping you to have your applications doing cool looking things to images in no time at all.

The basic controls are all well constructed and easy to use, and the Plug In control really extends the value of the the suite enormously.

ImageMan ActiveX Suite is $A839 and is available from GUI Computing.



Written by: Ian Rodda
February '99

Image of Arrow linked to Next Article
Image of Line Break
[HOME] [TABLE OF CONTENTS] [SEARCH]