unsafe { byte* p = (byte*)srcdata.scan0.topointer(); for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { if (y % val == 0) { if (x % val == 0) { stdr = p[2]; stdg = p[1]; stdb = p[0]; } else { p[0] = (byte)stdb; p[1] = (byte)stdg; p[2] = (byte)stdr; } } else { // 复制上一行 byte * ptemp = p - srcdata.stride;
p[0] = (byte)ptemp[0]; p[1] = (byte)ptemp[1]; p[2] = (byte)ptemp[2]; } p += 3; } // end of x p += srcdata.stride - w * 3; } // end of y b.unlockbits(srcdata); } return b; }