简体   繁体   中英

Opening/printing TIFF files in VB.NET Visual Studio 2005

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.

Is there any open source/free implementations of this that I could adopt in my application?

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM