In VB.NET, how do I save a bitmap in a pixel-indexed format?

CMousseau

Member
Joined
Mar 16, 2005
Messages
5
Location
Calgary, AB, Canada
Ladies and Gentlemen,

I am presently developing an application that will watermark .TIFF images we have on our system. These images are strictly black-and-white, so they are stored in 1 bit-per-pixel indexed format (Imaging.PixelFormat.Format1bppindexed) which naturally leads to them being very compressed.

Now, I know that you cannot assign a Graphics object to an indexed-pixel image, so I create a mediary bitmap in Imaging.PixelFormat.Format24bppRGB and use the first bitmap as a source to draw into the second one, to wit:


Read source TIFF into new bitmap object
Dim m_clsSource As New Bitmap(strPath)

Create destination bitmap object with the same features
Dim m_clsDest As New Bitmap(m_clsSource.Width, m_clsSource.Height, Imaging.PixelFormat.Format24bppRgb)
m_clsDest.SetResolution(m_clsSource.HorizontalResolution, m_clsSource.VerticalResolution)

Dim m_clsFrame As Bitmap
Dim m_clsCanvas As Graphics = Graphics.FromImage(m_clsDest)

Dim X, intPageCount As Integer
intPageCount = m_clsSource.GetFrameCount(Imaging.FrameDimension.Page)

m_clsCanvas.DrawImage(m_clsSource, 0, 0, m_clsDest.Width, m_clsDest.Height)


My question is, now - how do I go about converting m_clsDest back into the 1 bit-per-pixel indexed format?

Or, is there a graphics tool/class available on the net that would enable me to directly manipulate the graphic in its native 1bpp mode? Note that my employers security policy would dictate that I need the source code for such a class and compile it personally.

Thank you for your time,
Charles Mousseau.

***
 
Back
Top