新手提问:哪位高手能帮忙把VB.NET的代码转为VB的代码?

arthasalex 2007-06-12 09:41:12
这是李兰友书上一段中值滤波的代码,不过是拿VB.NET实现的,哪位大大能帮忙把它转成VB的阿,小弟自己没有成功。。。请大家帮忙阿~~~

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim i, i1, j1 As Integer ' x坐标
Dim j, gx, gy, bx, by, k1, k2 As Integer ' y坐标
Dim dt(181) As Integer
Dim r As Long '分解的R值
Dim g, dm As Long '分解的G值
Dim b As Long '分解的B值
Dim rr, rx As Integer
Dim gg, m As Short
Dim bb As Integer
Dim n As Long
Dim blocksize As Short = 3
tuxing = PictureBox1.Image

For i = Int(blocksize / 2) To PictureBox1.Size.Width - Int(blocksize / 2)
For j = Int(blocksize / 2) To PictureBox1.Size.Height - Int(blocksize / 2)
m = 0
For k1 = -Int(blocksize / 2) To Int(blocksize / 2)
For k2 = -Int(blocksize / 2) To Int(blocksize / 2)
c = tuxing.GetPixel(i + k1, j + k2)
r = c.R
g = c.G
b = c.B

dt(m) = r
m = m + 1


Next k2
Next k1
'Dim i, j As Integer
For i1 = m - 1 To 1 Step -1
For j1 = 1 To i1
If dt(j1 - 1) > dt(j1) Then
dm = dt(j1)
dt(j1) = dt(j1 - 1)
dt(j1 - 1) = dm
End If
Next j1
Next i1
rr = dt(Int(m / 2))
c = c.FromArgb(c.A, rr, rr, rr)
tuxing.SetPixel(i, j, c)
Next j
PictureBox1.Refresh()
Next i


End Sub
...全文
197 点赞 收藏 5
写回复
5 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
Chibi_chan 2011-06-24
我想请问一下楼主,您那本李兰友的书叫什么名字呀?好用吗?我是新手,正想买点书看看~~
回复
sandy_zc_1 2007-06-18
把第一行的小括号中的东西全部删掉。

然后把第二行去掉。

把所有的Short改成Integer,把所有的Integer改成Long。

然后把c = tuxing.GetPixel(i + k1, j + k2)这句改成:
c=PictureBox1.Point(i+k1,j+k2)


把tuxing.SetPixel(i, j, c)改成:
PictureBox1.Pset(i,j),c

把c = c.FromArgb(c.A, rr, rr, rr)改成:

c=RGB(rr,rr,rr)

大体OK。
回复
VirtualDesktop 2007-06-13
对了,vb.net中的Integer在vb6里面是long
回复
VBAdvisor 2007-06-13
稍微改一点就行了,你自己动脑子吧。
回复
VirtualDesktop 2007-06-13
不需要转换
你直接把那个事件的代码copy到vb6的一个按钮的点击事件里面就可以了
回复
相关推荐
发帖
多媒体
创建于2007-09-28

807

社区成员

VB 多媒体
申请成为版主
帖子事件
创建了帖子
2007-06-12 09:41
社区公告
暂无公告