110,536
社区成员
发帖
与我相关
我的任务
分享
[DllImport("dllTestForm.dll", EntryPoint = "showFormC")]
static extern void testShowFormC(byte[] photo,int len);
private void button6_Click(object sender, EventArgs e)
{
Bitmap bmp = (Bitmap)Image.FromFile(@"d:\1\1.jpg");
Rectangle rect = new 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.
int bytes = Math.Abs(bmpData.Stride) * bmp.Height;
byte[] rgbValues = new byte[bytes];
// Copy the RGB values into the array.
System.Runtime.InteropServices.Marshal.Copy(ptr, rgbValues, 0, bytes);
// Unlock the bits.
bmp.UnlockBits(bmpData);
testShowFormC(rgbValues, bytes);
}
[DllImport("dllTestForm.dll", EntryPoint = "showFormC")]
static extern void testShowFormC(byte[] photo,int len);
void __stdcall showFormC(byte *photo,int len)
{
ThelloWorld *a=new ThelloWorld(Application);//这是一个winForm测试界面,显示图片用
a->ImageEnView2->IO->LoadFromBuffer(photo,0,len);
a->Show();
}