<p>I'm trying to convert a multipage color tiff file to a c# CompressionCCITT3 tiff in C#. I realize that I need to make sure that all pixels are 1 bit. I have not found a useful example of this online.</p>

[{'answer_id': 45131, 'author': 'Joshua Turner', 'author_id': 820, 'author_profile': 'https://Stackoverflow.com/users/820', 'pm_score': 2, 'selected': True, 'text': "<p>You need this conversion as CCITT3 and CCITT4 don't support color (if I remember right).</p>\n"}, {'answer_id': 1363947, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<p>I saw the above code, and it looked like it was converting every pixel with manual logic.</p>\n\n<p>Would this work for you?</p>\n\n<p>Imports System.Drawing.Imaging</p>\n\n<p>\'get the color tif file</p>\n\n<p>Dim bmpColorTIF As New Bitmap("C:\\color.tif")</p>\n\n<p>\'select the an area of the tif (will grab all frames)</p>\n\n<p>Dim rectColorTIF As New Rectangle(0, 0, bmpColorTIF.Width, bmpColorTIF.Height )</p>\n\n<p>\'clone the rectangle as 1-bit color tif</p>\n\n<p>Dim bmpBlackWhiteTIF As Bitmap = bmpColorTIF.Clone(rectColorTIF, PixelFormat.Format1bppIndexed)</p>\n\n<p>\'do what you want with the new bitmap (save, etc)</p>\n\n<p>...</p>\n\n<p>Note: there are a ton of pixelformats to choose from.</p>\n'}, {'answer_id': 1364055, 'author': 'plinth', 'author_id': 20481, 'author_profile': 'https://Stackoverflow.com/users/20481', 'pm_score': 1, 'selected': False, 'text': '<p>Pimping disclaimer: I work for <a href="http://www.atalasoft.com" rel="nofollow noreferrer">Atalasoft</a>, a company that makes .NET imaging software.</p>\n\n<p>Using <a href="http://www.atalasoft.com/products/dotimage/documentimaging/default.aspx" rel="nofollow noreferrer">dotImage</a>, this task becomes something like this:</p>\n\n<pre><code>FileSystemImageSource source = new FileSystemImageSource("path-to-your-file.tif", true); // true = loop over all frames\n// tiff encoder will auto-select an appropriate compression - CCITT4 for 1 bit.\nTiffEncoder encoder = new TiffEncoder();\nencoder.Append = true;\n\n// DynamicThresholdCommand is very good for documents.  For pictures, use DitherCommand\nDynamicThresholdCommand threshold = new DynamicThresholdCommand();\n\nusing (FileStream outstm = new FileStream("path-to-output.tif", FileMode.Create)) {\n    while (source.HasMoreImages()) {\n        AtalaImage image = source.AcquireNext();\n        AtalaImage finalImage = image;\n        // convert when needed.\n        if (image.PixelFormat != PixelFormat.Pixel1bppIndexed) {\n            finalImage = threshold.Apply().Image;\n        }\n        encoder.Save(outstm, finalImage, null);\n        if (finalImage != image) {\n            finalImage.Dispose();\n        }\n        source.Release(image);\n    }\n}\n</code></pre>\n\n<p>The Bob Powell example is good, as far as it goes, but it has a number of problems, not the least of which is that it\'s using a simple threshold, which is terrific if you want speed and don\'t actually care what your output looks like or your input domain is such that really is pretty much black and white already - just represented in color.  Binarization is a tricky problem.  When your task is to reduce available information by 1/24th, how to keep the right information and throw away the rest is a challenge.  DotImage has six different tools (IIRC) for binarization.  SimpleThreshold is bottom of the barrel, from my point of view.</p>\n'}, {'answer_id': 2148627, 'author': 'Adriaan', 'author_id': 147820, 'author_profile': 'https://Stackoverflow.com/users/147820', 'pm_score': 1, 'selected': False, 'text': '<p>I suggest to experiment with the desired results first using tiff and image utilities before diving into the coding. I found <a href="http://www.vips.ecs.soton.ac.uk/index.php?title=VIPS" rel="nofollow noreferrer">VIPS</a> to be a handy tool. The next option is to look into what LibTIFF can do. I\'ve had good results with the free <a href="http://bitmiracle.com/libtiff/" rel="nofollow noreferrer">LibTiff.NET</a> using c# (see also <a href="https://stackoverflow.com/questions/2041783/using-libtiff-from-c-to-access-tiled-tiff-images">stackoverflow</a>). I was very disappointed by the GDI tiff functionality, although your milage may vary (I need the missing 16-bit-grayscale).\nAlso you can use the <a href="http://www.libtiff.org/" rel="nofollow noreferrer">LibTiff</a> utilities (i.e. see <a href="http://www.libtiff.org/man/tiffcp.1.html" rel="nofollow noreferrer">http://www.libtiff.org/man/tiffcp.1.html</a>)</p>\n'}]
['https://Stackoverflow.com/questions/44476', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/178/']