I'm trying to squeeze the best performance out of some imaging code and I've hit a wall.
As far as my knowledge goes it should be possible to speed up the process using pointers but my experience with them is very limited and finding good documentation to read and understand is proving difficult.
Am I correct? Could someone show an annotated example of the code converted to help me understand the process.
public void UpdatePixelIndexes(IEnumerable<byte[]> lineIndexes)
{
int width = this.Image.Width;
int height = this.Image.Height;
IEnumerator<byte[]> indexesIterator = lineIndexes.GetEnumerator();
for (int rowIndex = 0; rowIndex < height; rowIndex++)
{
indexesIterator.MoveNext();
BitmapData data = this.Image.LockBits(Rectangle.FromLTRB(0, rowIndex, width, rowIndex + 1), ImageLockMode.WriteOnly, PixelFormat.Format8bppIndexed);
try
{
Marshal.Copy(indexesIterator.Current, 0, data.Scan0, width);
}
finally
{
this.Image.UnlockBits(data);
}
}
}