Esempio n. 1
0
        public bFile 读取b(Stream bFileStream)
        {
            bFile b文件 = new bFile();

            byte[] buff;
            bFileStream.Read(b文件.Hdr, 0, 16);



            //System.Diagnostics.Debug.WriteLine(jis.GetString(b文件.Hdr));
            if (jis.GetString(b文件.Hdr).Substring(0, 6) == "abmp11" || jis.GetString(b文件.Hdr).Substring(0, 6) == "abmp12")
            {
                bFileStream.Read(b文件.bData.Hdr, 0, 16);
                if (jis.GetString(b文件.bData.Hdr).Substring(0, 8) == "abdata10" ||
                    jis.GetString(b文件.bData.Hdr).Substring(0, 8) == "abdata11" ||
                    jis.GetString(b文件.bData.Hdr).Substring(0, 8) == "abdata12" ||
                    jis.GetString(b文件.bData.Hdr).Substring(0, 8) == "abdata13")
                {
                    buff = new byte[4];
                    bFileStream.Read(buff, 0, 4);
                    b文件.bData.offset = BitConverter.ToInt32(buff, 0);

                    b文件.bData.Data = new byte[b文件.bData.offset];
                    bFileStream.Read(b文件.bData.Data, 0, b文件.bData.offset);

                    while (bFileStream.Position < bFileStream.Length - 1)
                    {
                        bImage b图像 = new bImage();
                        bFileStream.Read(b图像.Hdr, 0, 16);
                        System.Diagnostics.Debug.WriteLine(编码.GetString(b图像.Hdr));
                        if (jis.GetString(b图像.Hdr).Substring(0, 9) == "abimage10")
                        {
                            b图像.nData = (byte)bFileStream.ReadByte();
                            for (int i = 0; i < b图像.nData; i++)
                            {
                                bImgData b数据 = new bImgData();
                                bFileStream.Read(b数据.Hdr, 0, 16);

                                //System.Diagnostics.Debug.Write(bFileStream.Position);

                                if (jis.GetString(b数据.Hdr).Substring(0, 10) == "abimgdat14" ||
                                    jis.GetString(b数据.Hdr).Substring(0, 10) == "abimgdat13" ||
                                    jis.GetString(b数据.Hdr).Substring(0, 10) == "abimgdat11")
                                {
                                    buff = new byte[2];
                                    bFileStream.Read(buff, 0, 2);
                                    b数据.NameLen = BitConverter.ToInt16(buff, 0);
                                    b数据.Name    = new byte[b数据.NameLen];
                                    bFileStream.Read(b数据.Name, 0, b数据.NameLen);

                                    bFileStream.Read(buff, 0, 2);
                                    b数据.HashLen = BitConverter.ToInt16(buff, 0);

                                    if (b数据.HashLen != 0)
                                    {
                                        b数据.Hash = new byte[b数据.HashLen];
                                        bFileStream.Read(b数据.Hash, 0, b数据.HashLen);
                                    }

                                    if (jis.GetString(b数据.Hdr).Substring(0, 10) == "abimgdat14")
                                    {
                                        b数据.unkown = new byte[77];
                                        bFileStream.Read(b数据.unkown, 0, b数据.unkown.Length);
                                    }
                                    else if (jis.GetString(b数据.Hdr).Substring(0, 10) == "abimgdat13")
                                    {
                                        b数据.unkown = new byte[13];
                                        bFileStream.Read(b数据.unkown, 0, b数据.unkown.Length);
                                    }
                                    else
                                    {
                                        b数据.unkown = new byte[1];
                                        bFileStream.Read(b数据.unkown, 0, b数据.unkown.Length);
                                    }

                                    buff = new byte[4];
                                    bFileStream.Read(buff, 0, 4);
                                    b数据.DataLen = BitConverter.ToInt32(buff, 0);


                                    System.Diagnostics.Debug.WriteLine(bFileStream.Position);
                                    buff = new byte[b数据.DataLen];
                                    bFileStream.Read(buff, 0, b数据.DataLen);
                                    b数据.Data = new MemoryStream(buff);
                                    System.Diagnostics.Debug.WriteLine(bFileStream.Position);

                                    b图像.DataList.Add(b数据);
                                }
                                else
                                {
                                    throw (new Exception("不是标准的b文件."));
                                }
                            }
                            b文件.ImageList.Add(b图像);
                        }
                        else if (编码.GetString(b图像.Hdr).Substring(0, 9) == "absound10")
                        {
                            b文件.bEnd = new byte[bFileStream.Length - bFileStream.Position + 0x10];
                            bFileStream.Seek(-0x10, SeekOrigin.Current);
                            bFileStream.Read(b文件.bEnd, 0, b文件.bEnd.Length);
                        }
                        else
                        {
                            throw (new Exception("不是标准的b文件."));
                        }
                    }
                }
                else
                {
                    throw (new Exception("不是标准的b文件."));
                }
            }
            else
            {
                throw (new Exception("不是标准的b文件."));
            }

            return(b文件);
        }
Esempio n. 2
0
        public bFile 读取b(Stream bFileStream)
        {
            bFile b文件 = new bFile();
            byte[] buff;
            bFileStream.Read(b文件.Hdr, 0, 16);

            //System.Diagnostics.Debug.WriteLine(jis.GetString(b文件.Hdr));
            if (jis.GetString(b文件.Hdr).Substring(0, 6) == "abmp11" || jis.GetString(b文件.Hdr).Substring(0, 6) == "abmp12")
            {
                bFileStream.Read(b文件.bData.Hdr, 0, 16);
                if (jis.GetString(b文件.bData.Hdr).Substring(0, 8) == "abdata10" ||
                    jis.GetString(b文件.bData.Hdr).Substring(0, 8) == "abdata11" ||
                    jis.GetString(b文件.bData.Hdr).Substring(0, 8) == "abdata12" ||
                    jis.GetString(b文件.bData.Hdr).Substring(0, 8) == "abdata13")
                {
                    buff = new byte[4];
                    bFileStream.Read(buff, 0, 4);
                    b文件.bData.offset = BitConverter.ToInt32(buff, 0);

                    b文件.bData.Data = new byte[b文件.bData.offset];
                    bFileStream.Read(b文件.bData.Data, 0, b文件.bData.offset);

                    while (bFileStream.Position < bFileStream.Length - 1)
                    {
                        bImage b图像 = new bImage();
                        bFileStream.Read(b图像.Hdr, 0, 16);
                        System.Diagnostics.Debug.WriteLine(编码.GetString(b图像.Hdr));
                        if (jis.GetString(b图像.Hdr).Substring(0, 9) == "abimage10")
                        {
                            b图像.nData = (byte)bFileStream.ReadByte();
                            for (int i = 0; i < b图像.nData; i++)
                            {
                                bImgData b数据 = new bImgData();
                                bFileStream.Read(b数据.Hdr, 0, 16);

                                //System.Diagnostics.Debug.Write(bFileStream.Position);

                                if (jis.GetString(b数据.Hdr).Substring(0, 10) == "abimgdat14" ||
                                    jis.GetString(b数据.Hdr).Substring(0, 10) == "abimgdat13" ||
                                    jis.GetString(b数据.Hdr).Substring(0, 10) == "abimgdat11")
                                {
                                    buff = new byte[2];
                                    bFileStream.Read(buff, 0, 2);
                                    b数据.NameLen = BitConverter.ToInt16(buff, 0);
                                    b数据.Name = new byte[b数据.NameLen];
                                    bFileStream.Read(b数据.Name, 0, b数据.NameLen);

                                    bFileStream.Read(buff, 0, 2);
                                    b数据.HashLen = BitConverter.ToInt16(buff, 0);

                                    if (b数据.HashLen != 0)
                                    {
                                        b数据.Hash = new byte[b数据.HashLen];
                                        bFileStream.Read(b数据.Hash, 0, b数据.HashLen);
                                    }

                                    if (jis.GetString(b数据.Hdr).Substring(0, 10) == "abimgdat14")
                                    {
                                        b数据.unkown = new byte[77];
                                        bFileStream.Read(b数据.unkown, 0, b数据.unkown.Length);
                                    }
                                    else if (jis.GetString(b数据.Hdr).Substring(0, 10) == "abimgdat13")
                                    {
                                        b数据.unkown = new byte[13];
                                        bFileStream.Read(b数据.unkown, 0, b数据.unkown.Length);
                                    }
                                    else
                                    {
                                        b数据.unkown = new byte[1];
                                        bFileStream.Read(b数据.unkown, 0, b数据.unkown.Length);
                                    }

                                    buff = new byte[4];
                                    bFileStream.Read(buff, 0, 4);
                                    b数据.DataLen = BitConverter.ToInt32(buff,0);

                                    System.Diagnostics.Debug.WriteLine(bFileStream.Position);
                                    buff = new byte[b数据.DataLen];
                                    bFileStream.Read(buff, 0, b数据.DataLen);
                                    b数据.Data = new MemoryStream(buff);
                                    System.Diagnostics.Debug.WriteLine(bFileStream.Position);

                                    b图像.DataList.Add(b数据);
                                }
                                else
                                {
                                    throw (new Exception("不是标准的b文件."));
                                }

                            }
                            b文件.ImageList.Add(b图像);
                        }
                        else if (编码.GetString(b图像.Hdr).Substring(0, 9) == "absound10")
                        {
                            b文件.bEnd = new byte[bFileStream.Length - bFileStream.Position + 0x10];
                            bFileStream.Seek(-0x10, SeekOrigin.Current);
                            bFileStream.Read(b文件.bEnd, 0, b文件.bEnd.Length);
                        }
                        else
                        {
                            throw (new Exception("不是标准的b文件."));
                        }

                    }

                }
                else
                {
                    throw (new Exception("不是标准的b文件."));
                }
            }
            else
            {
                throw (new Exception("不是标准的b文件."));
            }

            return b文件;
        }