Creating a Tiff that is Fax Ready
-
Dave I'm sure you'll be the one responding so I'll direct towards you, and by the way , I think I can say on behalf of all of us here, you are a great help. I had asked you a question a while back, about printing with forsay the printdocument to a file. Well going the other route of creating the tif image file myself. My problem, is I can create a tiff image file, and it'll open on my home computer, but at work, when I try to open it, or pass it our Biscom Fax Software, it says incorrect format, which I'm sure it's cause it's not compressed right. If you could guide me in the right direction, or tell me what I'm doing wrong, Here as follows is my code Dim b As Bitmap = New Bitmap(800, 1100) Dim g As Graphics = Graphics.FromImage(b) g.SmoothingMode = Drawing2D.SmoothingMode.HighQuality g.DrawString(myuser.username, New Font("Arial", 12, FontStyle.Regular), Brushes.Black, 240, 20) g.DrawString(myuser.outsidephone, New Font("Arial", 12, FontStyle.Regular), Brushes.Black, 250, 37) g.DrawString(myuser.email, New Font("Arial", 12, FontStyle.Regular), Brushes.Black, 185, 53) g.DrawString(" Name : " + TextBox2.Text, New Font("Arial", 12, FontStyle.Regular), Brushes.Black, 50, 130) customerinfo = Customerfind(TextBox1.Text) g.DrawString("Company : " + customerinfo.Company, New Font("Arial", 12, FontStyle.Regular), Brushes.Black, 50, 150) g.DrawString(" Phone : " + TextBox3.Text, New Font("Arial", 12, FontStyle.Regular), Brushes.Black, 50, 170) g.DrawString(" Fax : " + TextBox4.Text, New Font("Arial", 12, FontStyle.Regular), Brushes.Black, 50, 190) g.DrawString("Active Part", New Font("Arial", 30, FontStyle.Bold), Brushes.Black, 280, 260) Dim mypos As Integer = 315 Dim index As Integer Dim total As Integer total = ListView1.Items.Count For index = 0 To total - 1 g.DrawString("Part # : ", New Font("Arial", 12, FontStyle.Regular), Brushes.Black, 80, mypos) g.DrawString(ListView1.Items(index).Text, New Font("Arial", 12, FontStyle.Regular), Brushes.Black, 150, mypos) mypos += 20 g.DrawString("Description : ", New Font("Arial", 12, FontStyle.Regular), Brushes.Black, 50, mypos) g.DrawString(ListView1.Items(index).SubItems(1).Text, New Font("Arial", 12, FontStyle.Regular), Brushes.Black, 150, mypos) mypos += 20 g.DrawString("Price : ", New Font("Arial", 12, FontStyle.Regu
-
Dave I'm sure you'll be the one responding so I'll direct towards you, and by the way , I think I can say on behalf of all of us here, you are a great help. I had asked you a question a while back, about printing with forsay the printdocument to a file. Well going the other route of creating the tif image file myself. My problem, is I can create a tiff image file, and it'll open on my home computer, but at work, when I try to open it, or pass it our Biscom Fax Software, it says incorrect format, which I'm sure it's cause it's not compressed right. If you could guide me in the right direction, or tell me what I'm doing wrong, Here as follows is my code Dim b As Bitmap = New Bitmap(800, 1100) Dim g As Graphics = Graphics.FromImage(b) g.SmoothingMode = Drawing2D.SmoothingMode.HighQuality g.DrawString(myuser.username, New Font("Arial", 12, FontStyle.Regular), Brushes.Black, 240, 20) g.DrawString(myuser.outsidephone, New Font("Arial", 12, FontStyle.Regular), Brushes.Black, 250, 37) g.DrawString(myuser.email, New Font("Arial", 12, FontStyle.Regular), Brushes.Black, 185, 53) g.DrawString(" Name : " + TextBox2.Text, New Font("Arial", 12, FontStyle.Regular), Brushes.Black, 50, 130) customerinfo = Customerfind(TextBox1.Text) g.DrawString("Company : " + customerinfo.Company, New Font("Arial", 12, FontStyle.Regular), Brushes.Black, 50, 150) g.DrawString(" Phone : " + TextBox3.Text, New Font("Arial", 12, FontStyle.Regular), Brushes.Black, 50, 170) g.DrawString(" Fax : " + TextBox4.Text, New Font("Arial", 12, FontStyle.Regular), Brushes.Black, 50, 190) g.DrawString("Active Part", New Font("Arial", 30, FontStyle.Bold), Brushes.Black, 280, 260) Dim mypos As Integer = 315 Dim index As Integer Dim total As Integer total = ListView1.Items.Count For index = 0 To total - 1 g.DrawString("Part # : ", New Font("Arial", 12, FontStyle.Regular), Brushes.Black, 80, mypos) g.DrawString(ListView1.Items(index).Text, New Font("Arial", 12, FontStyle.Regular), Brushes.Black, 150, mypos) mypos += 20 g.DrawString("Description : ", New Font("Arial", 12, FontStyle.Regular), Brushes.Black, 50, mypos) g.DrawString(ListView1.Items(index).SubItems(1).Text, New Font("Arial", 12, FontStyle.Regular), Brushes.Black, 150, mypos) mypos += 20 g.DrawString("Price : ", New Font("Arial", 12, FontStyle.Regu
Well, I only have about 10 minutes per day (if I'm lucky!) to do this anymore. My life got very busy with a new job and my girlfriend recovering from reconstructive knee surgery. First, you don't use
g.Save()
. This doesn't save the image, only the state of theGraphics
container. In your case, it's useless... Second, I'd have to do some research on this, but it would appear that at least one of the image parameters being written to the .TIFF file are wrong or not supported by the Fax software .TIFF parser. What I mean is something like the Image Color Depth or Pixel Format may not be supported. I say this because your creating a Bitmap object using just the height and width parameters, which defaults to a 32-bits per pixel format that supports 8 bits for Red, Green, Blue, and an Alpha channel. Now, when you go to save the Bitmap object, that image information is stored with the image in the .TIFF file. But, I don't think the correct, or should I say universaly compatible, image parameter information is being written to the file. Fax software might only support an 8-bit per pixel or maybe even a 1-bit per pixel format. So... What I think you have to do is experiment with creating your Bitmap object using the Height, Width, and PixelFormat parameters. Something like:Dim b As Bitmap = New Bitmap(800, 1100, PixelFormat.Format1bppIndexed)
You might also have to alter the Palette array and supply the correct colors to the Bitmap object if the PixelFormat is an -Indexed format. In the case of Format1bppIndex, you'd have to supply 2 colors (32-bit ARGB values) to the Palette array, maybe 0x00000000 and 0xFFFFFFFF for black and white colors. A good way to find out the information you need would be to load a .TIFF file generated by the Fax software into the Bitmap object and look at its property values in the debugger. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
Well, I only have about 10 minutes per day (if I'm lucky!) to do this anymore. My life got very busy with a new job and my girlfriend recovering from reconstructive knee surgery. First, you don't use
g.Save()
. This doesn't save the image, only the state of theGraphics
container. In your case, it's useless... Second, I'd have to do some research on this, but it would appear that at least one of the image parameters being written to the .TIFF file are wrong or not supported by the Fax software .TIFF parser. What I mean is something like the Image Color Depth or Pixel Format may not be supported. I say this because your creating a Bitmap object using just the height and width parameters, which defaults to a 32-bits per pixel format that supports 8 bits for Red, Green, Blue, and an Alpha channel. Now, when you go to save the Bitmap object, that image information is stored with the image in the .TIFF file. But, I don't think the correct, or should I say universaly compatible, image parameter information is being written to the file. Fax software might only support an 8-bit per pixel or maybe even a 1-bit per pixel format. So... What I think you have to do is experiment with creating your Bitmap object using the Height, Width, and PixelFormat parameters. Something like:Dim b As Bitmap = New Bitmap(800, 1100, PixelFormat.Format1bppIndexed)
You might also have to alter the Palette array and supply the correct colors to the Bitmap object if the PixelFormat is an -Indexed format. In the case of Format1bppIndex, you'd have to supply 2 colors (32-bit ARGB values) to the Palette array, maybe 0x00000000 and 0xFFFFFFFF for black and white colors. A good way to find out the information you need would be to load a .TIFF file generated by the Fax software into the Bitmap object and look at its property values in the debugger. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
Glad you get to spend the time you do, helping others. Someday, I'll be able to answer questions, I did some testing on some of what ya gave me, the following throws an error Dim b As Bitmap = New Bitmap(800, 1100, Imaging.PixelFormat.Format1bppIndexed) Dim g As Graphics = Graphics.FromImage(b) This throws the following error Additional information: A Graphics object cannot be created from an image that has an indexed pixel format. Tomorrow I'll grab a image that works, and see what specs I can get.