基于GetPixel 和 SetPixel 速度实在是太慢,处理大点的图片几乎崩溃的速度,幸好有解决方案~
Bitmap^ bmp = gcnew Bitmap( "y.bmp" );
Rectangle rect = Rectangle(0,0,bmp->Width,bmp->Height);
System::Drawing::Imaging::BitmapData^ bmpData = bmp->LockBits( rect, System::Drawing::Imaging::ImageLockMode::ReadWrite, bmp->PixelFormat );
// Get the address of the first line.
IntPtr ptr = bmpData->Scan0;
// Declare an array to hold the bytes of the bitmap.
// This code is specific to a bitmap with 24 bits per pixels.
int bytes = bmpData->Stride * bmp->Height ;
array<Byte>^rgbValues = gcnew array<Byte>(bytes);
// Copy the RGB values into the array.
// System::Runtime::InteropServices::Marshal::Copy( ptr, rgbValues, 0, bytes );
int PixelSize=3;