// non-allocation image generator
        public static Bitmap GetBitmapLayerAcre(FieldItemLayer layer, int x0, int y0, int scale, int[] acre1, int[] acreScale, Bitmap dest, int transparency = -1)
        {
            var w = layer.GridWidth;
            var h = layer.GridHeight;

            LoadPixelsFromLayer(layer, x0, y0, w, acre1);
            w *= scale;
            h *= scale;
            ImageUtil.ScalePixelImage(acre1, acreScale, w, h, scale);

            if (transparency >> 24 != 0xFF)
            {
                ImageUtil.SetAllTransparencyTo(acreScale, transparency);
            }

            // draw symbols over special items now?
            DrawDirectionals(acreScale, layer, w, x0, y0, scale);

            // Slap on a grid
            DrawGrid(acreScale, w, h, scale);

            // Return final data
            ImageUtil.SetBitmapData(dest, acreScale);
            return(dest);
        }
Exemple #2
0
 public static Bitmap CreateMap(TerrainLayer mgr, int scale, int x, int y, int[] scale1, int[] scaleX, Bitmap map)
 {
     CreateMap(mgr, scale1);
     ImageUtil.ScalePixelImage(scale1, scaleX, map.Width, map.Height, scale);
     ImageUtil.SetBitmapData(map, scaleX);
     return(DrawReticle(map, mgr, x, y, scale));
 }
Exemple #3
0
        public static Bitmap GetAcre(MapView m, Font f, int[] scale1, int[] scaleX, Bitmap acre, int index, byte tbuild, byte tterrain)
        {
            int mx = m.X / 2;
            int my = m.Y / 2;

            SetAcreTerrainPixels(mx, my, m.Map.Terrain, scale1, scaleX, m.TerrainScale);

            const int grid1 = unchecked ((int)0xFF888888u);
            const int grid2 = unchecked ((int)0xFF666666u);

            ImageUtil.SetBitmapData(acre, scaleX);

            using var gfx = Graphics.FromImage(acre);

            gfx.DrawAcrePlaza(m.Map.Terrain, mx, my, (ushort)m.Map.PlazaX, (ushort)m.Map.PlazaY, m.TerrainScale, tbuild);

            var buildings = m.Map.Buildings;
            var t         = m.Map.Terrain;

            for (var i = 0; i < buildings.Count; i++)
            {
                var b = buildings[i];
                t.GetBuildingRelativeCoordinates(mx, my, m.TerrainScale, b.X, b.Y, out var x, out var y);

                var pen = index == i ? Selected : Others;
                if (tbuild != byte.MaxValue)
                {
                    var orig = ((SolidBrush)pen).Color;
                    pen = new SolidBrush(Color.FromArgb(tbuild, orig));
                }
                DrawBuilding(gfx, null, m.TerrainScale, pen, x, y, b, Text);
            }

            ImageUtil.GetBitmapData(acre, scaleX);
            ItemLayerSprite.DrawGrid(scaleX, acre.Width, acre.Height, m.AcreScale, grid1);
            ItemLayerSprite.DrawGrid(scaleX, acre.Width, acre.Height, m.TerrainScale, grid2);
            ImageUtil.SetBitmapData(acre, scaleX);

            foreach (var b in buildings)
            {
                t.GetBuildingRelativeCoordinates(mx, my, m.TerrainScale, b.X, b.Y, out var x, out var y);
                if (!t.IsWithinGrid(m.TerrainScale, x, y))
                {
                    continue;
                }
                var name = b.BuildingType.ToString();
                gfx.DrawString(name, f, Text, new PointF(x, y - (m.TerrainScale * 2)), BuildingTextFormat);
            }

            if (tterrain != 0)
            {
                DrawTerrainTileNames(mx, my, gfx, t, f, m.TerrainScale, tterrain);
            }

            return(acre);
        }
 public static Bitmap GetBitmapLayer(FieldItemLayer layer, int x, int y, int[] data, Bitmap dest, int transparency = -1)
 {
     LoadBitmapLayer(layer.Tiles, data, layer.MapWidth, layer.MapHeight);
     if (transparency >> 24 != 0xFF)
     {
         ImageUtil.SetAllTransparencyTo(data, transparency);
     }
     ImageUtil.SetBitmapData(dest, data);
     return(DrawViewReticle(dest, layer, x, y));
 }
Exemple #5
0
        public static Bitmap CreateMap(TerrainLayer mgr, int[] scale1, int[] scaleX, Bitmap map, int scale, int acreIndex = -1)
        {
            CreateMap(mgr, scale1);
            ImageUtil.ScalePixelImage(scale1, scaleX, map.Width, map.Height, scale);
            ImageUtil.SetBitmapData(map, scaleX);

            if (acreIndex < 0)
            {
                return(map);
            }

            var acre = MapGrid.Acres[acreIndex];
            var x    = acre.X * mgr.GridWidth;
            var y    = acre.Y * mgr.GridHeight;

            return(DrawReticle(map, mgr, x, y, scale));
        }
Exemple #6
0
 public static Bitmap GetBitmapLayer(FieldItemLayer layer, int x, int y, int[] data, Bitmap dest)
 {
     LoadBitmapLayer(layer.Tiles, data, layer.MapWidth, layer.MapHeight);
     ImageUtil.SetBitmapData(dest, data);
     return(DrawViewReticle(dest, layer, x, y));
 }