Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
I am looking for some tools that will allow me to create a TIFF document and then save it to a folder. If there isn't any built in tools, please recommend an add-on package.
 
Thank you
Posted 12-Feb-13 13:02pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

.Net does not have great tools for handling the TIFF format built in, at work we use LibTiff.Net[^], which is free and open-source.
  Permalink  
Comments
Sergey Alexandrovich Kryukov at 12-Feb-13 18:34pm
   
Sure, a 5.
—SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

I actually started to look t this last week but couldn't get any support ( which I can understand since it's free). I am looking to create a laboratory report. In one of their examples they build a bridge.
 
using BitMiracle.LibTiff.Classic;
 
namespace WriteTiff
{
    class Program
    {
        static void Main(string[] args)
        {
            byte[] buffer = new byte[25 * 144]
            {
                // boring hex omitted
            };
 
            // Open the TIFF file
            using (Tiff image = Tiff.Open("output.tif", "w"))
            {
                if (image == null)
                {
                    System.Console.Error.WriteLine("Could not open output.tif for writing");
                    return;
                }
 
                // We need to set some values for basic tags before we can add any data
                image.SetField(TiffTag.IMAGEWIDTH, 25 * 8);
                image.SetField(TiffTag.IMAGELENGTH, 144);
                image.SetField(TiffTag.BITSPERSAMPLE, 1);
                image.SetField(TiffTag.SAMPLESPERPIXEL, 1);
                image.SetField(TiffTag.ROWSPERSTRIP, 144);
 
                image.SetField(TiffTag.COMPRESSION, Compression.CCITTFAX4);
                image.SetField(TiffTag.PHOTOMETRIC, Photometric.MINISWHITE);
                image.SetField(TiffTag.FILLORDER, FillOrder.MSB2LSB);
                image.SetField(TiffTag.PLANARCONFIG, PlanarConfig.CONTIG);
 
                image.SetField(TiffTag.XRESOLUTION, 150.0);
                image.SetField(TiffTag.YRESOLUTION, 150.0);
                image.SetField(TiffTag.RESOLUTIONUNIT, ResUnit.INCH);
 
                // Write the information to the file
                image.WriteEncodedStrip(0, buffer, 25 * 144);
 
                // file will be auto-closed during disposal
                // but you can close image yourself
                image.Close();
            }
        }
    }
}
 

Let's say I want to create a TIFF file that contains says "Hello World" in bold. Can you please supply an example of how I would code this with LibTiff?
 
Thank you.
  Permalink  
Comments
lewax00 at 12-Feb-13 19:11pm
   
It's in an example that isn't obvious, but check: http://bitmiracle.com/libtiff/help/add-page-to-existing-tiff.aspx it shows how to render strings onto it. In the future, if you need clarification on an answer, please use the "Have a Question or Comment?" button below the answer it's in reference too, otherwise that person will not get a notification (I only checked back because I had a new comment from someone else). It works out better for everyone that way :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web03 | 2.8.1411022.1 | Last Updated 12 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100