public void DumpImageData(ImageInfo imgInfo, string archiveDir = null, string fileName = null)
{
if (fileName == null)
{
fileName = texName + "_" + imgInfo.imgSize + ".bin";
}
byte[] imgBuffer;
switch (imgInfo.storageType)
{
case storage.pccSto:
imgBuffer = new byte[imgInfo.uncSize];
Buffer.BlockCopy(imageData, imgInfo.offset, imgBuffer, 0, imgInfo.uncSize);
break;
case storage.arcCpr:
case storage.arcUnc:
string archivePath = FullArcPath;
if (String.IsNullOrEmpty(archivePath))
GetTexArchive(archiveDir);
if (!File.Exists(archivePath))
{
throw new FileNotFoundException("Texture archive not found in " + archivePath);
}
using (FileStream archiveStream = File.OpenRead(archivePath))
{
//archiveStream.Seek(imgInfo.offset, SeekOrigin.Begin);
if (imgInfo.storageType == storage.arcCpr)
{
SaltLZOHelper lzohelp = new SaltLZOHelper();
imgBuffer = lzohelp.DecompressTex(archiveStream, imgInfo.offset, imgInfo.uncSize, imgInfo.cprSize);
}
else
{
archiveStream.Seek(imgInfo.offset, SeekOrigin.Begin);
imgBuffer = new byte[imgInfo.uncSize];
archiveStream.Read(imgBuffer, 0, imgBuffer.Length);
}
}
break;
default:
throw new FormatException("Unsupported texture storage type");
}
using (FileStream outputImg = new FileStream(fileName, FileMode.Create, FileAccess.Write))
outputImg.Write(imgBuffer, 0, imgBuffer.Length);
}