How to C#: Tiff
Using Tiff SDK for C#.NET
Convert Jpeg Images to Tiff
Convert Jpeg Images to Tiff
  |  
Home ›› XDoc.Tiff ›› C# Tiff: Images to Tiff

C# TIFF - Convert Raster Images to TIFF in C#.NET


C# Demo to Convert and Render JPEG/Png/Bmp to Tiff in Visual C#.NET Project




C#.NET Image: Raster Images to TIFF Overview



To help C# developers to transform & convert various image forms, like Jpeg, Png, Bmp, and REImage object to single or multi-page Tiff image file with no loss in content quality. RasterEdge develops a C#.NET Tiff file converter control, XDoc.Tiff for .NET, which can be stably integrated into C#.NET developing projects, like ASP.NET web applications and .NET Windows Forms applications.


Related .net document control helps:
asp.net pdf viewer using c#: ASP.NET PDF Viewer Control: view, navigate, zoom Adobe PDF document in C# ASP.NET
c# asp.net word document viewer: ASP.NET Office Word Document Viewer: view MS Office Word files online using C# in ASP.NET web applications
asp.net dotnetnuke pdf editor using c#: ASP.NET DNN PDF Editor Control: view, edit PDF files in Dotnetnuke application
c# asp.net dnn document viewer: DNN Document Viewer Control: view, annotate, redact, convert documents in dotnetnuke ASP.NET
c# asp.net iis document viewer: C# HTML5 Viewer: Deployment on IIS
c# asp.net text document viewer: C# HTML5 Viewer: Load, View, Convert, Annotate and Edit OpenOffice, CSV and Text file
asp.net azure pdf editor using c#: ASP.NET Azure PDF Editor Control: view, edit, annotate, redact PDF files online


In all, you will see four sections on this article.


C# sample code for converting Jpeg to Tiff


C# sample code for converting Png to Tiff


C# sample code for converting Bmp to Tiff





DLLs: Convert Raster Images to TIFF in C#



In order to run the following conversion code, please do as follows:


Add references;


  RasterEdge.Imaging.Basic.dll


  RasterEdge.Imaging.Basic.Codec.dll


  RasterEdge.Imaging.Drawing.dll


  RasterEdge.XDoc.Processing.dll


  RasterEdge.Imaging.Raster.dll


  RasterEdge.Imaging.Raster.Core.dll


  RasterEdge.Imaging.Font.dll


  RasterEdge.XDoc.TIFF.dll


Use corresponding namespaces;


  using RasterEdge.Imaging.Basic;


  using RasterEdge.XDoc.TIFF;


Note: When you get the error "Could not load file or assembly 'RasterEdge.Imaging.Basic' or any other assembly or one of its dependencies. An attempt to load a program with an incorrect format", please check your configure as follows:


If you are using x64 libraries/dlls, Right click the project -> Properties -> Build -> Platform target: x64.


If using x86, the platform target should be x86.




Use C# Code to Convert Jpeg to Tiff



Firstly, you may use following C# sample code to transform Jpeg image to Tiff image in your .NET application.




            String[] imagePaths = { @"F:\demo1.jpg", @"F:\demo2.jpg", @"F:\demo3.jpg" };
            Bitmap[] bmps = new Bitmap[3];
            // Step1: Load the image
            for (int i = 0; i < imagePaths.Length; i++)
            {
                Bitmap tmpBmp = new Bitmap(imagePaths[i]);
                if (tmpBmp != null)
                    bmps[i] = tmpBmp;
            }
            // Step2: Construct TIFFDocument object.
            TIFFDocument tifDoc = new TIFFDocument(bmps);
            // Step3: Other operations, like saving it.
            if (tifDoc == null)
                throw new Exception("Fail to construct TIFF Document");
            tifDoc.Save(@"F:\Test.tif");





Use C# Code to Convert Png to Tiff



Then, have a try with Png-to-Tiff conversion demo.




            String[] imagePaths = { @"F:\demo1.png", @"F:\demo2.png", @"F:\demo3.png" };
            Bitmap[] bmps = new Bitmap[3];
            // Step1: Load the image
            for (int i = 0; i < imagePaths.Length; i++)
            {
                Bitmap tmpBmp = new Bitmap(imagePaths[i]);
                if (tmpBmp != null)
                    bmps[i] = tmpBmp;
            }
            // Step2: Construct TIFFDocument object.
            TIFFDocument tifDoc = new TIFFDocument(bmps);
            // Step3: Other operations, like saving it.
            if (tifDoc == null)
                throw new Exception("Fail to construct TIFF Document");
            tifDoc.Save(@"F:\Test.tif");





Use C# Code to Convert Bmp to Tiff with specified compression type



The output TIFF file will be compressed by CCITT Group 3 Fax compression




            String[] imagePaths = { @"F:\demo1.bmp", @"F:\demo2.bmp", @"F:\demo3.bmp" };
            Bitmap[] bmps = new Bitmap[3];
            // Step1: Load the image
            for (int i = 0; i < imagePaths.Length; i++)
            {
                Bitmap tmpBmp = new Bitmap(imagePaths[i]);
                if (tmpBmp != null)
                    bmps[i] = tmpBmp;
            }
            // Step2: Construct TIFFDocument object.
            TIFFDocument tifDoc = new TIFFDocument(bmps,ImageCompress.Group3Fax);
            // Step3: Other operations, like saving it.
            if (tifDoc == null)
                throw new Exception("Fail to construct TIFF Document");
            tifDoc.Save(@"F:\Test.tif");





Use C# Code to Convert Bmp to Tiff with optional settings



The output TIFF will be 1.5 times the size of input image




            String[] imagePaths = { @"F:\demo1.bmp", @"F:\demo2.bmp", @"F:\demo3.bmp" };
            Bitmap[] bmps = new Bitmap[3];
            // Step1: Load the image
            for (int i = 0; i < imagePaths.Length; i++)
            {
                Bitmap tmpBmp = new Bitmap(imagePaths[i]);
                if (tmpBmp != null)
                    bmps[i] = tmpBmp;
            }
            // Step2: Create the ImageOutputOption object.
            ImageOutputOption option = new ImageOutputOption();
            //set the zoom value
            option.Zoom = 1.5f;
            // Step3: Construct TIFFDocument object.
            TIFFDocument tifDoc = new TIFFDocument(bmps, option);
            // Step4: Other operations, like saving it.
            if (tifDoc == null)
                throw new Exception("Fail to construct TIFF Document");
            tifDoc.Save(@"F:\Test.tif");




public TIFFDocument(Bitmap[] images)

Description:
Create TIFF file from images.

Parameters:
public TIFFDocument(Bitmap[] images, ImageCompress imageCompression)

Description:
Create TIFF file from images with specified compression

Parameters:
public TIFFDocument(Bitmap[] images, ImageOutputOption options)

Description:
Create TIFF file from images with optional output settings.

Parameters:
ImageOutputOption: