//the main function, call this to encode a frame -> starts thread workers after breaking image down. public TMVFrame encode(Bitmap input) { cframe = new TMVFrame(); unprocessed = new Queue<Cell>(); for (int row = 0; row < 25; row++) //for each row { for (int col = 0; col < 40; col++) // for each cell { unprocessed.Enqueue(new Cell(getCell(input, row, col),(uint)((row*40)+(col)))); //add the new cell to our task pool } } for (int i = 0; i < workers.Length; i++ ) //start the workers on our cell pool { workers[i] = new Thread(worker); workers[i].Start(i); } while (unprocessed.Count > 0) { System.Threading.Thread.Sleep(50); Application.DoEvents(); } for (int t = 0; t < workers.Length; t++) { workers[t].Join(); } return cframe; }
public void addFrame(TMVFrame frame) { frames.Enqueue(frame); }