private void button4_Click(object sender, EventArgs e) { // GDI+ still lies to us - the return format is BGR, NOT RGB. BitmapData bmData = RImage.LockBits(new Rectangle(0, 0, RImage.Width, RImage.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb); int stride = bmData.Stride; System.IntPtr Scan0 = bmData.Scan0; unsafe { byte* p = (byte*)(void*)Scan0; int nOffset = stride - RImage.Width * 3; for (int y = 0; y < RImage.Height; ++y) { for (int x = 0; x < RImage.Width; ++x) { //supaya setiap y baru seed juga baru if ((x == 0) || (seedR == 0)) { //mengambil value seed seedR = p[x]; seedG = p[x+1]; seedB = p[x+2]; } else { if ((seedR - p[x] >= tred) || (p[x] - seedR >= tred)) { for (int i = 0; i < 2; ++i) { p[x] = p[x + 1] = p[x + 2] = 255; ++x; } seedR = 0; seedG = 0; seedB = 0; } } p += 3; } p += nOffset; } } RImage.UnlockBits(bmData); }
UnlockBits
Graphics
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)