Пример #1
0
        /// <summary>
        /// shows the ideal rectified grid
        /// </summary>
        /// <param name="filename">raw image filename</param>
        /// <param name="overlay_grid">ideal rectified grid</param>
        /// <param name="output_filename">filename to save as</param>
        private static void ShowOverlayGrid(string filename,
                                            grid2D overlay_grid,
                                            string output_filename)
        {
            Bitmap bmp = (Bitmap)Bitmap.FromFile(filename);
            byte[] img = new byte[bmp.Width * bmp.Height * 3];
            BitmapArrayConversions.updatebitmap(bmp, img);

            if (overlay_grid != null)
            {
                overlay_grid.ShowIntercepts(img, bmp.Width, bmp.Height, 255, 0, 0, 5, 0);
            }

            Bitmap output_bmp = new Bitmap(bmp.Width, bmp.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
            BitmapArrayConversions.updatebitmap_unsafe(img, output_bmp);
            if (output_filename.ToLower().EndsWith("jpg"))
                output_bmp.Save(output_filename, System.Drawing.Imaging.ImageFormat.Jpeg);
            if (output_filename.ToLower().EndsWith("bmp"))
                output_bmp.Save(output_filename, System.Drawing.Imaging.ImageFormat.Bmp);
        }
Пример #2
0
 private static void ShowIdealGrid(Bitmap bmp,
                                   grid2D ideal_grid,
                                   CalibrationDot[,] grid,
                                   ref Bitmap output_bmp)
 {
     byte[] img = new byte[bmp.Width * bmp.Height * 3];
     BitmapArrayConversions.updatebitmap(bmp, img);
     
     if (grid != null)
     {
         for (int grid_x = 0; grid_x < grid.GetLength(0); grid_x++)
         {
             for (int grid_y = 0; grid_y < grid.GetLength(1); grid_y++)
             {
                 if (grid[grid_x, grid_y] != null)
                 {
                     drawing.drawCross(img, bmp.Width, bmp.Height,
                                       (int)grid[grid_x, grid_y].x, (int)grid[grid_x, grid_y].y,
                                       1, 0,255,0,0);
                 }
             }
         }
     }
     if (ideal_grid != null) ideal_grid.ShowIntercepts(img, bmp.Width, bmp.Height, 255,0,0, 3, 0);
     
     if (output_bmp == null)
         output_bmp = new Bitmap(bmp.Width, bmp.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
     BitmapArrayConversions.updatebitmap_unsafe(img, output_bmp);
 }