---
title: "Save bitonal TIFF with CCITT4 compression"
canonical_url: "https://www.nutrient.io/guides/dotnet/samples/tiff-photometric-vbnet/"
md_url: "https://www.nutrient.io/guides/dotnet/samples/tiff-photometric-vbnet.md"
last_updated: "2026-05-14T21:57:26.876Z"
description: "Learn to save bitonal TIFF documents in VB.NET, avoiding viewer errors with photometric 0 and CCITT4 compression."
---

# Save bitonal TIFFs with VB.NET using photometric 0

This example shows how to save a bitonal TIFF document with photometric 1 and CCITT4 compression. Some (buggy) image viewers, such as Windows Picture and Fax Viewer used in Windows XP, ignore the photometric interpretation tag of group 3 and group 4 TIFF documents by assuming that black is always encoded with 1, and therefore display them as reversed when the photometric is set to 1.

[Get Started](https://www.nutrient.io/sdk/dotnet/getting-started.md)

[All Samples](https://www.nutrient.io/guides/dotnet/samples.md)

[Download](https://www.nutrient.io/guides/dotnet/downloads.md)

[Launch Demo](https://www.nutrient.io/demo/)

---

### C#

[C#](https://www.nutrient.io/guides/dotnet/samples/tiff-photometric-cs.md)

### VB.NET

[VB.NET](https://www.nutrient.io/guides/dotnet/samples/tiff-photometric-vbnet.md)

```vb

' While saving bitonal TIFF images, Nutrient.NET SDK (formerly GdPicture.NET) (starting V.10) behaves in the following way:

' - The photometric is set to 0 if the first entry of the color palette is white and the second entry is black.
' - The photometric is set to 1 if the first entry of the color palette is black and the second entry is white.
' - The photometric is set to 3 for other cases.

' So if you need to maximize compatibility with 'Windows Picture and Fax Viewer', you have to ensure to save your image using photometric mode 0. For such purpose you have to process like this:

' 1. Check the intented photometric of the image by obtaining color palette information.
' 2. In case of photometric 1, you have to negative the image pixel and invert the two palette entries.

' So a simple code snippet here demonstrates, how to enforce the photometric 0 of an existing tiff image.

'We assume that GdPicture has been correctly installed and unlocked.
Dim oGdPictureImaging As New GdPictureImaging()
Dim ImageID As Integer = oGdPictureImaging.CreateGdPictureImageFromFile("c:\myfile.tif", True)
If oGdPictureImaging.GetStat() = GdPictureStatus.OK Then
    If (oGdPictureImaging.GetBitDepth(ImageID) = 1) AndAlso
       (oGdPictureImaging.PaletteGetEntry(ImageID, 0).ToArgb() = Color.Black.ToArgb()) AndAlso
       (oGdPictureImaging.PaletteGetEntry(ImageID, 1).ToArgb() = Color.White.ToArgb()) Then
        If (oGdPictureImaging.FxNegative(ImageID) = GdPictureStatus.OK) AndAlso
           (oGdPictureImaging.PaletteSet(ImageID, New Color() {Color.White, Color.Black}) = GdPictureStatus.OK) AndAlso
           (oGdPictureImaging.SaveAsTIFF(ImageID, "c:\myfile.tif", TiffCompression.TiffCompressionCCITT4) = GdPictureStatus.OK) Then
            MessageBox.Show("Done!", "Bitonal TIFF Example", MessageBoxButtons.OK, MessageBoxIcon.Information)
        Else
            MessageBox.Show("Error: " + oGdPictureImaging.GetStat().ToString(), "Bitonal TIFF Example", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If
    End If
    oGdPictureImaging.ReleaseGdPictureImage(ImageID)
Else
    MessageBox.Show("Error: " + oGdPictureImaging.GetStat().ToString(), "Bitonal TIFF Example", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
oGdPictureImaging.Dispose()

```

This code sample is an example that illustrates how to use our SDK. Please adapt it to your specific use case.

---

## Related pages

- [Automatically rotate pages of a multipage TIFF file using OCR and VB.NET](/guides/dotnet/samples/auto-rotate-tiff-vbnet.md)
- [Automatically rotate pages of a multipage TIFF file using OCR and C#](/guides/dotnet/samples/auto-rotate-tiff-cs.md)
- [Convert PDFs, MS Office, and images to TIFF in C#](/guides/dotnet/samples/convert-to-tiff-cs.md)
- [Saving images into folders based on their barcode](/guides/dotnet/samples/barcode-auto-sorting-cs.md)
- [Saving images into folders based on their barcode](/guides/dotnet/samples/barcode-auto-sorting-vbnet.md)
- [Generate a multipage TIFF file using a compression mode per page in C#](/guides/dotnet/samples/create-multipage-tiff-cs.md)
- [Converting a Microsoft Word binary file document (DOC) to a Microsoft Word OpenXML document (DOCX) in C#](/guides/dotnet/samples/doc-to-docx-cs.md)
- [Merging two PDF documents by alternating pages from both files in VB.NET](/guides/dotnet/samples/merge-pdf-alternate-pages-vbnet.md)
- [Using an external OCR engine during PDF/OCR generation](/guides/dotnet/samples/integrate-omnipage-ocr-cs.md)
- [Converting a multipage PDF to a multipage TIFF using color detection in C#](/guides/dotnet/samples/pdf-to-tiff-color-detection-cs.md)
- [Merging two PDF documents by alternating pages from both files in C#](/guides/dotnet/samples/merge-pdf-alternate-pages-cs.md)
- [Converting a multipage PDF to a multipage TIFF using color detection in VB.NET](/guides/dotnet/samples/pdf-to-tiff-color-detection-vbnet.md)
- [Recompress existing PDFs using MRC compression in C#](/guides/dotnet/samples/recompress-pdf-mrc-cs.md)
- [Recompress an existing PDF using color detection in VB.NET](/guides/dotnet/samples/recompress-pdf-vbnet.md)
- [Recompress an existing PDF using color detection in C#](/guides/dotnet/samples/recompress-pdf-cs.md)
- [Recompress existing PDFs using MRC compression in VB.NET](/guides/dotnet/samples/recompress-pdf-mrc-vbnet.md)
- [Highlight and crop an image in C#](/guides/dotnet/samples/select-image-crop-area-cs.md)
- [Highlight and crop an image in VB.NET](/guides/dotnet/samples/select-image-crop-area-vbnet.md)
- [Highlight a region in PDF or an image in VB.NET](/guides/dotnet/samples/select-pdf-image-region-vbnet.md)
- [Choosing the appropriate OCR zone in C#](/guides/dotnet/samples/select-ocr-zone-cs.md)
- [Highlight a region in a PDF or an image in C#](/guides/dotnet/samples/select-pdf-image-region-cs.md)
- [Choosing the appropriate OCR zone in VB.NET](/guides/dotnet/samples/select-ocr-zone-vbnet.md)
- [Convert a multipage TIFF to a multipage JBIG2 in VB.NET](/guides/dotnet/samples/tiff-to-jbig2-vbnet.md)
- [Save bitonal TIFF images with C# and CCITT4](/guides/dotnet/samples/tiff-photometric-cs.md)
- [Convert a multipage TIFF to a multipage JBIG2 in C#](/guides/dotnet/samples/tiff-to-jbig2-cs.md)

