日期:2014-05-18 浏览次数:20782 次
/* psrc 传入图像首地址 pdst DLL 对psrc处理有保存在pdst对应的内存中 */ extern "C" _declspec(dllexport) int clip2( unsigned char *psrc , unsigned char *pdst , int nwidth , int nheight); int clip2( unsigned char *psrc , unsigned char *pdst , int nwidth , int nheight) { //.............. }
unsafe private static extern int clip2(byte* psrc, byte* pdst, int nwidth, int height);
Bitmap bp = new Bitmap("a.bmp"); this.pictureBox1.Image = bp int w = bp.Width; ; int h = bp.Height; ; Bitmap buf = new Bitmap(w,h,PixelFormat.Format24bppRgb); BitmapData datasrc = bp.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb); BitmapData datadst = buf.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb); unsafe { byte * psrc = (byte *)datasrc.Scan0.ToPointer(); byte *pdst = (byte *)datadst.Scan0.ToPointer(); clip2(ptr, pdst, w, h); }