Font marker and marker direction

May 18, 2010 at 8:10 AM
Hi, I want to creating marker from font. For example "Ý" char for Wingdings font type. How can I do? I tried but I have a two problems. 1) Marker edges are cut after the marker rotated 2) The place of markers seems at different place on the map.(http://img443.imageshack.us/img443/8595/markerov.png) Best Regards
Coordinator
May 18, 2010 at 8:46 AM

"Marker edges are cut after the marker rotated' ?

May 18, 2010 at 9:06 AM
For example http://img80.imageshack.us/img80/5176/35837125.png
Coordinator
May 18, 2010 at 10:02 AM

and what's wrong with that?

May 18, 2010 at 11:34 AM
Edited May 18, 2010 at 11:35 AM
If you look at the first picture you can see the markers completly but at the second picture you cann't see the completly. You can see just some parts of marker.
Coordinator
May 18, 2010 at 11:40 AM

mm. a green circle ;} so how do you rotate it?

May 18, 2010 at 11:58 AM
Edited May 18, 2010 at 12:02 PM
        public Bitmap CreateMarker(string MarkerFont, float MarkerFontSize, string MarkerChar, float Angle)
        {
            Bitmap objBmpImage = new Bitmap(1, 1);
            GraphicsPath pth = new GraphicsPath();
            Graphics objGraphics = Graphics.FromImage(objBmpImage);
            objBmpImage = new Bitmap(objBmpImage, new System.Drawing.Size(Width, Height));
            objGraphics = Graphics.FromImage(objBmpImage);
            //Calculation to size
            Font objFont = new Font(MarkerFont, MarkerFontSize, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
            Width = (int)(objGraphics.MeasureString(MarkerChar, objFont).Height * Math.Abs(Math.Sin(Angle)) + objGraphics.MeasureString(MarkerChar, objFont).Width * Math.Abs(Math.Cos(Angle)));
            Height = (int)(objGraphics.MeasureString(MarkerChar, objFont).Height * Math.Abs(Math.Cos(Angle)) + objGraphics.MeasureString(MarkerChar, objFont).Width * Math.Abs(Math.Sin(Angle)));
            this.Size = new System.Drawing.Size(Width, Height);

            pth.AddString(MarkerChar, new FontFamily(MarkerFont), (int)FontStyle.Regular, MarkerFontSize, new System.Drawing.Point(0, 0), StringFormat.GenericDefault);
            objGraphics.SmoothingMode = SmoothingMode.AntiAlias;
            objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias;

            objGraphics.TranslateTransform(Width / 2, Height / 2);
            objGraphics.RotateTransform(Angle);
            objGraphics.TranslateTransform(-Width / 2, -Height / 2);
            //Halo
            Pen p = new Pen(Color.Transparent, 5);
            objGraphics.DrawPath(p, pth);
            objGraphics.FillPath(Brushes.DarkGreen, pth);
            objGraphics.Dispose();
            return objBmpImage;
        }

        public override void OnRender(Graphics g)
        {
            Bitmap MarkerBitmap = CreateMarker("Wingdings", 25, "Ý", 230);
            //Bitmap MarkerBitmap = CreateMarker(Pair.Value.MarkerFont,Pair.Value.MarkerFontSize,Pair.Value.Marker,Ang);
            g.DrawImageUnscaled(MarkerBitmap, LocalPosition.X, LocalPosition.Y);
        }
Coordinator
May 18, 2010 at 12:46 PM
Edited May 18, 2010 at 12:51 PM

creating new bitmap each frame is quite insane and kill for memory ;}

just transform onrender:

g.TranslateTransform(Width / 2, Height / 2);

g.RotateTransform(Angle);

g.DrawImageUnscaled(MarkerBitmap, LocalPosition.X, LocalPosition.Y);

g.ResetTransform();

May 18, 2010 at 1:03 PM

I have allready known what you told but can you explain me is there another way to do this? I want use a character as a marker. Also I tried the code what you gave me, but the markers doesnt seem at real place and when the change center of the map, the places of the markers change at the same time.

Coordinator
May 18, 2010 at 1:12 PM

let me experiment on this...

Coordinator
May 18, 2010 at 5:56 PM

check transport demo, i've added bearing with rotation

May 20, 2010 at 8:57 AM
Sorry, for late feedback. First of all, thank you. I will do feedback, after reviewing detailed.