|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Why the Marshalling / Copying?IntPtr ptr = bmpData->Scan0; .... .... // Copy the RGB values into the array. System::Runtime::InteropServices::Marshal::Copy( ptr, rgbValues, 0, bytes ); // Set every red value to 255. for ( int counter = 0; counter < rgbValues->Length; counter += 3 ) rgbValues[ counter ] = 255; // Copy the RGB values back to the bitmap System::Runtime::InteropServices::Marshal::Copy( rgbValues, 0, ptr, bytes ); It is a copy - modify - copy back sequence. My question: why bother? Why not simply cast a pointer: cPixel = (char *)bmpData->Scan0.ToInt32(); and work directly on the data? What are the risks? |
|||||||||||||||||||||||