KFreonLib.Textures.ME2Texture2D.DumpImage C# (CSharp) Method

DumpImage() public method

public DumpImage ( ImageSize imgSize, string archiveDir ) : byte[]
imgSize AmaroK86.ImageFormat.ImageSize
archiveDir string
return byte[]
        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;
        }

Same methods

ME2Texture2D::DumpImage ( string strImgSize, string archiveDir = null, string fileName = null ) : void