by eDayNova » Thu Aug 24, 2006 4:13 pm
Hi, i've fixed all my problems contacting the Black Ice support directly. It's actually been like 2-3 weeks now. I needed to create a multipage tiff out of many single page and multipage tiffs. Then, compress it as much as possible without quality loss. This code takes all the tiffs in a directory and adds them to a single multipage tiff file ready to be compressed with zip compression (you could compress the multipage tiff by changing the 201 parameter to something like 204 or 209, but the following zip compression will be less effective). Here's what I did:
VB.NET 2005 Code:
[code]
Dim FolderContainingTIFFs As String = "C:\TIFF" ' Directory containing TIFFs
Dim OutputTIFFfile As String = "C:\Output.tif" ' Output TIFF file
Dim hDIB As Integer 'DIB that will contain the page loaded from the tiff file
Dim hDIB2 As Integer 'DIB that will contain Halftoned image
Dim PageCount As Integer 'Number of pages in tiff file
Dim CurrentPage As Short 'Current page in tiff file
Try 'Error Handling
Dim pattern As String = "*.tif" ' Type of files to loop through
Dim dir_info As New System.IO.DirectoryInfo(FolderContainingTIFFs) 'Directory to look into
Dim file_infos() As System.IO.FileInfo 'Will contain info about the files found
file_infos = dir_info.GetFiles(pattern) 'Get all the files matching the pattern
For Each file_info As System.IO.FileInfo In file_infos 'Loop through files
PageCount = BIDIB.GetNumberOfImagesInFile(file_info.FullName, 9998) 'Get nuber of pages in tiff file
If PageCount = 9998 Then MsgBox("Error? Pagecount returned 9998")
For CurrentPage = 0 To PageCount - 1 'Loop through pages in TIFF file
hDIB = BIDIB.LoadImageIntoDIB(file_info.FullName, CurrentPage) 'Load the page into DIB
hDIB2 = BIDIB.Halftone(hDIB, 1, -20) 'Halftone the DIB
If CurrentPage = PageCount - 1 Then 'Last page of tiff file
Kill(file_info.FullName) 'Delete the tiff
End If
If hDIB2 <> 0 Then ' Halftone was OK
BITiff.SaveDIBInTiffFormat _
(OutputTIFFfile, hDIB2, 201, False) 'Change 201 to 204 or 209 for compression
Else ' Halftone failed, use DIB that wasen't halftoned
BITiff.SaveDIBInTiffFormat(OutputTIFFfile, hDIB, 201, False)'Change 201 to 204 or 209 for compression
End If
BIDIB.DropDIB(hDIB) 'Release DIB
BIDIB.DropDIB(hDIB2) 'Release DIB
Next CurrentPage
Next file_info
Catch err As System.Exception
MsgBox("Error" & err.Message)
End Try
[/code]
I would then use other code to zip this very big file into something like 12kb/page with excellent quality.
eDayNova