Public Function FSHtoDDS(ByVal strFSHFile As String) As String
Dim BR As IO.BinaryReader = New IO.BinaryReader(IO.File.Open(strFSHFile, IO.FileMode.Open))
Dim BW As IO.BinaryWriter = New IO.BinaryWriter(IO.File.Open(strDDS, IO.FileMode.CreateNew))
Dim intWidth, intHeight As Integer, ByteArray() As Byte
Dim strDDS As String
strDDS = strAppPath + "temp.dds" 'strAppPath contains application path
BR.BaseStream.Seek(36, IO.SeekOrigin.Begin)
intWidth = BR.ReadInt16 'read width of that fsh image
intHeight = BR.ReadInt16 'read height of that fsh image
ReDim ByteArray(intWidth * intHeight - 1) 'Redim the array so that it can hold the entire bytes
BR.BaseStream.Seek(48, IO.SeekOrigin.Begin)
ByteArray = BR.ReadBytes(intWidth * intHeight)
BR.Close()
Dim DXT5_1 As Byte() = {Asc("D"), Asc("D"), Asc("S"), 32, 124, 0, 0, 0, 7, 16, 8, 0}
Dim DXT5_2(107) As Byte 'We need to fill up the bytes which are not 0
DXT5_2(1) = 2 : DXT5_2(56) = 2 : DXT5_2(60) = 4 : DXT5_2(89) = 16
DXT5_2(64) = Asc("D") : DXT5_2(65) = Asc("X") : DXT5_2(66) = Asc("T") : DXT5_2(67) = Asc("5")
BW.Write(DXT5_1) : BW.Write(intHeight) : BW.Write(intWidth) : BW.Write(DXT5_2)
BW.Write(ByteArray)
BW.Close()
FSHtoDDS = strDDS
End Function