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:
The bitmap is drawn on and converted to 1bpp (the name is workingFront), then the items are applied and saved:
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.
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:
Code:
System.Drawing.Imaging.Encoder comp = System.Drawing.Imaging.Encoder.Compression;
EncoderParameters parms = new EncoderParameters(1);
parms.Param[0] = new EncoderParameter(comp,(long)EncoderValue.CompressionCCITT4);
ImageCodecInfo info = GetEncoder(ImageFormat.Tiff);
PropertyItem fillorder = resourceBitmap.GetPropertyItem(256);
fillorder.Id = 266;
fillorder.Len = 1;
fillorder.Type = 4;
fillorder.Value = new byte[1] { 1 };
PropertyItem imageDescription = resourceBitmap.GetPropertyItem(256);
imageDescription.Id = 270;
imageDescription.Value = new byte[0] { };
imageDescription.Len = 0;
imageDescription.Type = 4;
PropertyItem orientation = resourceBitmap.GetPropertyItem(256);
orientation.Id = 274;
orientation.Value = new byte[1] { 1 };
orientation.Len = 1;
orientation.Type = 4;
PropertyItem t6option = resourceBitmap.GetPropertyItem(256);
t6option.Id = 293;
t6option.Value = new byte[1] { 0 };
t6option.Len = 1;
t6option.Type = 4;
Code:
workingFront.SetPropertyItem(fillorder);
workingFront.SetPropertyItem(imageDescription);
workingFront.SetPropertyItem(orientation);
workingFront.SetPropertyItem(t6option);
workingFront.Save(outFile, info, parms);
Comment