"Ken Dopierala Jr." <kd*********@wi.rr.com> wrote in
news:#R*************@TK2MSFTNGP10.phx.gbl:
Hi,
I'm reading the header file of a PCX image and I need to convert 2
bytes
to a short. How would I go about doing this? I know that they are
bytes 8 & 9 in my byte array. I'm not sure how to take those two and
convert them into a short though. In C I would just use a union and
assign them accordingly. Thanks! Ken.
Why don't you just define a structure that is the same as the PCX header
and just import the whole thing in one shot?
'/////
'Define the PCX header structure
Public Structure PcxHeader
Public Mfg As Byte
Public Version As Byte
Public RLE As Byte
Public Bpp As Byte
Public XMin As Short
Public YMin As Short
Public XMax As Short
Public YMax As Short
Public HDpi As Short
Public VDpi As Short
<VBFixedString(48)> Public Palette As String
Public RFU1 As Byte
Public BitPlanes As Byte
Public VMem As Short
Public PaletteType As Short
Public HScreen As Short
Public VScreen As Short
<VBFixedString(54)> Public RFU As String
End Structure
'This function reads it in a returns it.
Private Function GetPcxHeader(ByVal vFile As String) As PcxHeader
Dim pheader As PcxHeader
Dim fHandle As Integer = FreeFile()
FileOpen(fHandle, vFile, OpenMode.Random, OpenAccess.Read,
OpenShare.Shared)
FileGet(fHandle, pheader)
FileClose(fHandle)
Return pheader
End Function
'////////
Chris