My application creates a dynamic graphic (some numbers superimposed on an existing bitmap) and saves the merged result to a bitmap file. I developed this using a laser printer. However, my customer will be using it on a thermal receipt printer. It, unfortunately, will only acept a 1 bit bitmap.
My base graphic, is saved as a grayscale file. I do my text/graphic merge thingy and save it back as a file, but the receipt printer won't print it because it is not 1 bit black and white graphic.
So I changed the base graphic to a 1 bit bitmap. When I run my app, an exception get thrown, "A Graphics object cannot be created from an image that has an indexed pixel format..." in other words something les than 16bpp.
Here's the offending code:
'Build dynamic graphic here
Const X = 160, Y = 160
Dim objBitmap = Bitmap.FromFile(regKey.GetValue("backgroundBloominBuck"))
Dim objGraphics As Graphics = Graphics.FromImage(objBitmap)
Dim moneyFont As New Font("Verdana", 36, FontStyle.Bold)
Dim drawBrush As New SolidBrush(Color.Black)
Dim drawFormat As New StringFormat
drawFormat.FormatFlags = StringFormatFlags.NoWrap
objGraphics.DrawString(strMoney, moneyFont, drawBrush, 66, 66, drawFormat)
If I could leave my orginal graphic as a grayscale, but somehow programmatically convert the resulting output file to a 1 bpp bitmap, then I would be happy. I would also be just as happy, if I could use Graphics.FromImage using a 1 bpp file. I wish I had run into this problem sooner, because this has to go live Saturday morning.
Someone please have pity on me and enlighten me with thine grand wisdom from I am but a worm.