Advertisements

How to save a Bitonal .tiff using CompressionCCITT4

This was a pain…. There are a couple of articles that got me really close, but this one was the finisher!

http://www.eggheadcafe.com/software/aspnet/29093592/key-to-speed–use-byte-array-instead-of-writing-to-locked-image-bytes.aspx

The trick was when I was converting the C# to vb.net from this article

http://www.codeproject.com/KB/GDI-plus/SaveMultipageTiff.aspx?fid=370645&fr=1#xx0xx

It mentions that you need to cast the bytes to ints

This is the salient line

pixelTotal = CInt(sourceBuffer(sourceIndex + 1)) + CInt(sourceBuffer(sourceIndex + 2)) + CInt(sourceBuffer(sourceIndex + 3))
Here is more info
http://www.bobpowell.net/onebit.htm
Also, note that if you want to retain the resolution you need to
In the ConvertToBitonal routine add the line marked below:

// Create destination bitmap
Bitmap destination = new Bitmap(source.Width, source.Height, PixelFormat.Format1bppIndexed);

-----> destination.SetResolution(source.HorizontalResolution, source.VerticalResolution);
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: