'在窗体上放一个Image、一个PictureBox、一个CommandButton,以下代码将一张图分成2*2=4份 Option ExplicitPrivate Sub Command1_Click() Dim w As Long, h As Long Dim i As Long, j As Long
Image1.Picture = LoadPicture("C:\Temp\a.bmp") w = Image1.Width \ 2 h = Image1.Height \ 2
Picture1.Move 0, 0, w, h
For i = 0 To 1 For j = 0 To 1 Picture1.PaintPicture Image1.Picture, 0, 0, w, h, i * w, j * h, w, h SavePicture Picture1.Image, "C:\temp\" & i & "_" & j & ".bmp" Next Next End SubPrivate Sub Form_Load() Picture1.BorderStyle = vbBSNone Picture1.AutoRedraw = True End Sub
Option ExplicitPrivate Sub Command1_Click()
Dim w As Long, h As Long
Dim i As Long, j As Long
Image1.Picture = LoadPicture("C:\Temp\a.bmp")
w = Image1.Width \ 2
h = Image1.Height \ 2
Picture1.Move 0, 0, w, h
For i = 0 To 1
For j = 0 To 1
Picture1.PaintPicture Image1.Picture, 0, 0, w, h, i * w, j * h, w, h
SavePicture Picture1.Image, "C:\temp\" & i & "_" & j & ".bmp"
Next
Next
End SubPrivate Sub Form_Load()
Picture1.BorderStyle = vbBSNone
Picture1.AutoRedraw = True
End Sub