In code I had in a Visual Studio C++ .NET Windows Form Application, I had a portion of code that looked like this:
bmd is a BitmapData object.
for(int y = 0; y < bmd->Height; y++)
Byte* row = (Byte*)(void*)bmd->Scan0 +(y * bmd->Stride);
for(int x = 0; x < bmd->Width*4; x++)
Now, I'm writing a function to do the same thing in C#. However, I got a few errors. I've been trying to find a C# equivalent that would give me the equivalent of the "Byte* row" line, but so far, I've got no luck. This is what I have now, but its still not working. I've replaced that one entire line with this:
int rowPtr = y * bmd.Stride;
IntPtr scanPoint = bmd.Scan0;
void* bmdRow = scanPoint.ToPointer();
//bmdRow+=rowPtr; <- Gives error.
row = (Byte)(bmdRow);
The code is basically supposed to give me a pointer to each row so I can set each pixel individually. In that nested for loop was code that contained stuff like "row[x] = pixelvalue;" If anyone can help me out with this, that'd be great. Any questions to get a more detailed explanation of the problem, just ask.