BCH.BCHTool.parseBCH C# (CSharp) Method

parseBCH() public static method

public static parseBCH ( string path ) : bool
path string
return bool
        public static bool parseBCH(string path)
        {
            // goto 0x80 (skip the PT container header and go straight to the BCH data
            // srcdata[:]=srcdata[0x80:len(srcdata)]
            byte[] input = File.ReadAllBytes(path);
            if (input.Length == 0)
                return false;
            if (BitConverter.ToUInt32(input, 0) != 0x484342) // BCH
                return false;

            // BCH should now be in our data array.
            BCH bch = analyze(path, input);
            if (bch.TextureCount > 0)
            {
                Directory.CreateDirectory(bch.FilePath + "\\" + bch.FileName + "_\\");
            }
            for (int i = 0; i < bch.TextureCount; i++)
            {
                string texname = bch.TexNames[i];
                Bitmap img = parseEntry(bch.Textures[i], bch.data); //pass in texture desc, data

                using (MemoryStream ms = new MemoryStream())
                {
                    //error will throw from here
                    img.Save(ms, ImageFormat.Png);
                    byte[] data = ms.ToArray();
                    File.WriteAllBytes(bch.FilePath + "\\" + bch.FileName + "_\\" + texname + ".png", data);
                }
            }
            return true;
        }