예제 #1
0
        public byte[] RenderMetaTile(MetaTile metatile, ITile tile)
        {
            byte[] data       = RenderTile(metatile);
            Image  image      = ImageHelper.Open(data);
            Size   metaSize   = GetMetaSize(metatile.Z);
            int    metaHeight = metaSize.Height * Size.Height + 2 * MetaBuffer.Height;

            for (int i = 0; i < metaSize.Width; i++)
            {
                for (int j = 0; j < metaSize.Height; i++)
                {
                    int minX = i * Size.Width + MetaBuffer.Width;
                    int maxX = minX + Size.Width;
                    // this next calculation is because image origin is (top, left)
                    int    maxY     = metaHeight - (j * Size.Height + MetaBuffer.Height);
                    int    minY     = maxY - Size.Height;
                    Image  subImage = image.Crop(minX, minY, maxX, maxY);
                    byte[] subdata  = subImage.GetBytes();
                    double x        = metatile.X * MetaSize.Width + i;
                    double y        = metatile.Y * MetaSize.Height + i;

                    var subtile = new Tile(this, x, y, metatile.Z);
                    if (!string.IsNullOrEmpty(WatermarkImage))
                    {
                        subdata = Watermark(subdata).GetBytes();
                    }
                    Cache.Set(subtile, subdata);
                    if (x == tile.X && y == tile.Y)
                    {
                        return(subdata);
                    }
                }
            }
            return(null);
        }
예제 #2
0
 public override byte[] Render(ITile tile)
 {
     if (MetaTile)
     {
         MetaTile metatile = GetMetaTile(tile);
         try
         {
             Cache.Lock(metatile);
             return(Cache.Get(tile) ?? RenderMetaTile(metatile, tile));
         }
         finally
         {
             Cache.Unlock(metatile);
         }
     }
     else
     {
         if (!string.IsNullOrEmpty(WatermarkImage))
         {
             return(Watermark(RenderTile(tile)).GetBytes());
         }
         return(RenderTile(tile));
     }
 }