To 我没有发现在.net中有可用的的函数可以调用,谁知道用.net怎样实现?用Graphics.DrawImage方法可以实现你的功能
public void DrawImage(
Image image,
Rectangle destRect,//目标大小
int srcX,//源的x坐标
int srcY,//源的y坐标
int srcWidth,//源的宽度
int srcHeight,//源的高度
GraphicsUnit srcUnit,
ImageAttributes imageAttr
);To 所以我想用api,Bitblt()
声明如下:
using System.Runtime.InteropServices;//BitBlt API declarition
[DllImport("gdi32.dll")]
public static extern bool BitBlt(
IntPtr hdcDest, // handle to destination DC
int nXDest, // x-coord of destination upper-left corner
int nYDest, // y-coord of destination upper-left corner
int nWidth, // width of destination rectangle
int nHeight, // height of destination rectangle
IntPtr hdcSrc, // handle to source DC
int nXSrc, // x-coordinate of source upper-left corner
int nYSrc, // y-coordinate of source upper-left corner
Int32 dwRop // raster operation code
);
public void DrawImage(
Image image,
Rectangle destRect,//目标大小
int srcX,//源的x坐标
int srcY,//源的y坐标
int srcWidth,//源的宽度
int srcHeight,//源的高度
GraphicsUnit srcUnit,
ImageAttributes imageAttr
);To 所以我想用api,Bitblt()
声明如下:
using System.Runtime.InteropServices;//BitBlt API declarition
[DllImport("gdi32.dll")]
public static extern bool BitBlt(
IntPtr hdcDest, // handle to destination DC
int nXDest, // x-coord of destination upper-left corner
int nYDest, // y-coord of destination upper-left corner
int nWidth, // width of destination rectangle
int nHeight, // height of destination rectangle
IntPtr hdcSrc, // handle to source DC
int nXSrc, // x-coordinate of source upper-left corner
int nYSrc, // y-coordinate of source upper-left corner
Int32 dwRop // raster operation code
);
解决方案 »
- 腾讯微博登陆问题,好诡异,高手都过来瞄一眼……
- C# 如何获取客户端外网IP
- 用registrykey打开注册表的问题
- 将GridView中的数据导出到Excel的问题
- C#写的程序(绘图)从一台机子拷贝到另外一台机子上不能用?
- ~~~~~~~问一个关于Listviwe与Access的问题?????? ~~~~~~~~~~~~~~急啊~~~~~`马上就要交毕业设计了~~~~~~~~`
- set的问题
- 一个Winform数据库连接的安全问题
- 求一正则表达式
- 关于comboBox绑定数据时的问题! (100分,在线等待)
- 有没有什么好的办法让DataGird只显示指定的列?急问的说
- 求解C#从上手到精通时间
你看看这段代码是不是可以解决你的问题。 不用 api 以
Bitmap myBit=new Bitmap(@"E:\Tools\photo\Photo\mummy1.jpg");
int nXPos=200;//Position in picture
int nYPos=200;Bitmap myBit2=new Bitmap(100, 100); //your size
Graphics g=Graphics.FromImage(myBit2);
g.DrawImage(myBit,new Rectangle(0,0,100,100)/*Dest rectangle*/,
new Rectangle(nXPos,nYPos,100,100)/*Sour rectangle*/,
GraphicsUnit.Pixel);this.BackgroundImage=myBit2;//Using new image