Using custom images for points causes very slow unloading

Aug 12, 2011 at 4:45 PM

I have a project were I just added custom images to my point features and I have noticed that my application is very slow to unload now.  I assume it has to do with the large number of custom images.  My point shapefile contains about 900 points and each one was being assigned its own image (even thought most of them were the same) using:

                Map1.set_UDPointType(gCarHdl, image)
                Map1.set_ShapeLayerPointSize(gCarHdl, 1)
                Map1.set_ShapeLayerPointType(gCarHdl, MapWinGIS.tkPointType.ptUserDefined)

When I close my app, it takes about 10 seconds to close.  Removing this feature allows it to close normally.

I then noticed there was an imagelist functionality that might be more efficient, so I used that code in my form's load event to add all potential images to the imagelist and then just reference the image's index when I draw the point.  Problem is, I have 1200 potential images.  For testing purposes, i randomly generated an index between 1 and 10 during the drawing event, but I still saw the issue on closing.  So I assume the issue is related to how many images I have in my list, not the ones I am using.  Which makes sense.  I did notice this option was worse than the first which also makes sense since there were only 900 images in the first attempt and 1200 in this one.

The next thing I want to try is to only add images that are in use (which I think I can do and it may reduce this list to 100 or so).

Am I thinking of this right?

Thanks,

Eric

Developer
Aug 13, 2011 at 5:14 PM

First of all I would suggest to use newer API members (in case you are using 4.8 version). It can be something like this:

for (int i = 0; i < numImages; i++) {

MapWinGIS.Shapefile category = shapefile.Categories.Add("Name " + i.ToString());
        category.DrawingOtions.PointType = ptPicture;
category.DrawingOptions.Picture = someImage;
        category.Expression = "[SomeField] = someValue";
}
shapefile.Categories.ApplyExpressions();

Some more info on ShapeDrawingOptions class: http://mapwingis.codeplex.com/wikipage?title=Class%20schemes