![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi All, I'm am having trouble resizing a multipage TIFF file. The TIFF is 640x480 and I am trying to resize ALL frames to 320x280. If I resize it by creating a new bitmap at the target size and resave, it loses the pages. If I loop through all the pages and resize each page into new bitmap, then recreate the TIFF, I get an Invalid Parameter Used exception. What is confusing is that the code to create a multipaged TIFF from an array of newly drawn images works. It seems to be when I open a multipaged TIFF and try to use copies of the frames as a source for another TIFF where the issue occurs. Dim imageFile As System.IO.StreamReader = New System.IO.StreamReader("my_multipaged_tiff.tiff") Dim tiffImage As System.Drawing.Bitmap = New Bitmap(imageFile.BaseStream) Dim images(tiffImage.GetFrameCount(Imaging.FrameDimens ion.Page) - 1) As Drawing.Bitmap For imageIndex As Int32 = 0 To images.GetUpperBound(0) tiffImage.SelectActiveFrame(Drawing.Imaging.FrameD imension.Page, imageIndex) images(imageindex) = GetReducedImage(CType(tiffImage.Clone, Bitmap)) Next FYI Public Shared Function GetReducedImage(ByRef image As Bitmap) As Bitmap Dim result As Image = New Bitmap(image.Width, image.Height,Imaging.PixelFormat.Format16bppRgb555 ) g = Graphics.FromImage(result) g.DrawImageUnscaled(image, 0, 0) Return CType(result, Bitmap) End Function |
#3
| |||
| |||
|
|
Check out the multi-page TIFF articles 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. landers wrote: Hi All, I'm am having trouble resizing a multipage TIFF file. The TIFF is 640x480 and I am trying to resize ALL frames to 320x280. If I resize it by creating a new bitmap at the target size and resave, it loses the pages. If I loop through all the pages and resize each page into new bitmap, then recreate the TIFF, I get an Invalid Parameter Used exception. What is confusing is that the code to create a multipaged TIFF from an array of newly drawn images works. It seems to be when I open a multipaged TIFF and try to use copies of the frames as a source for another TIFF where the issue occurs. Dim imageFile As System.IO.StreamReader = New System.IO.StreamReader("my_multipaged_tiff.tiff") Dim tiffImage As System.Drawing.Bitmap = New Bitmap(imageFile.BaseStream) Dim images(tiffImage.GetFrameCount(Imaging.FrameDimens ion.Page) - 1) As Drawing.Bitmap For imageIndex As Int32 = 0 To images.GetUpperBound(0) tiffImage.SelectActiveFrame(Drawing.Imaging.FrameD imension.Page, imageIndex) images(imageindex) = GetReducedImage(CType(tiffImage.Clone, Bitmap)) Next FYI Public Shared Function GetReducedImage(ByRef image As Bitmap) As Bitmap Dim result As Image = New Bitmap(image.Width, image.Height,Imaging.PixelFormat.Format16bppRgb555 ) g = Graphics.FromImage(result) g.DrawImageUnscaled(image, 0, 0) Return CType(result, Bitmap) End Function |
#4
| |||
| |||
|
|
Hi Bob, Already checked the website out and it doesn't really answer my question. I am trying to read a multipaged TIFF in, resize it and write it out to a new TIFF. I can already get random images and create a multipaged TIFF, but its when my source images are from a page within a TIFF where I get the problem. Landers. "Bob Powell [MVP]" <bob (AT) _spamkiller_bobpowell (DOT) net> wrote in message news:%23Izb5HscHHA.4984 (AT) TK2MSFTNGP05 (DOT) phx.gbl... Check out the multi-page TIFF articles 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. landers wrote: Hi All, I'm am having trouble resizing a multipage TIFF file. The TIFF is 640x480 and I am trying to resize ALL frames to 320x280. If I resize it by creating a new bitmap at the target size and resave, it loses the pages. If I loop through all the pages and resize each page into new bitmap, then recreate the TIFF, I get an Invalid Parameter Used exception. What is confusing is that the code to create a multipaged TIFF from an array of newly drawn images works. It seems to be when I open a multipaged TIFF and try to use copies of the frames as a source for another TIFF where the issue occurs. Dim imageFile As System.IO.StreamReader = New System.IO.StreamReader("my_multipaged_tiff.tiff") Dim tiffImage As System.Drawing.Bitmap = New Bitmap(imageFile.BaseStream) Dim images(tiffImage.GetFrameCount(Imaging.FrameDimens ion.Page) - 1) As Drawing.Bitmap For imageIndex As Int32 = 0 To images.GetUpperBound(0) tiffImage.SelectActiveFrame(Drawing.Imaging.FrameD imension.Page, imageIndex) images(imageindex) = GetReducedImage(CType(tiffImage.Clone, Bitmap)) Next FYI Public Shared Function GetReducedImage(ByRef image As Bitmap) As Bitmap Dim result As Image = New Bitmap(image.Width, image.Height,Imaging.PixelFormat.Format16bppRgb555 ) g = Graphics.FromImage(result) g.DrawImageUnscaled(image, 0, 0) Return CType(result, Bitmap) End Function |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |