예제 #1
0
파일: ReadMap.cs 프로젝트: Pete107/Mir2
        private void LoadMapCellsv0(byte[] fileBytes)
        {
            int offSet = 0;
            Width = BitConverter.ToInt16(fileBytes, offSet);
            offSet += 2;
            Height = BitConverter.ToInt16(fileBytes, offSet);
            Cells = new Cell[Width, Height];

            offSet = 52;

            clippingZone = new Bitmap(Width, Height);

            LockBitmap BitLock = new LockBitmap(clippingZone);
            BitLock.LockBits();

            for (int x = 0; x < Width; x++)
                for (int y = 0; y < Height; y++)
                {
                    if (Cells[x, y] == null)
                        BitLock.SetPixel(x, y, Color.WhiteSmoke);

                    if ((BitConverter.ToInt16(fileBytes, offSet) & 0x8000) != 0)
                        BitLock.SetPixel(x, y, Color.Black);

                    offSet += 2;

                    if ((BitConverter.ToInt16(fileBytes, offSet) & 0x8000) != 0)
                        BitLock.SetPixel(x, y, Color.Black);

                    offSet += 10;
                }
            BitLock.UnlockBits();
            clippingZone.Dispose();
        }
예제 #2
0
        private void LoadMapCellsv0(byte[] fileBytes)
        {
            int offSet = 0;

            Width   = BitConverter.ToInt16(fileBytes, offSet);
            offSet += 2;
            Height  = BitConverter.ToInt16(fileBytes, offSet);
            Cells   = new Cell[Width, Height];

            offSet = 52;

            clippingZone = new Bitmap(Width, Height);

            LockBitmap BitLock = new LockBitmap(clippingZone);

            BitLock.LockBits();

            for (int x = 0; x < Width; x++)
            {
                for (int y = 0; y < Height; y++)
                {
                    if (Cells[x, y] == null)
                    {
                        BitLock.SetPixel(x, y, Color.WhiteSmoke);
                    }

                    if ((BitConverter.ToInt16(fileBytes, offSet) & 0x8000) != 0)
                    {
                        BitLock.SetPixel(x, y, Color.Black);
                    }

                    offSet += 2;

                    if ((BitConverter.ToInt16(fileBytes, offSet) & 0x8000) != 0)
                    {
                        BitLock.SetPixel(x, y, Color.Black);
                    }

                    offSet += 10;
                }
            }
            BitLock.UnlockBits();
            clippingZone.Dispose();
        }
예제 #3
0
파일: ReadMap.cs 프로젝트: cpp1992/Emerald
        public void Load()
        {
            try
            {
                if (File.Exists(Path.Combine("Maps", mapFile + ".map")))
                {
                    byte[] fileBytes = File.ReadAllBytes(Path.Combine("Maps", mapFile + ".map"));

                    int offSet = 0;
                    Width        = BitConverter.ToInt32(fileBytes, offSet);
                    offSet      += 4;
                    Height       = BitConverter.ToInt32(fileBytes, offSet);
                    offSet      += 4;
                    clippingZone = new Bitmap(Width, Height);

                    LockBitmap BitLock = new LockBitmap(clippingZone);
                    BitLock.LockBits();

                    for (int y = 0; y < Height; y++)
                    {
                        for (int x = 0; x < Width; x++)
                        {
                            if (!BitConverter.ToBoolean(fileBytes, offSet))
                            {
                                BitLock.SetPixel(x, y, Color.Black);
                                offSet++;
                                continue;
                            }
                            BitLock.SetPixel(x, y, Color.WhiteSmoke);
                            offSet += 13;
                        }
                    }

                    BitLock.UnlockBits();
                    //clippingZone.Dispose();
                }
            }

            catch (Exception) { }

            VisualizerGlobal.ClippingMap = clippingZone;
        }