예제 #1
0
파일: Form1.cs 프로젝트: configare/hispeed
        private void Vector2Bitmap(ShapePolygon shapePolygon)
        {
            //矢量转成位图
            Dictionary <ShapePolygon, Color> vectors = new Dictionary <ShapePolygon, Color>();

            vectors.Add(shapePolygon, Color.Red);
            IVector2BitmapConverter c = new Vector2BitmapConverter();
            int    width  = (int)(shapePolygon.Envelope.Width / 0.1f);
            int    height = (int)(shapePolygon.Envelope.Height / 0.1f);
            Size   size   = new System.Drawing.Size(width, height);
            Bitmap buffer = new Bitmap(size.Width, size.Height, PixelFormat.Format24bppRgb);

            c.ToBitmap(vectors, Color.White, shapePolygon.Envelope, size, ref buffer);
            buffer.Save("f:\\1.bmp", ImageFormat.Bmp);
            //位图转成栅格索引
            Bitmap2RasterConverter b2r = new Bitmap2RasterConverter();

            int[] idxs = b2r.ToRaster(buffer, Color.Red);
            //栅格索引转成位图
            BinaryBitmapBuilder b = new BinaryBitmapBuilder();

            buffer = b.CreateBinaryBitmap(size, Color.Red, Color.White);
            b.Fill(idxs, size, ref buffer);
            buffer.Save("f:\\2.bmp", ImageFormat.Bmp);
        }
예제 #2
0
 private static Bitmap VectorsToBitmap(IRasterDataProvider prd, CodeCell.AgileMap.Core.Feature[] features, string shpPrimaryField, out Dictionary <string, Color> nameColors)
 {
     using (IVector2BitmapConverter c = new Vector2BitmapConverter())
     {
         Dictionary <ShapePolygon, Color> vectors = GetVectorColors(features, shpPrimaryField, out nameColors);
         Bitmap   bmp     = new Bitmap(prd.Width, prd.Height, PixelFormat.Format24bppRgb);
         Envelope envelop = GetEnvelop(prd);
         c.ToBitmap(vectors, Color.Black, envelop, new Size(prd.Width, prd.Height), ref bmp);
         return(bmp);
     }
 }