示例#1
0
        public Point GetBMPPoint(BBOX boundarybox, int width, int height)
        {
            double x        = width * (this.x - boundarybox.xmin) / (boundarybox.xmax - boundarybox.xmin);
            double y        = height * (this.y - boundarybox.ymin) / (boundarybox.ymax - boundarybox.ymin);
            Point  bmpPoint = new Point((int)x, height - (int)y);

            return(bmpPoint);
        }
示例#2
0
 public Point[] GetBMPPoints(BBOX boundarybox, int width, int height)
 {
     Point[] bmpPoints = new Point[numPoints];
     for (int i = 0; i < numPoints; i++)
     {
         double x = width * (points[i].X - boundarybox.xmin) / (boundarybox.xmax - boundarybox.xmin);
         double y = height * (points[i].Y - boundarybox.ymin) / (boundarybox.ymax - boundarybox.ymin);
         bmpPoints[i] = new Point((int)x, height - (int)y);
     }
     return(bmpPoints);
 }
示例#3
0
        public Bitmap DrawBMP(BBOX boundarybox, Bitmap bmp)
        {
            int      width   = bmp.Width;
            int      height  = bmp.Height;
            Graphics graphic = Graphics.FromImage(bmp);
            Pen      mypen   = new Pen(Color.Black);

            Random ran        = new Random();
            int    r          = ran.Next(0, 255);
            int    g          = ran.Next(0, 255);
            int    b          = ran.Next(0, 255);
            Color  brushcolor = Color.FromArgb(r, g, b);

            switch (shapetype)
            {
            case ShapeTypes.Point:
                for (int i = 0; i < points.Count; i++)
                {
                    System.Drawing.Point bmpPoint = points[i].GetBMPPoint(boundarybox, width, height);
                    Brush     mybrush             = new SolidBrush(Color.Green);
                    Rectangle rect = new Rectangle(bmpPoint.X, bmpPoint.Y, 2, 2);
                    graphic.DrawRectangle(mypen, rect);
                    graphic.FillRectangle(mybrush, rect);
                }
                break;

            case ShapeTypes.Polyline:
                for (int i = 0; i < polylines.Count; i++)
                {
                    System.Drawing.Point[] bmpPoints = polylines[i].GetBMPPoints(boundarybox, width, height);
                    graphic.DrawLines(mypen, bmpPoints);
                }
                break;

            case ShapeTypes.Polygon:
                for (int i = 0; i < polygons.Count; i++)
                {
                    System.Drawing.Point[] bmpPoints = polygons[i].GetBMPPoints(boundarybox, width, height);
                    Brush mybrush = new SolidBrush(brushcolor);
                    graphic.DrawPolygon(mypen, bmpPoints);
                    graphic.FillPolygon(mybrush, bmpPoints);
                }
                break;

            default:
                break;
            }
            return(bmp);
        }
示例#4
0
        public Bitmap DrawBMP(BBOX boundarybox, Bitmap bmp, string style)
        {
            int      width   = bmp.Width;
            int      height  = bmp.Height;
            Graphics graphic = Graphics.FromImage(bmp);
            Pen      mypen   = new Pen(Color.Black);

            Color brushcolor = Color.Gray;

            switch (style)
            {
            case "Red":
                brushcolor = Color.Red;
                break;

            case "Green":
                brushcolor = Color.Green;
                break;

            case "Blue":
                brushcolor = Color.Blue;
                break;

            case "Cyan":
                brushcolor = Color.Cyan;
                break;

            case "Magenta":
                brushcolor = Color.Magenta;
                break;

            case "Yellow":
                brushcolor = Color.Yellow;
                break;

            default:
                break;
            }

            switch (shapetype)
            {
            case ShapeTypes.Point:
                for (int i = 0; i < points.Count; i++)
                {
                    Point     bmpPoint = points[i].GetBMPPoint(boundarybox, width, height);
                    Brush     mybrush  = new SolidBrush(Color.Green);
                    Rectangle rect     = new Rectangle(bmpPoint.X, bmpPoint.Y, 2, 2);
                    graphic.DrawRectangle(mypen, rect);
                    graphic.FillRectangle(mybrush, rect);
                }
                break;

            case ShapeTypes.Polyline:
                for (int i = 0; i < polylines.Count; i++)
                {
                    Point[] bmpPoints = polylines[i].GetBMPPoints(boundarybox, width, height);
                    graphic.DrawLines(mypen, bmpPoints);
                }
                break;

            case ShapeTypes.Polygon:
                for (int i = 0; i < polygons.Count; i++)
                {
                    Point[] bmpPoints = polygons[i].GetBMPPoints(boundarybox, width, height);
                    Brush   mybrush   = new SolidBrush(brushcolor);
                    graphic.DrawPolygon(mypen, bmpPoints);
                    graphic.FillPolygon(mybrush, bmpPoints);
                }
                break;

            default:
                break;
            }
            return(bmp);
        }