Product and Development Musings

V 8.72 of ImageMan ActiveX & DLL Suites Released

2. June 2010 10:44

V 8.72 of the ImageMan ActiveX and DLL Suites is now available for downloading.  The installations can be downloaded from the My Products page.  Contact if you require assistance downloading the updated files.

This is a maintenance release that fixes the following issues:

  • Tif DIL round up error on resolution
  • IncreaseTo method changes X & Y resolution of image
  • Cant write multi-page PDFs to memory using ImgxWriteMem*
  • Exception when loading images larger than memory
  • Licensing change to eliminate calls to display trial dialog from IsLicenseValid
  • Check for license file in the Common Files\DTI\Licenses directory
  • MousePointer property now updates cursor when its set

Efficiently Convert PDF to Multipage TIF

24. May 2010 08:28

One of our ImageMan.Net customers recently asked us to help him convert a multipage PDF file to a single multipage TIF.  His initial attempts to do so were causing memory issues due the resolution and color depth of the source PDF as well as the approach he was taking. 

Inefficient Approach

The less optimized, but convenient, way to solve this problem would be to load the PDF file into an ImageMan.Net image collection (as a standalone ImageCollection object or part of the Viewer's Images property).  Then you can simply save that collection using one of the many overloaded Save methods.  ImageMan.Net handles appending each image in the collection to a single file.

For example, here's one way to simply save the entire collection to a file called image.tif:




myImageCollection.Save "image.tif"

Or if you are using a Viewer, then you can save the collection using the Viewer's Save method which will loop through the Images property and create a single file called image.tif:




Viewer1.Save "image.tif"

Additionally, these Save methods have overloads that will allow you to specify the start page, the total number of pages and the image encoder to use.

The problem with this approach is that the larger your ImageCollection, the larger the amount of memory your program will use while running.  Our client was running out memory while trying to process the PDF.

Efficient Approach

The most efficient and less memory intensive (and lowest level) way to solve this problem is to make use of the PdfDecoder class to loop through the pages of the source PDF.  With the PdfDecoder you can also modify some of the source PDF's image details including the resolution and color depth.  Then, for each page in the source image, you can create and append to a single output image file using the TifEncoder's Save method.

At the end of this article, I'll provide links to working sample apps that will contain the code to perform the PDF to TIF conversion.  This sample app will cover all of the details on how to properly work with streams to create the decoder and encoder instances.  I'll cover some of the highlights below:

To loop through the pages of the source PDF, you'll need an instance of the PdfDecoder class which will allow you to retrieve the number of pages (using the Pages property) and set the current page (using the Page property).  Then, you can use an instance of the TifEncoder class to append each page to an output file using the Save method:


int totalPageCount = pdfDecoder.Pages;
int currentPageNumber = 0;
while (totalPageCount-- > 0)
    pdfDecoder.Page = currentPageNumber++;
    ImImage tempImage = pdfDecoder.Load(null);
    tifStream.Seek(0, SeekOrigin.Begin);
    tifEncoder.Save(tifStream, tempImage, null);


Dim totalPageCount As Integer = pdfDecoder.Pages
Dim currentPageNumber As Integer = 0
Do While totalPageCount > 0
    pdfDecoder.Page = currentPageNumber
    currentPageNumber += 1  
    Dim tempImage As ImImage = pdfDecoder.Load(Nothing)
    tifStream.Seek(0, SeekOrigin.Begin)
    tifEncoder.Save(tifStream, tempImage, Nothing)
    totalPageCount = totalPageCount - 1

The decoder and encoder classes allow you to perform some very low level operations on images that will help your image processing code become much more efficient.  For more details on these ImageMan.Net classes, please refer to the documentation. 

The following sample apps are available online:

ImageMan.Net Twain Now Compatible with .NET 4.0 and Visual Studio 2010

20. May 2010 06:35

Good news, early adopters! ImageMan.Net Twain 2.80, the latest release of our advanced Twain component, fully supports the .NET framework 4.0 and Visual Studio 2010.   This component is now available for downloading from the My Products page.

Separate Assemblies

ImageMan.Net Twain 2.80 ships with two separate DLL's- one for the .NET framework 2.0 and one for the .NET framework 4.0.  You'll find the DLL's in separate folders in the installation path.

Note: You can tell the difference between the similarly named DLLs by right clicking on the file and viewing the Properties dialog.  In the Details tab (for Windows 7) or the Version tab (for XP), view the File description field.  The 2.0 assembly will read "ImageMan.Net Twain for .Net 2.0".  Likewise, the 4.0 assembly will be labeled "ImageMan.Net Twain  for .Net 4.0". 


Sample Applications and Code

You'll notice new client side and ASP.NET samples (and sample code) that are fully compatible with Visual Studio 2010.  If you have multiple versions of Visual Studio on your system, you can select which samples to install during the installation process. 

Note: The Start menu links to the demo apps will always target the earliest version of the .NET framework you have installed on your computer.


Help Format

To better integrate with Visual Studio 2010, we've updated our documentation to the Microsoft Help System format which is available to you when you install Visual Studio 2010.  Previous versions still retain their properly formatted help documentation.


ImageMan.Net and Visual Studio 2010

15. April 2010 08:26

With the release of Visual Studio 2010, some of you are probably eager to start developing new applications on (or porting existing applications to) the .NET Framework 4 and the new IDE.  You can use ImageMan.Net components in Visual Studio 2010 projects that target .Net Framework 4 but you'll need to be aware of one issue. 

According to Microsoft:

The .NET Framework 4 works side-by-side with older Framework versions.  Applications that are based on older versions of the Framework will continue to run on the version targeted by default.

However, the above statement does not hold true when the older versions involve mixed mode assemblies.  ImageMan.Net was developed on .NET Framework 2 and one of the components, DTI.ImageMan.Codecs.dll, is a mixed-mode assembly which does not get properly loaded into the .NET Framework 4 runtime without additional configuration.

Until the ImageMan.Net source is built in .NET Framework 4, you are going to have to apply a slight workaround to get the components to work properly in a .NET Framework 4 assembly.  Here's an example of the type of exception you can expect to see when you do not apply this workaround:


To cause this exception, I created a simple Windows application in Visual Studio 2010.  I dropped ImageMan.Net ThumbnailViewer, Viewer, Annotation and AnnotationToolSrip controls onto the form's design surface.  Then I built and ran the application which displayed the exception dialog above.

To fix this problem, you'll simply need to add the useLegacyV2RuntimeActivationPolicy attribute to the application's config file (app.config) like so:

    <startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0"/>

Setting this attribute to true will allow a pre-.NET Framework 4 mixed-mode assembly to load in a .NET Framework 4 process.  With this workaround in place, you'll be able to integrate the ImageMan.Net components in your Visual Studio/.NET Framework 4 projects.  We will soon release .NET Framework 4 targeted ImageMan.Net assemblies which will not require you to modify your app.config files.

Persisting Annotations: Saving and Branding

19. February 2010 11:43

We recently learned how the Viewer control manages annotation marks during runtime.  Now let's continue our discussion in our series of articles on annotation support in ImageMan.Net Document Edition by highlighting how to persist annotated images after you are done working with them. 

Saving Annotations

The annotation information on an image can be saved in TIFF, JPG or PNG formats. This will happen automatically when an image in the Viewer control has associated annotation information. The annotation information is stored as a separate layer of the image.

So, if you want to share or continue working with an annotated image save it as a TIFF, JPG or PNG file.  If you want to load an image with the annotation information in the proprietary ImageMan.Net format in another TIFF viewer the annotation information will not be displayed.  (In an upcoming post, we will learn how to create annotated images with a common set of annotations that can be shared with other TIFF viewers.)

We'll now add the ability to save our annotations in the sample application we built in the last few posts (Visual Studio 2008 source code: C# source, VB.Net source).

  • Open IMAnnotate1.sln for C# (or IMAnnotate1VB.sln fo VB.Net) in Visual Studio 2005 or 2008 (which ever you used last time)
  • Open Form1 class in design view
  • Drag and drop a SaveFileDialog control onto the form:


  • Add a new menu item under the File menu item and call it Save.:


  • Automatically add events to this submenu item by double-clicking to let Visual Studio autogenerate the event method.
  • Now, add this code to open the Save File dialog:


private void saveToolStripMenuItem_Click(object sender, EventArgs e)
    saveFileDialog1.Filter = RegisteredEncoders.GetFilterString();
    if (saveFileDialog1.ShowDialog() == DialogResult.OK)
        annotation1.SaveInWangFormat = false;


Private Sub SaveToolStripMenuItem_Click( _
    ByVal sender As System.Object, ByVal e As System.EventArgs) _
    Handles SaveToolStripMenuItem.Click
    SaveFileDialog1.Filter = RegisteredEncoders.GetFilterString()
    If SaveFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
        Annotation1.SaveInWangFormat = False
    End If
End Sub

First we generate a list of available file types to allow the user to use and set that as the filter for the SaveFileDialog control.  Then, if the user selected a valid filename and location, we save the image using the given filename.  Notice the SaveInWangFormat property of the Annotation object? Let's hold off on that until the next topic.

  • So now run the application (by clicking F5, for instance)
  • Add a few annotation marks onto the default (white) image
  • Save that image to a known location as either a TIFF, JPG or PNG file type
  • Close the application
  • Run it again
  • Open the previously saved image
  • You should now still be able to move, edit and otherwise manipulate the previous marks

Note: If you open the file in the Windows Picture and Fax Viewer, for instance, you will not see the annotated marks.

Branding Annotations

If you need to permanently add the annotation information to the image you can use the annotation objects Brand() method to burn the annotations onto the image. Once you do this, however, you can no longer manipulate the annotations as before.

Branding is done at the image's color depth. So if you have color marks and a black and white image. Either increase the color depth of the underlying image, or understand that the color branded marks will appear differently.

  • Add another menu item on the toolstrip (under the File menu item) and call it Brand


  • Create the code behind and add the following code:


private void brandToolStripMenuItem_Click(object sender, EventArgs e)
    // Brand the current image
    // Clear all existing marks
    // Refresh the viewer


Private Sub BrandToolStripMenuItem_Click( _
    ByVal sender As System.Object, ByVal e As System.EventArgs) _
    Handles BrandToolStripMenuItem.Click
    ' Brand the current image
    ' Clear all existing marks
    ' Refresh the viewer
End Sub
  • Run the application
  • Add a few annotation marks onto the default (white) image
  • Brand the image using the Brand menu option
  • Now try to manipulate the current marks and notice that you can't (they aren't marks now; they are part of the image)
  • Add some new marks
  • Save that image to a known location as either a TIFF, JPG or PNG file type
  • Close the application
  • Run it again
  • Open the previously saved image
  • You should now still be able to move, edit and otherwise manipulate the new marks but the branded marks are not editable any longer

Save this project since we will continue to build on it next time for a discussion on persisting common annotations that are compatible with other TIFF viewer and (many) annotation editors.

Persisting Annotations: The Viewer Control

14. January 2010 10:50

In the last series, we learned how to work with Annotations in ImageMan.Net Document Edition. Now, we will learn more about one of the ways to persist your annotated images.

The ImageMan.Net Viewer control automatically manages the annotations for each image in it's associated Images collection.  So, when you load an image in the Viewer and add annotations to it, then add a second image to the Viewer, you can still go back to the first image and manipulate the annotation marks. 

Let's try this out by adding some file and paging features to the example application that we started in the previous article.  (If you didn't create this solution, then I suggest you quickly follow the steps as indicated in the previous blog post so we can be in synch.)

  1. Open IMAnnotate1.sln in Visual Studio 2005 or 2008 (which ever you used last time)
  2. Open the Form1 class in design view
  3. Drag and drop a ImageMan.Net OpenImageDialog control onto the design surface
  4. Add the following menu items:
    - File
    - Image


  1. Under the File men item, add the following menu items:
    - Add...  A2-2
  2. Under the Image menu item, add the following menu items:
    - First
    - Next
    - Previous
    - Last A2-3
  3. Automatically add events to each submenu item by double-clicking each one.  Let Visual Studio autogenerate the event method.
  4. Now, in code view, let's add some code that will handle adding images to the Viewer control's Images collection:


private void addToolStripMenuItem_Click(object sender, EventArgs e)
    if (openImageDialog1.ShowDialog() == DialogResult.OK)

[Visual Basic]

Private Sub AddToolStripMenuItem_Click( _
    ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles AddToolStripMenuItem.Click
    If OpenImageDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
    End If
End Sub
  1. Add this code that will handle navigating the image collection:


private void firstToolStripMenuItem_Click(object sender, EventArgs e)
private void nextToolStripMenuItem_Click(object sender, EventArgs e)
private void previousToolStripMenuItem_Click(object sender, EventArgs e)
private void lastToolStripMenuItem_Click(object sender, EventArgs e)

[Visual Basic]

Private Sub FirstToolStripMenuItem_Click( _
    ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles FirstToolStripMenuItem.Click
End Sub
Private Sub NextToolStripMenuItem_Click( _
    ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles NextToolStripMenuItem.Click
End Sub
Private Sub PreviousToolStripMenuItem_Click( _
    ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles PreviousToolStripMenuItem.Click
End Sub
Private Sub LastToolStripMenuItem_Click( _
    ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles LastToolStripMenuItem.Click
End Sub
  1. Run the application and add a few images
  2. Add some annotations
  3. Navigate between the various images

You'll notice the annotations you added will remain intact while navigating between the images.  The annotated marks are able to moved, resized, modified, etc.

Next week, we'll continue on this persistence topic and learn how to save and brand the annotated image.

Annotations in ImageMan.NET Document Edition

5. January 2010 12:08

Today we are going to kick off a series of blog posts highlighting some of the great new features in our latest version of ImageMan: ImageMan.Net Document Edition.  This first post will introduce you to the annotation features you can use to add text and drawings to images or documents. 

The Document Edition includes a rich set of annotation objects including:

    • Rectangle
    • Ellipse
    • Line
    • Polygon
    • Highlight
    • String
    • Freehand Line
    • Bezier Curve
    • Pie Shape
    • Arc
    • Sticky Note
    • Image
    • Redaction
    • Overlay
    • Text Stamp
    • Custom Mark

You can add multiple annotation objects to an image.  Once added, you can modify, move, resize and remove them easily.  We'll discuss persisting, protecting and encrypting annotated images in upcoming blog posts.  We'll also cover implementing annotation support programmatically soon, but for starters, we'll go over the Annotation control, which is the core of annotation support in ImageMan.Net, as well as the Annotation ToolStrip.

Test Driving the Annotation Features

Let's build a simple image viewer with annotation support.  I'm assuming you've already installed at least the trial version of the ImageMan.Net Document Edition.

  1. Start Visual Studio.Net (2005/2008)
  2. Create a new Windows Forms Application project (in C# or VB.Net)
  3. Name it IMAnnotate1
  4. Add the following controls to the design surface of Form1:
    - MenuStrip
  5. Add the following ImageMan.Net controls to the design surface of Form1:
    - Viewer, Annotation, Annotation ToolStrip
  6. In the Properties window, set the following properties for viewer1:
    - Dock: Fill
  7. Set the following properties for annotation1:
    - Viewer: viewer1
    - ToolStrip: annotationToolstrip1
  8. Save your work

Adding the Design Surface

If you run the application we've just created, you'll notice that the Annotation ToolStrip is pre-populated with buttons you can use to easily work with the full set of annotation objects:


Our next step is to add a design surface.  We have two options here: we can add code to go out and retrieve an existing image and load it into the Viewer or we can create a new image.  For ease of use, let's go with the latter approach.

  1. Open Form1 in code view
  2. Add a reference to DTI.ImageMan:


using DTI.ImageMan;

[Visual Basic]

Imports DTI.ImageMan
  1. In the Form1 Constructor (after the InitializeComponent() method), add this code to create the default design surface:


    new ImImage(800, 1100, PixelFormat.Format24bppRgb, Color.White));

[Visual Basic]

    New ImImage(800, 1100, PixelFormat.Format24bppRgb, Color.White))

Working with the Annotation ToolStrip

Now we've got a design surface where we can add and manipulate annotation marks.  Let's add a few marks from the Annotation ToolStrip.

  1. Select the Rectangle button
  2. Left click and drag on the design surface to create a rectangle annotation mark

Notice that when you select an annotation tool on the Annotation ToolStrip, additional formatting tool buttons are dynamically added:


The visible formatting options will change depending on the annotation tool selected. For the Rectangle annotation tool, you can modify the following properties:

  • Fore Color
  • Back Color
  • Translucent
  • Brush
  • Pen Width
  • Corner Radius
  • Filled

Working with the Annotation Marks

Once a mark has been added to an image, you can perform various actions on it.  Marks can be:

  • selected
  • dragged
  • dropped
  • reordered
  • formatted
  • moved
  • resized (for most annotation marks)
  • deleted
  • copied
  • cut
  1. Click on the Select tool on the Annotation ToolStrip:


  1. Select the rectangle mark on the design surface by clicking anywhere inside it
  2. On the ToolStrip, select the Back Color button
  3. Select a color in the Color Dialog and click OK button
  4. On the ToolStrip, select the Pen Width button
  5. Enter a pen width of 3 and click the OK button


Working with the Context Menu

An alternative way to create and format annotation objects is to use the right click context menu. 

  1. Right click on the design surface
  2. Select the Tools menu option
  3. Select the Note annotation tool
  4. Drag a note mark onto the design surface
  5. Type some text in the note mark


If you want to hide the context menu, you just have to set the ShowContextMenu property on the Annotation object to false:


annotation1.ShowContextMenu = false;

[Visual Basic]

annotation1.ShowContextMenu = False

The next article on this topic will cover saving and branding your annotated images.

Drag and Drop with the ImageMan.NET WinForms Controls

22. December 2009 12:11

The ImageMan.NET Windows Forms controls make it easy to implement drag and drop functionality in your own applications.  To showcase this feature, lets extend one of the VS.NET 2008 Thumbnail control samples (TestThumbCol for C# or TestThumbColVb for VB.NET) that ships with ImageMan.NET.  This code will also work in Visual Studio.NET 2005.

We will add the ability for a user to select one or more image files from Windows Explorer and drop them on to the Viewer control.  The images will then be added to the Thumbnail Browser control and one of the images will be opened in the Viewer.

  • Run Visual Studio.NET 2008
  • Open the solution file found under:

For C#:
C:\Program Files\ImageMan.Net V2\Visual Studio 2008 Samples\C#\TestThumbCol\TestThumbCol.sln


C:\Program Files\ImageMan.Net V2\Visual Studio 2008 Samples\VB\TestThumbColVb\TestThumbColVB.sln

  • Open Form1 in design view
  • Select the Viewer control
  • In the Properties window, set AllowDrop to True:


  • Open the Events list for the Viewer control and double click on the DragDrop event to have Visual Studio.NET automatically create the event:


  • Return to the design view and double click on the DragOver event to have Visual Studio.NET automatically generate the event:


  • Staying in code view, let's add some code to the DragDrop event which will add the selected files to the Viewer's image collection.  Because the Thumbnail Browser is synchronized with the Viewer's image collection (in the Form's constructor), the Thumbnail Browser will also be updated.  In the DragDrop event, add the following code:

For C#:

private void thumbNail1_DragDrop(object sender, DragEventArgs e)
    string[] fileNames = (string[])e.Data.GetData(DataFormats.FileDrop);

    // handle each file passed as needed
    foreach (string fileName in fileNames)
        // Open each image and add to collection


Private Sub viewer1_DragDrop(ByVal sender As System.Object, ByVal e _
    As System.Windows.Forms.DragEventArgs) Handles viewer1.DragDrop
    Dim fileNames As String() = _
        DirectCast(e.Data.GetData(DataFormats.FileDrop), String())

    ' handle each file passed as needed
    For Each fileName As String In fileNames
        ' Open each image and add to collection
End Sub
  • To add the appropriate visual feedback to the user interface, update the DragOver event with the code shown below:

For C#:

private void thumbNail1_DragOver(object sender, DragEventArgs e)
    if (e.Data.GetDataPresent(DataFormats.FileDrop))
        e.Effect = DragDropEffects.Copy;
        e.Effect = DragDropEffects.None;


Private Sub viewer1_DragOver(ByVal sender As System.Object, ByVal e _
    As System.Windows.Forms.DragEventArgs) Handles viewer1.DragOver
    If e.Data.GetDataPresent(DataFormats.FileDrop) Then
        e.Effect = DragDropEffects.Copy
        e.Effect = DragDropEffects.None
    End If
End Sub
  • Build the application and give it a test run
  • Open Windows Explorer and navigate to a folder that contains images
  • Select one or more images and drag them on to the Viewer control.  Notice that the cursor will change indicating that you are allowed to drop the files on that control surface.
  • Drop the files on to the Viewer control and notice that the Thumbnail Browser updates to include those files and that one of the files will be displayed in the Viewer:


You can follow the steps outlined below to add similar functionality to the Thumbnail Browser control as well.  This implementation of drag and drop is consistent with the default Windows controls set and makes it easy for you add the user interactions your users have come to expect with desktop applications.

Automatic Debug Logging in FaxMan 4

10. December 2009 05:19

There will be times when you will need to know what's going on behind the scenes with the FaxMan SDK - you've added new features that aren't working quite yet or our technical support staff has requested debug logs to help you troubleshoot issues with sending or receiving faxes.  In an effort to make this as easy as possible, we've introduced automatic debug logging in version 4.6 of our FaxMan SDK.  Developers familiar with our previous versions will no longer have to use the command line "/d" option.

Port specific data is stored in a file for each day and port with the filename in the format Portxx-yyyymmdd.log where xx is the com port number and yyyymmdd is the date.   FaxMan log data is stored in a file in the format, faxman-yyyymmdd.log where yyyymmdd is the date.

These files, by default, are stored for 3 days.  You can change this by modifying the DaysToRetain FaxMan server configuration option (please refer to our documentation on how to modify these settings).  If you want to keep only a single day's worth of logs, for instance, set DaysToRetain equal to 1.

You'll find the logs in the same directory as the FaxMan4.exe file (typically the Windows System32 directory for 32-bit machines).

ImageMan.Net Version 1.73 Available

19. November 2009 04:11

V 1.73 of ImageMan.Net is now available for downloading from the My Products page.

This is a maintenance release that includes the following changes:

  • Memory leak in decoders
  • TIFF LZW compression for 24 bit continous tone images improved
  • TifEncoder may invert passed image data for 1 bit images
  • Scale of thumbnail images is incorrect
Log in