Esempio n. 1
0
        public void Validate()
        {
            if (sectionHead.tag != DefaultTagHead)
            {
                TilesetCommon.throwReadError("Header Tag", sectionHead.tag, DefaultTagHead);
            }

            if (sectionHead.length != DefaultSectionSize)
            {
                TilesetCommon.throwReadError("Header Section Size", sectionHead.length, DefaultSectionSize);
            }

            if (pixelWidth != DefaultPixelWidth)
            {
                TilesetCommon.throwReadError("Pixel Width", pixelWidth, DefaultPixelWidth);
            }

            if (pixelHeight % DefaultPixelHeightMultiple != 0)
            {
                throw new System.Exception("Tileset property Pixel Height reads " + pixelHeight +
                                           ". Pixel Height must be a multiple of " + DefaultPixelHeightMultiple + ".");
            }

            if (tagCount != DefaultTagCount)
            {
                TilesetCommon.throwReadError("Header tag count", tagCount, DefaultTagCount);
            }
        }
Esempio n. 2
0
        public void Validate()
        {
            if (ppal.tag != DefaultTagPpal)
            {
                TilesetCommon.throwReadError("PPAL Tag", ppal.tag, DefaultTagPpal);
            }

            if (ppal.length != DefaultPpalSectionSize)
            {
                TilesetCommon.throwReadError("PPAL Section Size", ppal.length, DefaultPpalSectionSize);
            }

            if (head.tag != DefaultTagHead)
            {
                TilesetCommon.throwReadError("PPAL Head Tag", head.tag, DefaultTagHead);
            }

            if (head.length != DefaultHeadSectionSize)
            {
                TilesetCommon.throwReadError("PPAL Head Section Size", head.length, DefaultHeadSectionSize);
            }

            if (tagCount != DefaultTagCount)
            {
                TilesetCommon.throwReadError("PPAL Section Tag Count", tagCount, DefaultTagCount);
            }
        }
Esempio n. 3
0
        private static void ValidatePaletteHeader(SectionHeader paletteHeader)
        {
            if (paletteHeader.tag != TilesetCommon.DefaultTagData)
            {
                TilesetCommon.throwReadError("Palette Header Tag", paletteHeader.tag, TilesetCommon.DefaultTagData);
            }

            if (paletteHeader.length != TilesetCommon.DefaultPaletteHeaderSize)
            {
                TilesetCommon.throwReadError("Palette Header Section Size", paletteHeader.length, TilesetCommon.DefaultPaletteHeaderSize);
            }
        }
Esempio n. 4
0
        private static void ValidateFileSignatureHeader(SectionHeader fileSignatureHeader)
        {
            if (fileSignatureHeader.tag != TagFileSignature)
            {
                TilesetCommon.throwReadError("File Signature", fileSignatureHeader.tag, TagFileSignature);
            }

            if (fileSignatureHeader.length == 0)
            {
                throw new System.Exception("Tileset property File Length reads " +
                                           fileSignatureHeader.length + ", which is too small.");
            }
        }
Esempio n. 5
0
        private static void ValidatePixelHeader(SectionHeader pixelHeader, uint height)
        {
            if (pixelHeader.tag != TilesetCommon.DefaultTagData)
            {
                TilesetCommon.throwReadError("Pixel Header Tag", pixelHeader.tag, TilesetCommon.DefaultTagData);
            }

            uint expectedLength = CalculatePixelHeaderLength(height);

            if (pixelHeader.length != expectedLength)
            {
                TilesetCommon.throwReadError("Pixel Header Length", pixelHeader.length, expectedLength);
            }
        }
Esempio n. 6
0
        // Throw runtime error if provided bitmap does not meet specific tileset requirements
        // Assumes provided tileset is already properly formed to standard bitmap file format
        public static void ValidateTileset(BitmapFile tileset)
        {
            int    DefaultPixelWidth          = 32;
            int    DefaultPixelHeightMultiple = DefaultPixelWidth;
            ushort DefaultBitCount            = 8;

            if (tileset.imageHeader.bitCount != DefaultBitCount)
            {
                TilesetCommon.throwReadError("Bit Depth", tileset.imageHeader.bitCount, DefaultBitCount);
            }

            if (tileset.imageHeader.width != DefaultPixelWidth)
            {
                TilesetCommon.throwReadError("Pixel Width", tileset.imageHeader.width, DefaultPixelWidth);
            }

            if (tileset.imageHeader.height % DefaultPixelHeightMultiple != 0)
            {
                throw new System.Exception("Tileset property Pixel Height reads " + tileset.imageHeader.height +
                                           ". Expected value must be a multiple of " + DefaultPixelHeightMultiple + " pixels");
            }
        }