예제 #1
0
        /// <summary>
        /// Function to rotate the marker drawing
        /// </summary>
        /// <param name="marker">Marker from which we want to make the shape</param>
        /// <returns>Bitmap with marker drawing rotated</returns>
        static public Bitmap GetNoTextBitmap(CustomOldGmapMarker marker)
        {
            Bitmap bmp;

            //We will take a different starting image depending on whether it is a surface vehicle, plane or undetermined
            if (marker.emitter == "car")
            {
                bmp = (Bitmap)Image.FromFile(System.IO.Path.Combine(directory, "Markers", "OldCarIco.png"));
            }
            else if (marker.emitter == "plane")
            {
                bmp = (Bitmap)Image.FromFile(System.IO.Path.Combine(directory, "Markers", "PlaneOldMarker.png"));
            }
            else
            {
                bmp = (Bitmap)Image.FromFile(System.IO.Path.Combine(directory, "Markers", "OldUndeterminedMarker.png"));
            }

            Bitmap   returnBitmap = new Bitmap(30, 30);               // We create an empty Bitmap where we will be putting the images
            Graphics g            = Graphics.FromImage(returnBitmap); //Create a grapichs g from bitmap

            g.SmoothingMode     = SmoothingMode.AntiAlias;            //set parameters of g graphics. Interpolation and Pixel offset mode not set to highest quality to save resources
            g.InterpolationMode = InterpolationMode.HighQualityBicubic;
            g.PixelOffsetMode   = PixelOffsetMode.HighQuality;
            g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;


            if (marker.emitter == "plane" || marker.emitter == "car")
            {
                bmp = rotateBitmap(bmp, marker.direction);
                System.Drawing.Rectangle section = new System.Drawing.Rectangle(new System.Drawing.Point(bmp.Width / 4, bmp.Height / 4), new System.Drawing.Size(bmp.Width / 2, bmp.Height / 2));
                bmp = CropImage(bmp, section);  //After rotating image we crop it to quit unsused space
                g.DrawImage(bmp, 0, 0, 30, 30); //draw rotated image into g graphics
            }

            else
            {
                g.DrawImage(bmp, 10, 10, 10, 10); //draw dot image into g graphics
            }

            g.Flush();
            g.Dispose();

            return(returnBitmap);
        }
예제 #2
0
        /// <summary>
        /// Function to insert the label and rotate the marker drawing
        /// </summary>
        /// <param name="marker">Marker from which we want to make the shape</param>
        /// <returns>Bitmap with marker drawing, rotated, and labeled</returns>
        static public Bitmap InsertText(CustomOldGmapMarker marker)
        {
            Bitmap bmp;

            try
            {
                //We will take a different starting image depending on whether it is a surface vehicle, plane or undetermined
                if (marker.emitter == "car")
                {
                    bmp = (Bitmap)Image.FromFile(System.IO.Path.Combine(directory, "Markers", "OldCarIco.png"));
                }
                else if (marker.emitter == "plane")
                {
                    bmp = (Bitmap)Image.FromFile(System.IO.Path.Combine(directory, "Markers", "PlaneOldMarker.png"));
                }
                else
                {
                    bmp = (Bitmap)Image.FromFile(System.IO.Path.Combine(directory, "Markers", "OldUndeterminedMarker.png"));
                }
            }
            catch
            {
                bmp = null;
                GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced, true);
                if (marker.emitter == "car")//We will take a different starting image depending on whether it is a surface vehicle, plane or undetermined
                {
                    bmp = (Bitmap)Image.FromFile(System.IO.Path.Combine(directory, "Markers", "OldCarIco.png"));
                }
                else if (marker.emitter == "plane")
                {
                    bmp = (Bitmap)Image.FromFile(System.IO.Path.Combine(directory, "Markers", "PlaneOldMarker.png"));
                }
                else
                {
                    bmp = (Bitmap)Image.FromFile(System.IO.Path.Combine(directory, "Markers", "OldUndeterminedMarker.png"));
                }
            }

            Bitmap   returnBitmap = new Bitmap(60, 40);               // We create an empty Bitmap where we will be putting the images
            Graphics g            = Graphics.FromImage(returnBitmap); //Create a grapichs g from bitmap

            g.SmoothingMode     = SmoothingMode.AntiAlias;            //set parameters of g graphics. Interpolation and Pixel offset mode not set to highest quality to save resources
            g.InterpolationMode = InterpolationMode.High;
            g.PixelOffsetMode   = PixelOffsetMode.Default;
            g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;

            if (marker.emitter == "plane" || marker.emitter == "car")
            {
                bmp = rotateBitmap(bmp, marker.direction);
                System.Drawing.Rectangle section = new System.Drawing.Rectangle(new System.Drawing.Point(bmp.Width / 4, bmp.Height / 4), new System.Drawing.Size(bmp.Width / 2, bmp.Height / 2));
                bmp = CropImage(bmp, section);    //After rotating image we crop it to quit unsused space
                g.DrawImage(bmp, 20, 15, 20, 20); //draw rotated image into g graphics
            }

            else
            {
                g.DrawImage(bmp, 27, 23, 6, 6); //draw dot image into g graphics
            }

            Font font       = new Font("Times New Roman", 12, System.Drawing.FontStyle.Regular, GraphicsUnit.Pixel);
            var  stringSize = g.MeasureString(marker.caption, font);
            var  localPoint = new PointF((returnBitmap.Width - stringSize.Width) / 2, 0);

            System.Drawing.Brush color = new SolidBrush(System.Drawing.Color.FromArgb(255, (byte)0, (byte)0, (byte)0)); //Set color to match radar detection color
            if (marker.DetectionMode == "SMR")
            {
                color = new SolidBrush(System.Drawing.Color.FromArgb(70, 255, 0));
            }
            if (marker.DetectionMode == "MLAT")
            {
                color = new SolidBrush(System.Drawing.Color.FromArgb(0, 151, 255));
            }
            if (marker.DetectionMode == "ADSB")
            {
                color = new SolidBrush(System.Drawing.Color.FromArgb(255, 151, 0));
            }

            bmp.Dispose();
            bmp = null;

            g.DrawString(marker.caption, font, color, localPoint);

            g.Flush();
            g.Dispose();

            return(returnBitmap);
        }