473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Saving TIFF tags in C#

Working in C# in Visual Studio 2005

So I know how to edit TIFF tags (get a propertyItem object, edit its details, and stick it into a bitmap), but saving them is presenting itself as a problem.

After I'm done drawing on the bitmap, I convert it to 1bbp, then stick the propertyItems onto the bitmap. I've checked, and I can see each of the propertyItems I've put into the bitmap. I then save the file using the TIFF encoder and CCITT4 compression.
When I actually look at the tags, all that's there are the default tags generated by the TIFF encoder.

A little snippit of my code:
Expand|Select|Wrap|Line Numbers
  1. System.Drawing.Imaging.Encoder comp = System.Drawing.Imaging.Encoder.Compression;
  2.             EncoderParameters parms = new EncoderParameters(1);
  3.             parms.Param[0] = new EncoderParameter(comp,(long)EncoderValue.CompressionCCITT4);
  4.             ImageCodecInfo info = GetEncoder(ImageFormat.Tiff);
  5.  
  6.             PropertyItem fillorder = resourceBitmap.GetPropertyItem(256);
  7.             fillorder.Id = 266;
  8.             fillorder.Len = 1;
  9.             fillorder.Type = 4;
  10.             fillorder.Value = new byte[1] { 1 };
  11.             PropertyItem imageDescription = resourceBitmap.GetPropertyItem(256);
  12.             imageDescription.Id = 270;
  13.             imageDescription.Value = new byte[0] { };
  14.             imageDescription.Len = 0;
  15.             imageDescription.Type = 4;
  16.             PropertyItem orientation = resourceBitmap.GetPropertyItem(256);
  17.             orientation.Id = 274;
  18.             orientation.Value = new byte[1] { 1 };
  19.             orientation.Len = 1;
  20.             orientation.Type = 4;
  21.             PropertyItem t6option = resourceBitmap.GetPropertyItem(256);
  22.             t6option.Id = 293;
  23.             t6option.Value = new byte[1] { 0 };
  24.             t6option.Len = 1;
  25.             t6option.Type = 4;
The bitmap is drawn on and converted to 1bpp (the name is workingFront), then the items are applied and saved:

Expand|Select|Wrap|Line Numbers
  1. workingFront.SetPropertyItem(fillorder);
  2.                     workingFront.SetPropertyItem(imageDescription);
  3.                     workingFront.SetPropertyItem(orientation);
  4.                     workingFront.SetPropertyItem(t6option);
  5.  
  6.                     workingFront.Save(outFile, info, parms);
Now, is it that I'm not using an encoder parameter that I should be? Perhaps the method isn't even how you're supposed to be able to get TIFF tags into a TIFF image? I also think that perhaps I haven't formatted the propertyItems correctly. I'm not sure, there aren't very many examples out there about this stuff at all.
Mar 13 '08 #1
1 8746
Hmm, nevermind. It looks like I was formatting my propertyitem objects incorrectly (I looked at the property items in the file I was stripping them off of, and noticed that I was doing it a lot differently than what was in that object).
Mar 13 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: mchl gdbt | last post by:
Hi, I have several thousand tiffs generated by application A which are read by application B. I need to remove a few colours from the tiffs and I decided to try with the python imaging library....
0
by: E-Cube | last post by:
Hello all, I am attempting to save a bitmap image and saving it as a tiff image with CCITT4 compression using the folllowing code. oEncoderParameters = New Imaging.EncoderParameters(1) oEncoder...
5
by: Thaynann | last post by:
I have an app that (at the moment) moves through files that are on a web site, and deletes them, wat i want to do for the next stage, is to be able to download each file before i delete it. i...
0
by: Robert Seidl | last post by:
I saw that VB .Net 2003 has some tools for easily reading metadata information present in some TIFF and JPG files, eg. ---------------------------------------------------------------- .... Dim b...
5
by: Eddie Leung | last post by:
Hi All, As I know that the tiff contain header information, I can use one software called tifftags.exe to get tiff tag information. However, I can't get any reference from vb.net to do such...
5
by: mesh2005 | last post by:
I'm new to C# , I use MS visual studio.NET 2003. I have some TIFF images, I want to write a program using c# that reads an image (.tiff) and prints all its tags. can anyone guid me to the right...
5
by: Sameer Gupta | last post by:
what are options for opening / handling tiff files in .Net framework ? which is the best library, namespace ? Please help Regards Sameer Gupta C# Designer & Developer Siemens UK
8
dshimer
by: dshimer | last post by:
I am doing some basic modification to existing TIFF files using PIL (1.6 in python 2.5). When I open the image there is quite a bit of info in the tags dict that I would like to save with the new...
3
by: eagles | last post by:
I'm trying to save a BufferedImage as a .tiff. The following: ImageIO.write(bufferedImg, "TIFF", new File("file.tiff")); is returning false. Do I need to use JAI? I'm just trying to use the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.