7,763
社区成员
发帖
与我相关
我的任务
分享
Private Sub Form_Load()
Picture1.AutoRedraw = True
Picture1.Picture = LoadPicture("c:\ 缩放前.jpg")
Picture1.Width = Picture1.Width / 2
Picture1.Height = Picture1.Height / 2
Picture1.PaintPicture Picture1, 0, 0, Picture1.Width, Picture1.Height
SavePicture Picture1.Image, "c:\缩放后.jpg"
End Sub
Option Explicit
Private Declare Function StretchBlt Lib "gdi32.dll" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long
Private Const SRCCOPY As Long = &HCC0020
Private Sub Command1_Click()
'保存个铲铲c:\chanchan_1.bmp
SavePicture Picture1.Image, "c:\chanchan_1.bmp"
End Sub
Private Sub Form_Load()
Picture2.ScaleMode = 3
Picture1.ScaleMode = 3
Picture2.AutoRedraw = True
Picture1.AutoRedraw = True
'先在picture2上加载个铲铲
Picture2.Picture = LoadPicture("c:\chanchan.jpg")
'缩放个铲铲到picture1
Call StretchBlt(Picture1.hdc, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, Picture2.hdc, 0, 0, Picture2.ScaleWidth, Picture2.ScaleHeight, SRCCOPY)
'Picture1.Refresh
End Sub
Private Sub Form_Click ()
' 声明变量。
Dim CX, CY, Limit, Radius as Integer, Msg as String
ScaleMode = vbPixels ' 设置比例模型为像素。
AutoRedraw = True ' 打开 AutoRedraw。
Width = Height ' 改变宽度以便和高度匹配。
CX = ScaleWidth / 2 ' 设置 X 位置。
CY = ScaleHeight / 2 ' 设置 Y 位置。
Limit = CX ' 圆的尺寸限制。
For Radius = 0 To Limit ' 设置半径。
Circle (CX, CY), Radius, RGB(Rnd * 255, Rnd * 255, Rnd * 255)
DoEvents ' 转移到其它操作。
Next Radius
Msg = "Choose OK to save the graphics from this form "
Msg = Msg & "to a bitmap file."
MsgBox Msg
SavePicture Image, "TEST.BMP" ' 将图片保存到文件。
End Sub