图形处理从一张图中撷取一个小区块显示在另个窗口的问题
小弟目前我正在尝试从一张图中 去撷取这张图的一个矩形区块出来
然后在另一个窗口中呈现 我是直接拿市面上已经有做好的模块来进行截图的
程序上传到我的skydrive 请各位参考:
http://sdrv.ms/YOnm9r
Private Sub PictureBox_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint '只要在pic滑过去就会触发事件
Dim NEWBITMAP As New Bitmap(PictureBox1.Image)
If c = 2 Then
With e.Graphics
'------------------------------------
'问题区块
Dim R(mdq.X - mdp.X, mdq.Y - mdp.Y) As Byte
Dim G(mdq.X - mdp.X, mdq.Y - mdp.Y) As Byte
Dim B(mdq.X - mdp.X, mdq.Y - mdp.Y) As Byte
'newpart.Image
FastPixel.LockBMP(NEWBITMAP)
For i = mdp.X To mdq.X
For j = mdp.Y To mdq.Y
R(i, j) = FastPixel.GetC(i, j, 1) '取得红
G(i, j) = FastPixel.GetC(i, j, 2) '取得绿
B(i, j) = FastPixel.GetC(i, j, 3) '取得蓝
Next
Next
For I = 0 To mdq.X - mdp.X
For J = 0 To mdq.Y - mdp.Y
FastPixel.SetP(I, J, R(I, J), G(I, J), B(I, J))
Next
Next
FastPixel.UnLockBMP(NEWBITMAP)
Dim newcolor As New Form2
newcolor.PictureBox1.Image = NEWBITMAP
newcolor.Show()
'问题区块
'-----------------------------------
'.DrawRectangle(Pens.Black, 矩形区块)
.DrawLine(Pens.Black, mdp.X, mdp.Y, mdq.X, mdp.Y)
.DrawLine(Pens.Black, mdp.X, mdp.Y, mdp.X, mdq.Y)
.DrawLine(Pens.Black, mdp.X, mdq.Y, mdq.X, mdq.Y)
.DrawLine(Pens.Black, mdq.X, mdp.Y, mdq.X, mdq.Y)
End With
End If
End Sub
'问题区块