I'm trying to create an image to SQL parser, but I've run into a snag, it starts off running really quick but as time goes on it progressively slows down, and the memory keeps seesawing between 60MB and 300MB. For a 3000x3000 image it takes over 16 hours......
class Img2Sql
{
static string table_name="test";
static string sql_data="";
public void Start()
{
Console.Write("Enter in a full path to file: ");
String file_full_path = Console.ReadLine();
Bitmap image = AForge.Imaging.Image.FromFile(file_full_path);
Console.WriteLine("Loaded image from File.... {0}\n", file_full_path);
int x = 0;
int y = 0;
int grid_x = image.Width;
int grid_y = image.Height;
Color pix;
for (y = 0; y < grid_y; y++)
{
for (x = 0; x < grid_x; x++)
{
Console.WriteLine("({0},{1})",x,y);
pix = image.GetPixel(x, y);
sql_data += pixel_to_sql(pix, x, y);
//process_slow_destory_max_min(ref pix, ref img, x, y);
}
}
Console.WriteLine(sql_data);
}
static string pixel_to_sql(Color pix,int x,int y)
{
return ("INSERT INTO "+table_name+"(red,green,blue,x,y) VALUES("+pix.R+","+pix.G+","+pix.B+","+x+","+y+");\n");
}
}
It seems like a fairly straight forward loop.....