public byte[] DumpImage(ImageSize imgSize, string archiveDir)
{
byte[] imgBuff = null;
ImageInfo imgInfo;
if (privateimgList.Exists(img => img.imgSize == imgSize))
imgInfo = privateimgList.Find(img => img.imgSize == imgSize);
else
throw new FileNotFoundException("Image with resolution " + imgSize + " not found");
switch (imgInfo.storageType)
{
case storage.pccSto:
imgBuff = new byte[imgInfo.uncSize];
Buffer.BlockCopy(imageData, imgInfo.offset, imgBuff, 0, imgInfo.uncSize);
break;
case storage.arcCpr:
case storage.arcUnc:
string archivePath = FullArcPath;
if (String.IsNullOrEmpty(archivePath))
archivePath = GetTexArchive(archiveDir);
if (!File.Exists(archivePath))
throw new FileNotFoundException("Texture archive not found in " + archivePath);
using (FileStream archiveStream = File.OpenRead(archivePath))
{
if (imgInfo.storageType == storage.arcCpr)
{
SaltLZOHelper lzohelp = new SaltLZOHelper();
imgBuff = lzohelp.DecompressTex(archiveStream, imgInfo.offset, imgInfo.uncSize, imgInfo.cprSize);
}
else
{
archiveStream.Seek(imgInfo.offset, SeekOrigin.Begin);
imgBuff = new byte[imgInfo.uncSize];
archiveStream.Read(imgBuff, 0, imgBuff.Length);
}
}
break;
default:
throw new FormatException("Unsupported texture storage type");
}
return imgBuff;
}