Shapefile Icon BMPs: Cannot display the colour black

Jan 14, 2013 at 2:27 PM

Hi there,

I have a very odd problem: I have a shapefile of points which I have created with the following code:

    MapWinGIS.Shapefile shp = new MapWinGIS.Shapefile();      

    shp.CreateNew("pointImages.shp", MapWinGIS.ShpfileType.SHP_POINT);           

    int shapeIndex = 0;

    string[] iconsRaw = System.IO.Directory.GetFiles("Icons\\Large_Icons");           

    string[] icons = new string[iconsRaw.Length];           

    for (int i = 0; i < iconsRaw.Length; ++i)           

    {               

        icons[i] = System.IO.Path.GetFileNameWithoutExtension(iconsRaw[i]);           

    }

    int fieldIndex = 0;           

    MapWinGIS.Field name = new MapWinGIS.Field();            

    MapWinGIS.Field icon = new MapWinGIS.Field();           

    name.Name = "Name";            

    icon.Name = "Icon";           

    name.Type = MapWinGIS.FieldType.STRING_FIELD;            

    icon.Type = MapWinGIS.FieldType.STRING_FIELD;           

    name.Width = 20;           

    icon.Width = 20;           

    shp.EditInsertField(name, ref fieldIndex, this);           

    fieldIndex++;           

    shp.EditInsertField(icon, ref fieldIndex, this);           

    shp.StartEditingShapes(true, this);           

    shp.DefaultDrawingOptions.Visible = true;          

    string name = "Some name";

    MapWinGIS.Shape thenewshape = new MapWinGIS.Shape();            

    thenewshape.ShapeType = MapWinGIS.ShpfileType.SHP_POINT;            

    MapWinGIS.Point p = new MapWinGIS.Point();                   

    p.x = someXValue                    

    p.y = someYValue;                   

    p.Z = 0;                   

    int temp = 0;                   

    thenewshape.InsertPoint(p, ref temp);                   

    string iconVal = "No_Signal";                   

    shp.EditInsertShape(thenewshape, ref shapeIndex);                   

    shp.EditCellValue(0, shapeIndex, name);                    

    shp.EditCellValue(1, shapeIndex, iconval);

    shp.StopEditingShapes(true, true, this);

 

Elsewhere in my code, I load the pre-created shapefile like this:

MapWinGIS.Shapefile iconSymbols = new MapWinGIS.Shapefile();iconSymbols.Open(path, this);


int detailedSignalMin = 300;

int detailedSignalMax = 600;

int symbolLayerHandle = DetailedMap.AddLayer(iconSymbols, true);

DetailedMap.set_LayerMinVisibleScale(symbolLayerHandle, detailedSignalMin);

DetailedMap.set_LayerMaxVisibleScale(symbolLayerHandle, detailedSignalMax);

DetailedMap.set_LayerDynamicVisibility(symbolLayerHandle, true);

if(System.IO.Directory.Exists(MyProject.Properties.Settings.Default.LargeIconDirectory))

{   

    string[] files = System.IO.Directory.GetFiles(MyProject.Properties.Settings.Default.LargeIconDirectory);   

    int fieldIndex = iconSymbols.Table.get_FieldIndexByName("Icon");   

    HashSet<string> names = new HashSet<string>();   

    for (int i = 0; i < iconSymbols.Table.NumRows; i++)   

    {       

        names.Add(iconSymbols.Table.get_CellValue(fieldIndex, i).ToString());   

    }   

    foreach (string file in files)   

    {       

        string iconname = System.IO.Path.GetFileNameWithoutExtension(file);       

        if (System.IO.Path.GetExtension(file).ToLower() == ".bmp" && names.Contains(iconname))       

        {           

            MapWinGIS.Image img = new MapWinGIS.Image();           

            if (img.Open(file, MapWinGIS.ImageType.USE_FILE_EXTENSION, true, null))           

            {               

                MapWinGIS.ShapefileCategory ct = iconSymbols.Categories.Add(iconname); 

                ct.Expression = "[Icon] = \"" + iconname + "\"";       

                ct.DrawingOptions.PointType = MapWinGIS.tkPointSymbolType.ptSymbolPicture;   

                ct.DrawingOptions.Picture = img;           

            }       

        }   

    }   

    iconSymbols.Categories.ApplyExpressions();

}

 

The icons are displayed on the map, everything relating to the mechanics of dynamically displaying the icons is fine.  The problem is that every part of the bitmap image file No_Signal.bmp which is coloured black refuses to display.  The bits which are in colour are fine.  Does anyone have any idea why this might be the case?

 

Thanks,

Rik