J
j_dublevay
Guest
I need to read a pure binary file into a binary array, arranged as 16 rows of 256 columns.
I'm reading the file like this:
Module Common
Public Sub LoadFontFile()
Dim fullFilename As String
Dim appdataPath As String
appdataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\6847 font Editor"
fullFilename = appdataPath & "sampleFont.bin"
Try
Form1.fontFileBytes = My.Computer.FileSystem.ReadAllBytes(fullFilename)
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub
End Module
and am then trying to load it into the array, as below...
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
'Dim rows As Byte
'Dim cols As Byte
Call LoadFontFile()
'For rows = 0 To 15
' For cols = 0 To 255
' fontArray(rows, cols) = fontFileBytes.readbyte()
' Next
'Next
fontArray = GetStreamAsByteArray(fontFileBytes)
End Sub
Private Function GetStreamAsByteArray(ByVal stream As MemoryStream) As Byte()
Return stream.ToArray()
End Function
As you can see, I'd already tried to use the stream.ToArray functionality, but I get the error that Byte() cannot be converted to MemoryStream. If I define fontFileBytes as a MemoryStream, it tells me that MemoryStream() cannot be converted to MemoryStream.
I need to represent this data as an X-Y array ideally, so that I can then remap it prior to editing. It's an old 8-bit font representation, and each character is represented as 16 bytes in 1 column - so the first character is composed of file positions 0, 256, 512, 768 etc...
Cheers, John
Continue reading...
I'm reading the file like this:
Module Common
Public Sub LoadFontFile()
Dim fullFilename As String
Dim appdataPath As String
appdataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\6847 font Editor"
fullFilename = appdataPath & "sampleFont.bin"
Try
Form1.fontFileBytes = My.Computer.FileSystem.ReadAllBytes(fullFilename)
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub
End Module
and am then trying to load it into the array, as below...
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
'Dim rows As Byte
'Dim cols As Byte
Call LoadFontFile()
'For rows = 0 To 15
' For cols = 0 To 255
' fontArray(rows, cols) = fontFileBytes.readbyte()
' Next
'Next
fontArray = GetStreamAsByteArray(fontFileBytes)
End Sub
Private Function GetStreamAsByteArray(ByVal stream As MemoryStream) As Byte()
Return stream.ToArray()
End Function
As you can see, I'd already tried to use the stream.ToArray functionality, but I get the error that Byte() cannot be converted to MemoryStream. If I define fontFileBytes as a MemoryStream, it tells me that MemoryStream() cannot be converted to MemoryStream.
I need to represent this data as an X-Y array ideally, so that I can then remap it prior to editing. It's an old 8-bit font representation, and each character is represented as 16 bytes in 1 column - so the first character is composed of file positions 0, 256, 512, 768 etc...
Cheers, John
Continue reading...