Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

IImageTileSource.CanDisposeSourceImage Property

Returns the value that indicates whether to dispose source image objects that are used to generate tiles.

Namespace: DevExpress.XtraMap

Assembly: DevExpress.XtraMap.v24.2.dll

NuGet Package: DevExpress.Win.Map

#Declaration

bool CanDisposeSourceImage { get; }

#Property Value

Type Description
Boolean

true if all the resources allocated to the source images should be released; otherwise, false.

#Example

This example shows how to use an ImageTileDataProvider instance to generate map tiles.

using DevExpress.XtraMap;
using System;
using System.Drawing;
using System.Windows.Forms;

namespace InMemoryTileProvider {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e) {
            ImageTileDataProvider tileDataProvider = new ImageTileDataProvider();
            tileDataProvider.TileSource = new SimpleTileGenerator();
            this.imageLayer1.DataProvider = tileDataProvider;
        }
        public class SimpleTileGenerator : IImageTileSource {
            readonly Font font = new Font("Arial", 10);
            Random rnd = new Random();
            public bool CanDisposeSourceImage => true;
            public string Name => nameof(SimpleTileGenerator);
            public Image GetImage(int x, int y, int level, Size size) {
                Bitmap bitmap = new Bitmap(size.Width, size.Height);
                using (Graphics gr = Graphics.FromImage(bitmap)) {
                    gr.Clear(Color.FromArgb(128, rnd.Next(255),
                            rnd.Next(255), rnd.Next(255)));
                    gr.DrawString(string.Format("{0} {1} {2}", x, y, level),
                           font, Brushes.Black, new PointF(5, 5));
                }
                return bitmap;
            }
        }
    }
}
See Also