
通常Graphics是要和Bitmap一起使用的,假如iWidth=300,iHeight=100,代码如下:
Bitmap bmpOut = new Bitmap((int)iWidth, (int)iHeight, PixelFormat.Format24bppRgb)Graphics g = Graphics.FromImage(bmpOut)
g.DrawImage(b, new Rectangle(0, 0, (int)iWidth, (int)iHeight), new Rectangle((int)S tartX, (int)StartY, (int)iWidth, (int)iHeight), GraphicsUnit.Pixel)
g.Dispose()
return bmpOut
这样就会生成一个300 * 100的图片,然后PictureBox.BackgroundImage=这个把回来的bmpOut就可以了,例如:
this.pictureBox1.BackgroundImage = new Bitmap(300,100)//假设这个 new Bitmap(300,100)
就是上面的代码返回来的bmpOut
Private Sub Form_Load()Command1.Visible = False
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Command1.Visible = True
End Sub
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)