Пример #1
0
        /// <summary>
        /// show the recongnition result
        /// </summary>
        /// <summary>
        /// show the result;
        /// </summary>
        /// <param name="num"></param>
        /// <summary>
        /// Show color image
        /// </summary>
        /// <param name="str">The name for the form</param>
        /// <param name="imMatrix">Matrix needed to be show</param>
        public static void ShowImg(string str, ARGB[,] imMatrix)
        {
            int i, j, w, h;
            int rr, gg, bb;
            Form2 child = new Form2();
            probsolve = child;
            child.Text = str;
            w = imMatrix.GetLength(0);
            h = imMatrix.GetLength(1);
            Bitmap box1 = new Bitmap(w, h);
            FastBitmap box11 = new FastBitmap(box1);
            child.Show();

            Color cc = new Color();

            for (i = 0; i < w; i++)
                for (j = 0; j < h; j++)
                {
                    rr = imMatrix[i, j].R;
                    gg = imMatrix[i, j].G;
                    bb = imMatrix[i, j].B;
                    cc = Color.FromArgb(rr, gg, bb);
                    box11.SetPixel(i, j, cc);

                }
            child.PictureBox1.Refresh();
            box1 = box11.Bitmap;
            child.PictureBox1.Image = box1;
            box11.Release();

               // Application.Run(child);
        }
Пример #2
0
        /// <summary>
        /// Save color image to files
        /// </summary>
        /// <param name="imMatrix">Image matrix needed to be saved</param>
        /// <param name="fileName">Specify the filename to be save in</param>
        public static void saveColorImage(ARGB[,] imMatrix, string fileName)
        {
            int i, j;
            ARGB pp;
            //PGM Picuture;
            fileName = (fileName + ".bmp");

            int w = imMatrix.GetLength(0);
            int h = imMatrix.GetLength(1);
            Bitmap box1 = new Bitmap(w,h);
              //  FastBitmap box11 = new FastBitmap(box1);
            Color cc = new Color();
            for (i = 0; i < w; i++)
                for (j = 0; j < h; j++)
                {
                    pp = imMatrix[i, j];
                   // cc = Color.FromArgb(255, 255, 255);
                    cc = Color.FromArgb(pp.R, pp.G, pp.B);
                    box1.SetPixel(i, j, cc);

                }
               /*
            for (i = 0; i < w; i++)
                for (j = 0; j < h; j++)
                {

                    cc = box11.GetPixel(i, j);
                    imMatrix[i, j] = cc.R;

                }
            */
            //    box1 = box11.Bitmap;
              //  ShowImg("box1", imMatrix);
             //   System.IO.File.Delete(fileName);

            box1.Save(fileName);
            //box11.Release();
        }