views:

233

answers:

1

I'm trying to use my existing application to open tiff files for clients and staff in order to print or view the reports that we have scanned into our server. Unfortunately I have been unable to find a free, preferably open source library or wrapper for a library that will work in VB.NET running through Visual Studio 2005.

Does anyone know of any open source/free implementations of this that I could adopt in my application?

A: 

You can use the FreeImage library, downloadable from FreeImage.net.

To link it, add a reference to your project to the DLL contained in:

FreeImage/Wrapper/FreeImage.NET/CS/Bin

Once it is linked, import FreeImageAPI into your class.

then, declare your variables:

Dim pageCount As Integer
Dim imagePage As FreeImageAPI.FIBITMAP
Dim tiffImage As FreeImageAPI.FIMULTIBITMAP

tiffImage = FreeImageAPI.FreeImage.OpenMultiBitmapEx(ImagePath)
pageCount = FreeImage.GetPageCount(tiffImage)
imagePage = FreeImage.LockPage(tiffImage, 0)
imgMain.Image = FreeImage.GetBitmap(scaledImage)
imgMain.Show()

This will return the first page of a multi-page tiff file. To get each page afterwards,

FreeImage.UnlockPage(tiffImage, imagePage, false)
imagePage = FreeImage.LockPage(tiffImage, newPageNum)
Aevum Decessus