DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Fri, 17 Aug 2007 14:36:36 -0500,    posted on: microsoft.public.dotnet.framework.drawing        back       

Thread Index
  1    SR
          2    SR
          3    Bob Powell [MVP]


Combining Single Page TIFFs into 1 multipage TIFF   
I have a directory full of single page TIFFs.  I would like to write a 
program that will combine all of them into 1 multipage TIFF.  Here is my 
code.  I am getting a "Parameter not valid" error message when performing 
the SaveAdd methods.  Any help would be appreciated!

            oFiles = oDir.GetFiles("*.tif")
            If oFiles.Length > 0 Then
                miFileCnt += 1
                sSplit = zsDirectory.Split("\")
                sOutTiff = txtOutpath.Text & "\" & sSplit(sSplit.Length - 1) 
& "_SDISM_" & miFileCnt.ToString.PadLeft(5, "0") & ".tif"
                oBmp = Nothing

                For Each oFile As FileInfo In oFiles
                    laCurrentFile.Text = oFile.Name
                    Application.DoEvents()

                    oCurrImage = Image.FromFile(oFile.FullName)
                    iFrameCnt = 
oCurrImage.GetFrameCount(FrameDimension.Page)

                    If oBmp Is Nothing Then
                        oBmp = New Bitmap(oCurrImage)
                        oBmp.Save(sOutTiff, moImageInfo, moParams)

                        iStart = 1
                    Else
                        iStart = 0
                    End If

                    oMS = New MemoryStream

                    moParams.Param(0) = New EncoderParameter(moEncoder, 
CLng(EncoderValue.FrameDimensionPage))
                    For iCnt As Integer = iStart To iFrameCnt - 1
                        oCurrImage.SelectActiveFrame(FrameDimension.Page, 
iCnt)
                        oCurrImage.Save(oMS, ImageFormat.Bmp)

                        oNewImage = Image.FromStream(oMS)

                        oBmp.SaveAdd(oNewImage, moParams)

                        oMS.SetLength(0)
                    Next

                    oCurrImage.Dispose()
                    oBmp.Dispose()
                Next

                oMS.Dispose()
                oNewImage.Dispose()
            End If

TIA,
SR
Date:Fri, 17 Aug 2007 14:36:36 -0500   Author:  

Re: Combining Single Page TIFFs into 1 multipage TIFF   
I figured it out...

oFiles = oDir.GetFiles("*.tif")

If oFiles.Length > 0 Then

miFileCnt += 1

sSplit = zsDirectory.Split("\")

sOutTiff = txtOutpath.Text & "\" & sSplit(sSplit.Length - 2) & "_SDISM_" & 
miFileCnt.ToString.PadLeft(5, "0") & ".tif"

oNewImage = Nothing

For Each oFile As FileInfo In oFiles

laCurrentFile.Text = oFile.Name

Application.DoEvents()


If oNewImage Is Nothing Then

oNewImage = Image.FromFile(oFile.FullName)

oNewImage.Save(sOutTiff, moImageInfo, encParamsMulti)

iStart = 1

Else

oCurrImage = Image.FromFile(oFile.FullName)

oNewImage.SaveAdd(oCurrImage, encParamsAdd)

iStart = 0

End If

If oCurrImage IsNot Nothing Then

oCurrImage.Dispose()

End If

Next

oNewImage.SaveAdd(encParamsFlush)

oNewImage.Dispose()

End If



"SR"  wrote in message 
news:uRF5VYQ4HHA.5724@TK2MSFTNGP05.phx.gbl...

>I have a directory full of single page TIFFs.  I would like to write a 
>program that will combine all of them into 1 multipage TIFF.  Here is my 
>code.  I am getting a "Parameter not valid" error message when performing 
>the SaveAdd methods.  Any help would be appreciated!
>
>            oFiles = oDir.GetFiles("*.tif")
>            If oFiles.Length > 0 Then
>                miFileCnt += 1
>                sSplit = zsDirectory.Split("\")
>                sOutTiff = txtOutpath.Text & "\" & sSplit(sSplit.Length - 
> 1) & "_SDISM_" & miFileCnt.ToString.PadLeft(5, "0") & ".tif"
>                oBmp = Nothing
>
>                For Each oFile As FileInfo In oFiles
>                    laCurrentFile.Text = oFile.Name
>                    Application.DoEvents()
>
>                    oCurrImage = Image.FromFile(oFile.FullName)
>                    iFrameCnt = 
> oCurrImage.GetFrameCount(FrameDimension.Page)
>
>                    If oBmp Is Nothing Then
>                        oBmp = New Bitmap(oCurrImage)
>                        oBmp.Save(sOutTiff, moImageInfo, moParams)
>
>                        iStart = 1
>                    Else
>                        iStart = 0
>                    End If
>
>                    oMS = New MemoryStream
>
>                    moParams.Param(0) = New EncoderParameter(moEncoder, 
> CLng(EncoderValue.FrameDimensionPage))
>                    For iCnt As Integer = iStart To iFrameCnt - 1
>                        oCurrImage.SelectActiveFrame(FrameDimension.Page, 
> iCnt)
>                        oCurrImage.Save(oMS, ImageFormat.Bmp)
>
>                        oNewImage = Image.FromStream(oMS)
>
>                        oBmp.SaveAdd(oNewImage, moParams)
>
>                        oMS.SetLength(0)
>                    Next
>
>                    oCurrImage.Dispose()
>                    oBmp.Dispose()
>                Next
>
>                oMS.Dispose()
>                oNewImage.Dispose()
>            End If
>
> TIA,
> SR
> 
Date:Fri, 17 Aug 2007 16:24:48 -0500   Author:  

Re: Combining Single Page TIFFs into 1 multipage TIFF   
You may also want to see the examples in the GDI+ FAQ.

-- 
-- 
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.


"SR"  wrote in message 
news:uRF5VYQ4HHA.5724@TK2MSFTNGP05.phx.gbl...

>I have a directory full of single page TIFFs.  I would like to write a 
>program that will combine all of them into 1 multipage TIFF.  Here is my 
>code.  I am getting a "Parameter not valid" error message when performing 
>the SaveAdd methods.  Any help would be appreciated!
>
>            oFiles = oDir.GetFiles("*.tif")
>            If oFiles.Length > 0 Then
>                miFileCnt += 1
>                sSplit = zsDirectory.Split("\")
>                sOutTiff = txtOutpath.Text & "\" & sSplit(sSplit.Length - 
> 1) & "_SDISM_" & miFileCnt.ToString.PadLeft(5, "0") & ".tif"
>                oBmp = Nothing
>
>                For Each oFile As FileInfo In oFiles
>                    laCurrentFile.Text = oFile.Name
>                    Application.DoEvents()
>
>                    oCurrImage = Image.FromFile(oFile.FullName)
>                    iFrameCnt = 
> oCurrImage.GetFrameCount(FrameDimension.Page)
>
>                    If oBmp Is Nothing Then
>                        oBmp = New Bitmap(oCurrImage)
>                        oBmp.Save(sOutTiff, moImageInfo, moParams)
>
>                        iStart = 1
>                    Else
>                        iStart = 0
>                    End If
>
>                    oMS = New MemoryStream
>
>                    moParams.Param(0) = New EncoderParameter(moEncoder, 
> CLng(EncoderValue.FrameDimensionPage))
>                    For iCnt As Integer = iStart To iFrameCnt - 1
>                        oCurrImage.SelectActiveFrame(FrameDimension.Page, 
> iCnt)
>                        oCurrImage.Save(oMS, ImageFormat.Bmp)
>
>                        oNewImage = Image.FromStream(oMS)
>
>                        oBmp.SaveAdd(oNewImage, moParams)
>
>                        oMS.SetLength(0)
>                    Next
>
>                    oCurrImage.Dispose()
>                    oBmp.Dispose()
>                Next
>
>                oMS.Dispose()
>                oNewImage.Dispose()
>            End If
>
> TIA,
> SR
> 
Date:Sat, 18 Aug 2007 13:43:32 +0200   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us