So I'm trying to read a file, line by line, then insert those onto a bitmap and convert that to a tiff file. Logically, to me anyway, my code should work. but when I run it, i just get a blank page.
But if I get rid of the loop for the streamreader and just try to add the string "TEST" to my image, it works. Anyone have any ideas? Thanks in advance.
And for those wondering what the function convertToG4tiff is, its explained here
Oh, and the contents of the text file is just the code from another project that I've made.
VB.NET:
Public Function AddCode() As Boolean
Try
enParams.Param(0) = New EncoderParameter(Encoder.Compression, EncoderValue.CompressionCCITT4)
tiff = Image.FromFile("C:\TestTIFF.tif")
Dim tempBM As New Bitmap(1080, 1778, PixelFormat.Format64bppArgb)
Using sr As New StreamReader("C:\TextFile.txt")
Dim x As Integer
Dim line As String
Do
x = x + 10
Using g As Graphics = Graphics.FromImage(tempBM)
line = sr.ReadLine
'g.FillRectangle(Brushes.White, New Rectangle(0, 0, tiff.Width, tiff.Height))
g.DrawImage(tiff, 0, 0)
g.DrawString(line, displayFont, Brushes.Black, x, 10)
''test to make sure its reading all the text properly
'Console.WriteLine(line)
End Using
Loop Until line Is Nothing
End Using
tiff.Dispose()
'convert to a Group4 TIFF
tiff = convertToG4tiff(tempBM)
'save
tiff.Save("C:\TestTiffFinal.tif", tifCodec, enParams)
tiff.Dispose()
Return True
Catch ex As Exception
MsgBox("Error Creating TIFF", MsgBoxStyle.Critical, "Error Creating Image")
Return False
End Try
End Function
But if I get rid of the loop for the streamreader and just try to add the string "TEST" to my image, it works. Anyone have any ideas? Thanks in advance.
And for those wondering what the function convertToG4tiff is, its explained here
Oh, and the contents of the text file is just the code from another project that I've made.