PurplePen.MapUtil.CreateToolboxIcon C# (CSharp) Method

CreateToolboxIcon() public static method

public static CreateToolboxIcon ( Bitmap bm ) : ToolboxIcon
bm System.Drawing.Bitmap
return ToolboxIcon
        public static ToolboxIcon CreateToolboxIcon(Bitmap bm)
        {
            ToolboxIcon icon = new ToolboxIcon();

            for (int x = 0; x < ToolboxIcon.WIDTH; ++x) {
                for (int y = 0; y < ToolboxIcon.HEIGHT; ++y) {
                    icon.SetPixel(x, y, bm.GetPixel(x, y));
                }
            }

            return icon;
        }

Usage Example

Example #1
0
        // Create a point symbol that can be used to put this symbol onto a map inside
        // a box of the given size (in mm).
        public PointSymDef CreateSymdef(Map map, SymColor color, float boxSize)
        {
            Glyph glyph = new Glyph();

            for (int i = 0; i < strokes.Length; ++i)
            {
                strokes[i].AddToMapGlyph(glyph, color, boxSize);
            }
            glyph.ConstructionComplete();

            // Find a free OCAD ID number.
            string symbolId = map.GetFreeSymbolId(800);

            // Create the symdef
            PointSymDef symdef;

            symdef = new PointSymDef("Description: " + this.GetName(Util.CurrentLangName()), symbolId, glyph, false);

            // Create the toolbox image.
            Bitmap bm = new Bitmap(24, 24);

            using (Graphics g = Graphics.FromImage(bm)) {
                g.Clear(Color.White);
                g.SmoothingMode = SmoothingMode.AntiAlias;
                if (kind >= 'T')
                {
                    g.SetClip(new RectangleF(0, 0, bm.Width / 2, bm.Height));
                    Draw(g, Color.Black, new RectangleF(0, bm.Height / 3F, bm.Width * 8F / 3F, bm.Height / 3F));
                    g.SetClip(new RectangleF(bm.Width / 2, 0, bm.Width / 2, bm.Height));
                    Draw(g, Color.Black, new RectangleF(-bm.Width * 5F / 3F, bm.Height / 3F, bm.Width * 8F / 3F, bm.Height / 3F));
                }
                else
                {
                    Draw(g, Color.Black, new RectangleF(0, 0, bm.Width, bm.Height));
                }
            }
            symdef.ToolboxImage = MapUtil.CreateToolboxIcon(bm);

            // Add the symdef to the map.
            map.AddSymdef(symdef);

            return(symdef);
        }
All Usage Examples Of PurplePen.MapUtil::CreateToolboxIcon