CNCMaps.Engine.Rendering.TmpRenderer.GetBounds C# (CSharp) Method

GetBounds() public static method

public static GetBounds ( CNCMaps.Engine.Map.MapTile tile, CNCMaps.FileFormats.TmpFile tmp ) : Rectangle
tile CNCMaps.Engine.Map.MapTile
tmp CNCMaps.FileFormats.TmpFile
return System.Drawing.Rectangle
        public static Rectangle GetBounds(MapTile tile, TmpFile tmp)
        {
            if (tmp == null) return Rectangle.Empty;
            tmp.Initialize();

            if (tile.SubTile >= tmp.Images.Count) return Rectangle.Empty;
            var img = tmp.Images[tile.SubTile];

            int left = tile.Dx * tmp.BlockWidth / 2;
            int top = (tile.Dy - tile.Z) * tmp.BlockHeight / 2;
            int width = tmp.BlockWidth;
            int height = tmp.BlockHeight;
            if (img.HasExtraData) {
                if (img.ExtraX < 0) { left += img.ExtraX; width -= img.ExtraX; }
                if (img.ExtraY < 0) { top += img.ExtraY; height -= img.ExtraY; }
                width = Math.Max(width, img.ExtraWidth);
                height = Math.Max(height, img.ExtraHeight);
            }

            return new Rectangle(left, top, width, height);
        }