Пример #1
0
        public static Bitmap MakeImage(ovf2 ovfFile, int XYorZ_12or3)
        {
            int        Nx    = ovfFile.header.xnodes;
            int        Ny    = ovfFile.header.ynodes;
            Bitmap     bmp   = new Bitmap(Nx, Ny);
            Graphics   g     = Graphics.FromImage(bmp);
            SolidBrush brush = new SolidBrush(Color.Black);

            double[] minmax = Viz.GetMinMax(ovfFile, XYorZ_12or3);
            for (int i = 0; i < Nx; i++)
            {
                for (int j = 0; j < Ny; j++)
                {
                    Vector vij = ovfFile.CellValue(i, j, 0);
                    //if (vij.z < 1)
                    //Console.WriteLine(vij.z.ToString());
                    brush.Color = ColorMap.BlackWhite(minmax[0], minmax[1], Component(vij, XYorZ_12or3));
                    //Console.WriteLine("{0}, {1}", i, Nx - 1 - j);
                    Rectangle pxl = new Rectangle(i, Ny - 1 - j, 1, 1);
                    g.FillRectangle(brush, pxl);
                }
            }

            return(bmp);
        }
Пример #2
0
        //xy or z = 1,2 or 3
        public static double[] GetMinMax(ovf2 ovfFile, int XYorZ_12or3)
        {
            double max = double.NegativeInfinity;
            double min = double.PositiveInfinity;
            int    Nx  = ovfFile.header.xnodes;
            int    Ny  = ovfFile.header.ynodes;

            for (int i = 0; i < Nx; i++)
            {
                for (int j = 0; j < Ny; j++)
                {
                    double val = Component(ovfFile.CellValue(i, j, 0), XYorZ_12or3);
                    if (val > max)
                    {
                        max = val;
                    }
                    if (val < min)
                    {
                        min = val;
                    }
                }
            }

            return(new double[] { min, max });
        }