Solved

.Tif Files in C#

Posted on 2003-11-22
8
631 Views
Last Modified: 2009-12-16
Again for my lovely OCR Project, I need to be able to use .tif files. TIF Files use an Index Pixel Format. Does C# Natively support these? And if not, would my best approach be to manually make it, or find a library?
0
Comment
Question by:derekthornton
  • 5
  • 3
8 Comments
 
LVL 20

Expert Comment

by:TheAvenger
ID: 9805638
You can load a TIFF image with this code:

System.Drawing.Bitmap bmp = new System.Drawing.Bitmap (@"C:\picture.tif");

Then you can manipulate the bitmap using the Bitmap class members.
0
 
LVL 2

Author Comment

by:derekthornton
ID: 9805827
but can it be properly saved back as a tif?
0
 
LVL 20

Expert Comment

by:TheAvenger
ID: 9805837
You can use Bitmap.Save (actually inherited from the Image class) to save it to a specified file or stream. Have a look at the different versions of the Save method - you can specify an ImageFormat, ImageCodecInfo and/or EncoderParameters.
0
 
LVL 20

Accepted Solution

by:
TheAvenger earned 500 total points
ID: 9805839
ImageFormat.Tiff is what you will need, so something like:

bmp.Save (@"c:\newfile.tif", ImageFormat.Tiff);
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 2

Author Comment

by:derekthornton
ID: 9805841
How do you know all this? Is there a list of all these class members and/or fields somewhere? The MSDN Library is useless, it has no organization whatsoever.
0
 
LVL 20

Expert Comment

by:TheAvenger
ID: 9805849
Just the opposite, I use very often the MSDN library and it helps me a lot. I only figured out that the Bitmap class supports TIFF format by loading one (with the line I showed you). Then I went to the MSDN, wrote in the index Bitmap class, then selected all members and just checked the Save method. It has several overloads and I just had a look at the easiest one to work for you.

MSDN online is somewhat more difficult to work on, so I normally prefer the local version. However the online version has absolutely everything as well and is more actual so I also check it from time to time.
0
 
LVL 2

Author Comment

by:derekthornton
ID: 9805862
Thanks again. I guess I should install the MSDN Local Copy then, I figured it was no different than the online version.
0
 
LVL 20

Expert Comment

by:TheAvenger
ID: 9805865
It's a little bit better organized and it has an index - very useful I think. Also it's much faster, you don't need internet connection... But in a bad case the online will also help you once you get used to using it
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Check my code out(2) 2 54
C# HTTP GET method sample code 3 42
Reset asp.net login password 4 34
Where can I ask about my ASP.NET MVC project? 6 23
Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now