472,142 Members | 1,273 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,142 software developers and data experts.

Graphics: Get Dimensions of a frame in a multi frame tiff

I can seem to get the dimensions of a frame in a multiframe tiff.

After selecting activeframe, the Width/Height is still really much larger
than the page's actual dimensions.

When I split a TIFF to several PNG files this causes a problem, becuase the
resulting image is (the page to the far left and a lot of black space
surrounding it and a filesize that is larger than needed.

Any ideas?

Any way to get the dimensions of this page/frame?

Thanks,

Shane
Nov 21 '05 #1
5 5787
Take a look at the application that accompanies my article on how to add
pages to a multi-frame TIFF.

It's in the GDI+ FAQ. See the DoOpen method.

Code is in C# and VB.

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

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.

"Shane Story" <sh**************@dv-corp.com> wrote in message
news:e9**************@TK2MSFTNGP10.phx.gbl...
I can seem to get the dimensions of a frame in a multiframe tiff.

After selecting activeframe, the Width/Height is still really much larger
than the page's actual dimensions.

When I split a TIFF to several PNG files this causes a problem, becuase
the resulting image is (the page to the far left and a lot of black space
surrounding it and a filesize that is larger than needed.

Any ideas?

Any way to get the dimensions of this page/frame?

Thanks,

Shane

Nov 21 '05 #2
Actually, I did Bob, and with some success.

The problem is that, I seem to be able to take a TIFF (multi) and using your
encoding params, get it to single TIFF's with no problem.

The problem is getting it to the right kind of TIFF for our legacy VB6 app
to be able to display it, using LEAD tools 12.

Apparently I am doing something wrong, that it won't load it using the LEAD
control.

Are there other encoder params that I should consider? Where do we find
such things?

Also, while I am asking, is there a way to get the dimensions of a frame? H
x W? I know that in one of the things I tried, I was getting PNG's
proportionally correct, except with lots of black space to the right and
bottom of the image...this because I was trying to drawimage onto a new
bitmap that I was dimensioning using the Height and Width properties of the
Bitmap which I used to load the TIFF file.

I will take a look again at the methods you have, but if you can point me to
any encoder stuff that I might need to know about tiffs and pings, then I
would appreciate it.

Thanks,

Shane

"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Take a look at the application that accompanies my article on how to add
pages to a multi-frame TIFF.

It's in the GDI+ FAQ. See the DoOpen method.

Code is in C# and VB.

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

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.

"Shane Story" <sh**************@dv-corp.com> wrote in message
news:e9**************@TK2MSFTNGP10.phx.gbl...
I can seem to get the dimensions of a frame in a multiframe tiff.

After selecting activeframe, the Width/Height is still really much larger
than the page's actual dimensions.

When I split a TIFF to several PNG files this causes a problem, becuase
the resulting image is (the page to the far left and a lot of black space
surrounding it and a filesize that is larger than needed.

Any ideas?

Any way to get the dimensions of this page/frame?

Thanks,

Shane


Nov 21 '05 #3
Ok, we got the right parameter. For anyone using LEAD12 in VB6 to read
single TIFF files, that were split form a multiframe TIFF using .NET, the
following code worked for us:

We got much of it from Bob Powell's site, but had to add the CCITT4 encoder
param for LEAD Tools 12 to read it.

Private Sub SplitMultiTiffToSingleTiffs()
Try
Const strFilePath As String = "c:\Scratch\testfax.TIFF"
'Select the image encoder
Dim enc As Encoder = Encoder.SaveFlag
Dim info As ImageCodecInfo = Nothing
Dim ice As ImageCodecInfo

For Each ice In ImageCodecInfo.GetImageEncoders()
If ice.MimeType = "image/tiff" Then
info = ice
End If
Next ice

Dim MyEncorderParam As EncoderParameter = New
EncoderParameter(Encoder.Compression, CLng _
(EncoderValue.CompressionCCITT4))
Dim encParams As EncoderParameters = New EncoderParameters(1)
encParams.Param(0) = MyEncorderParam

'load the file
Dim multi As Image = Image.FromFile(strFilePath)

'if we have more than one page
If multi.GetFrameCount(FrameDimension.Page) > 1 Then
Dim i As Integer
' 'loop through each page
For i = 0 To (multi.GetFrameCount(FrameDimension.Page)) - 1
'get the current page in the TIFF
multi.SelectActiveFrame(FrameDimension.Page, i)
multi.Save(String.Format("c:\scratch\Page{0}.tiff" , i),
info, encParams)
Next i
End If
multi.Dispose()
Catch ex As Exception
MsgBox("Exception->: " & ex.Message, MsgBoxStyle.Information)
End Try
End Sub

"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Take a look at the application that accompanies my article on how to add
pages to a multi-frame TIFF.

It's in the GDI+ FAQ. See the DoOpen method.

Code is in C# and VB.

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

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.

"Shane Story" <sh**************@dv-corp.com> wrote in message
news:e9**************@TK2MSFTNGP10.phx.gbl...
I can seem to get the dimensions of a frame in a multiframe tiff.

After selecting activeframe, the Width/Height is still really much larger
than the page's actual dimensions.

When I split a TIFF to several PNG files this causes a problem, becuase
the resulting image is (the page to the far left and a lot of black space
surrounding it and a filesize that is larger than needed.

Any ideas?

Any way to get the dimensions of this page/frame?

Thanks,

Shane


Nov 21 '05 #4
Ahh, them third party tools really throw a spanner in the works sometimes.

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

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.

"Shane Story" <sh**************@dv-corp.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Ok, we got the right parameter. For anyone using LEAD12 in VB6 to read
single TIFF files, that were split form a multiframe TIFF using .NET, the
following code worked for us:

We got much of it from Bob Powell's site, but had to add the CCITT4
encoder param for LEAD Tools 12 to read it.

Private Sub SplitMultiTiffToSingleTiffs()
Try
Const strFilePath As String = "c:\Scratch\testfax.TIFF"
'Select the image encoder
Dim enc As Encoder = Encoder.SaveFlag
Dim info As ImageCodecInfo = Nothing
Dim ice As ImageCodecInfo

For Each ice In ImageCodecInfo.GetImageEncoders()
If ice.MimeType = "image/tiff" Then
info = ice
End If
Next ice

Dim MyEncorderParam As EncoderParameter = New
EncoderParameter(Encoder.Compression, CLng _
(EncoderValue.CompressionCCITT4))
Dim encParams As EncoderParameters = New EncoderParameters(1)
encParams.Param(0) = MyEncorderParam

'load the file
Dim multi As Image = Image.FromFile(strFilePath)

'if we have more than one page
If multi.GetFrameCount(FrameDimension.Page) > 1 Then
Dim i As Integer
' 'loop through each page
For i = 0 To (multi.GetFrameCount(FrameDimension.Page)) - 1
'get the current page in the TIFF
multi.SelectActiveFrame(FrameDimension.Page, i)
multi.Save(String.Format("c:\scratch\Page{0}.tiff" , i),
info, encParams)
Next i
End If
multi.Dispose()
Catch ex As Exception
MsgBox("Exception->: " & ex.Message, MsgBoxStyle.Information)
End Try
End Sub

"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Take a look at the application that accompanies my article on how to add
pages to a multi-frame TIFF.

It's in the GDI+ FAQ. See the DoOpen method.

Code is in C# and VB.

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

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.

"Shane Story" <sh**************@dv-corp.com> wrote in message
news:e9**************@TK2MSFTNGP10.phx.gbl...
I can seem to get the dimensions of a frame in a multiframe tiff.

After selecting activeframe, the Width/Height is still really much
larger than the page's actual dimensions.

When I split a TIFF to several PNG files this causes a problem, becuase
the resulting image is (the page to the far left and a lot of black
space surrounding it and a filesize that is larger than needed.

Any ideas?

Any way to get the dimensions of this page/frame?

Thanks,

Shane



Nov 21 '05 #5
Yes, but that's what I'm stuck with until the rewrite. ;)

Thanks Bob!

Thanks for your site--and all the GDI+ articles you have written.

Shane
"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:eK*************@TK2MSFTNGP14.phx.gbl...
Ahh, them third party tools really throw a spanner in the works sometimes.

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

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.

"Shane Story" <sh**************@dv-corp.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Ok, we got the right parameter. For anyone using LEAD12 in VB6 to read
single TIFF files, that were split form a multiframe TIFF using .NET, the
following code worked for us:

We got much of it from Bob Powell's site, but had to add the CCITT4
encoder param for LEAD Tools 12 to read it.

Private Sub SplitMultiTiffToSingleTiffs()
Try
Const strFilePath As String = "c:\Scratch\testfax.TIFF"
'Select the image encoder
Dim enc As Encoder = Encoder.SaveFlag
Dim info As ImageCodecInfo = Nothing
Dim ice As ImageCodecInfo

For Each ice In ImageCodecInfo.GetImageEncoders()
If ice.MimeType = "image/tiff" Then
info = ice
End If
Next ice

Dim MyEncorderParam As EncoderParameter = New
EncoderParameter(Encoder.Compression, CLng _
(EncoderValue.CompressionCCITT4))
Dim encParams As EncoderParameters = New EncoderParameters(1)
encParams.Param(0) = MyEncorderParam

'load the file
Dim multi As Image = Image.FromFile(strFilePath)

'if we have more than one page
If multi.GetFrameCount(FrameDimension.Page) > 1 Then
Dim i As Integer
' 'loop through each page
For i = 0 To (multi.GetFrameCount(FrameDimension.Page)) -
1
'get the current page in the TIFF
multi.SelectActiveFrame(FrameDimension.Page, i)
multi.Save(String.Format("c:\scratch\Page{0}.tiff" ,
i), info, encParams)
Next i
End If
multi.Dispose()
Catch ex As Exception
MsgBox("Exception->: " & ex.Message, MsgBoxStyle.Information)
End Try
End Sub

"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Take a look at the application that accompanies my article on how to add
pages to a multi-frame TIFF.

It's in the GDI+ FAQ. See the DoOpen method.

Code is in C# and VB.

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

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.

"Shane Story" <sh**************@dv-corp.com> wrote in message
news:e9**************@TK2MSFTNGP10.phx.gbl...
I can seem to get the dimensions of a frame in a multiframe tiff.

After selecting activeframe, the Width/Height is still really much
larger than the page's actual dimensions.

When I split a TIFF to several PNG files this causes a problem, becuase
the resulting image is (the page to the far left and a lot of black
space surrounding it and a filesize that is larger than needed.

Any ideas?

Any way to get the dimensions of this page/frame?

Thanks,

Shane



Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Ruby Tuesday | last post: by
2 posts views Thread by Adam Teale | last post: by
5 posts views Thread by Andy | last post: by
reply views Thread by =?Utf-8?B?VmVuZWRpY3Q=?= | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.