Beispiel #1
0
        /// <summary>
        /// Read file.
        /// </summary>
        /// <returns>True if succeeded, otherwise false.</returns>
        private bool Read()
        {
            //try
            //{
            // Step through file
            BinaryReader Reader = managedFile.GetReader();

            if (!ReadHeader(Reader))
            {
                return(false);
            }

            Numfiles = Reader.ReadInt32();

            var DataOffsets = new int[Numfiles];

            for (int row = 0; row < Numfiles; row++)
            {
                var offset = Reader.ReadInt32();
                Reader.BaseStream.Position += 4;
                DataOffsets[row]            = offset;
            }
            // DataOffsets[Numfiles] = (int)Reader.BaseStream.Length;

            imgRecord = new MCBitmap[Numfiles];

            this.ReadMinHeightWidth(Reader, DataOffsets);

            for (int row = 0; row < Numfiles; row++)
            {
                if (DataOffsets[row] == 0)
                {
                    InitEmptyBmp(row);
                    continue;
                }

                Reader.BaseStream.Position = DataOffsets[row];
                if (!ReadShpHeader(Reader))
                {
                    return(false);
                }

                var bmp = new MCBitmap();

                if (!ReadShpData(Reader, out bmp))
                {
                    InitEmptyBmp(row);
                    UnityEngine.Debug.Log("Error Reader Header");
                    continue;
                }


                bmp.Name = row.ToString();

                imgRecord[row] = bmp;
            }

            //} catch (Exception e)
            //{
            //    UnityEngine.Debug.Log(e.Message);
            //    managedFile.Close();
            //    return false;
            //}

            managedFile.Close();

            return(true);
        }