Solved

.Tif Files in C#

Posted on 2003-11-22
8
622 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
Comment Utility
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
Comment Utility
but can it be properly saved back as a tif?
0
 
LVL 20

Expert Comment

by:TheAvenger
Comment Utility
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
Comment Utility
ImageFormat.Tiff is what you will need, so something like:

bmp.Save (@"c:\newfile.tif", ImageFormat.Tiff);
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 2

Author Comment

by:derekthornton
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Article by: Ivo
Anonymous Types in C# by Ivo Stoykov Anonymous Types are useful when  we do not need to follow usual work-flow -- creating object of some type, assign some read-only values and then doing something with them. Instead we can encapsulate this read…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

771 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

11 Experts available now in Live!

Get 1:1 Help Now