Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / January 2008

Tip: Looking for answers? Try searching our database.

modifying single frames in a multi frame tiff

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steve K. - 11 Jan 2008 07:15 GMT
I would like to rotate pages in a multi-page tiff.  Here is my first
attempt:

<code>
public void RotatePageAndSave(int degrees)
{
   RotateFlipType rotateType = RotateFlipType.Rotate180FlipNone;
   switch(degrees)
   {
       case 180: rotateType = RotateFlipType.Rotate180FlipNone; break;
       case 90: rotateType = RotateFlipType.Rotate90FlipNone; break;
       default: throw new Exception("Unsupported rotation value: " +
degrees);
   }

   //  try drawing on the current frame and saving to a temp folder
   _attachment.RotateFlip(rotateType);
   int y = _attachment.GetFrameCount(FrameDimension.Page);

   Console.WriteLine("The saved file should have {0} pages and the " +
       "rotating should be on page {1}", _numPages, _currentPageIndex);
   _attachment.Save(@"C:\StompTest.tif");
}
Peter Duniho - 11 Jan 2008 08:15 GMT
> I would like to rotate pages in a multi-page tiff.  Here is my first
> attempt:

And?

Did you have a question?
Steve K. - 11 Jan 2008 09:25 GMT
I accidently sent that without finishing, sorry.

What I was *going* to say is that the code below results in a single frame
tif.  In fact as soon as I rotate the page, the frame count returned by
GetFrameCount() changes from (whatever it was) to 1.  It seems that
perfoming operations on a tif like this invalidates it somehow?

I'm still reading online for various tips and tricks, but not finding too
much about specifically editing a tif like this.  The only thing I can think
of would be to pull all the frames out, perform operations, then rebuild the
tif.

Is that what others are doing?

I've run some tests and even that is proving a little more difficult than I
had though.  Lots to learn!

-Steve

>I would like to rotate pages in a multi-page tiff.  Here is my first
>attempt:
[quoted text clipped - 19 lines]
>    _attachment.Save(@"C:\StompTest.tif");
> }
Peter Duniho - 11 Jan 2008 18:42 GMT
> I accidently sent that without finishing, sorry.
>
[quoted text clipped - 3 lines]
> GetFrameCount() changes from (whatever it was) to 1.  It seems that
> perfoming operations on a tif like this invalidates it somehow?

Ah.  Well, not something I know about first-hand, but that sounds about  
right.  I'd guess the RotateFlip() method is just a simple helper that  
basically creates a new internal image, copying the original into the new  
one thereby replacing it.

> I'm still reading online for various tips and tricks, but not finding too
> much about specifically editing a tif like this.  The only thing I can  
> think
> of would be to pull all the frames out, perform operations, then rebuild  
> the
> tif.

Sounds like a reasonable workaround to me.  I don't view the .NET  
Framework as being a full-featured image editing framework.  It has some  
basic functionality, but it still leaves lots of things for you to manage  
manually.  Assuming .NET has a way for you to generate a multi-frame image  
(haven't done that myself), that seems like a better way to go.

BTW, if performance is important, you may want to avoid using RotateFlip()  
in this case, given that it does generate a brand new image without any  
other frames.  Using RotateFlip(), you'd have to copy your original Image  
so that you don't muck it up with the call to RotateFlip(), and then copy  
the rotated image into the new Image you're building.

Instead, you should just use Graphics.FromImage() on the Image you're  
building so that you can draw into its current frame, set the Transform  
property of the Graphics so that drawing the original image into the new  
one is rotated as you desire, and then just draw the original image  
directly into the new one.

Pete
Steve K. - 13 Jan 2008 01:29 GMT
>> I accidently sent that without finishing, sorry.
>>
[quoted text clipped - 21 lines]
> manually.  Assuming .NET has a way for you to generate a multi-frame image
> (haven't done that myself), that seems like a better way to go.

I agree, it can't do it all.  It does somethings so well that I've come to
expect it to "do everything" which of course is unreasonable! ;0)

> BTW, if performance is important, you may want to avoid using RotateFlip()
> in this case, given that it does generate a brand new image without any
> other frames.  Using RotateFlip(), you'd have to copy your original Image
> so that you don't muck it up with the call to RotateFlip(), and then copy
> the rotated image into the new Image you're building.

Performance is not an issue, however this is a good point and something I
will keep in mind.

> Instead, you should just use Graphics.FromImage() on the Image you're
> building so that you can draw into its current frame, set the Transform
> property of the Graphics so that drawing the original image into the new
> one is rotated as you desire, and then just draw the original image
> directly into the new one.

Yes, this is what I've started to do.

Thanks again for the great help Peter, I appreciate it.
-Steve

> Pete

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.