/// <summary>
 /// Sets style information.
 /// </summary>
 /// <param name="image"></param>
 public void Set(Image2D image)
 {
     image.MaxZoom = image.MaxZoom;
     image.MinZoom = image.MinZoom;
 }
 /// <summary>
 /// Adds a new style and returns it's index.
 /// </summary>
 /// <param name="image"></param>
 /// <param name="layer"></param>
 /// <returns></returns>
 public ushort AddStyle(Image2D image, int layer)
 {
     Image2DStyle newStyle = Image2DStyle.From(image, layer);
     int indexOf = this.ImageStyles.IndexOf(newStyle);
     if (indexOf < 0)
     { // the style is not found yet.
         indexOf = this.ImageStyles.Count;
         this.ImageStyles.Add(newStyle);
     }
     return (ushort)indexOf;
 }
 /// <summary>
 /// Extracts style information.
 /// </summary>
 /// <param name="image"></param>
 /// <returns></returns>
 public static Image2DStyle From(Image2D image, int layer)
 {
     Image2DStyle newStyle = new Image2DStyle();
     newStyle.MaxZoom = image.MaxZoom;
     newStyle.MinZoom = image.MinZoom;
     newStyle.Layer = layer;
     return newStyle;
 }
        /// <summary>
        /// Adds the image.
        /// </summary>
        /// <returns>The image.</returns>
        /// <param name="layer">Layer.</param>
        /// <param name="minZoom">Minimum zoom.</param>
        /// <param name="maxZoom">Max zoom.</param>
        /// <param name="left">Left.</param>
        /// <param name="top">Top.</param>
        /// <param name="right">Right.</param>
        /// <param name="bottom">Bottom.</param>
        /// <param name="imageData">Image data.</param>
        public override uint AddImage(int layer, float minZoom, float maxZoom, double left, double top, double right, double bottom,
                             byte[] imageData, object tag)
        {
            if (imageData == null)
                throw new ArgumentNullException("imageData");

            Image2D image = new Image2D(left, top, bottom, right, imageData, minZoom, maxZoom);
            image.Tag = tag;

            lock (_primitives)
            {

                uint id = _nextId;
                _nextId++;

                this.AddPrimitive(layer, id, image);
                return id;
            }
        }