//添加图片 private void button9_Click(object sender, EventArgs e) { User_Bmp BmpZone = new User_Bmp(); User_MoveSet MoveSet = new User_MoveSet(); int iBMPZoneNum = 0; BmpZone.PartInfo.iX = 0; BmpZone.PartInfo.iY = 0; BmpZone.PartInfo.iHeight = 32; BmpZone.PartInfo.iWidth = 64; BmpZone.PartInfo.FrameColor = 0xFF00; BmpZone.PartInfo.iFrameMode = 1; MoveSet.bClear = true; MoveSet.iActionSpeed = 4; MoveSet.iActionType = 0; MoveSet.iHoldTime = 50; MoveSet.iClearActionType = 0; MoveSet.iClearSpeed = 4; MoveSet.iFrameTime = 20; iBMPZoneNum = User_AddBmpZone(g_iCardNum, ref BmpZone, g_iProgramIndex); string strBmpFile = ".\\风景06.bmp"; if (false == User_AddBmpFile(g_iCardNum, iBMPZoneNum, strBmpFile, ref MoveSet, g_iProgramIndex)) { MessageBox.Show("添加指定路径图片失败!"); } else { MessageBox.Show("添加指定路径图片成功!"); } Bitmap bmp = new Bitmap(pictureBox2.Image, BmpZone.PartInfo.iWidth, BmpZone.PartInfo.iHeight); IntPtr hBitmap = bmp.GetHbitmap(); if (false == User_AddBmp(g_iCardNum, iBMPZoneNum, hBitmap, ref MoveSet, g_iProgramIndex)) { MessageBox.Show("添加图片句柄失败!"); } else { MessageBox.Show("添加图片句柄成功!"); } DeleteObject(hBitmap); bmp.Dispose(); }
public static extern bool User_AddBmpFile(int CardNum, int iBmpPartNum, string strFileName, ref User_MoveSet pMoveSet, int iProgramIndex);
public static extern bool User_AddBmp(int CardNum, int iBmpPartNum, IntPtr hBitmap, ref User_MoveSet pMoveSet, int iProgramIndex);