【发布时间】:2016-06-28 06:12:43
【问题描述】:
我正在尝试从另一个类访问属于类 frmamain 的函数。请谁能告诉我我必须如何实现这一目标?我是 VB.NET 的新手。提前致谢。
代码抛出如下错误
“ConvertImagerBnW() 未声明。由于其保护级别,它可能无法访问”
class frmamain
Public Function ConvertImagerBnW()
Try
Dim img As Bitmap = New Bitmap((Image.FromFile("D:\\imgnam.jpg")))
''Dim img As Bitmap = New Bitmap(ImageBox1.Image)
Dim c As Color
Dim i As Integer = 0
Do While (i < img.Width)
Dim j As Integer = 0
Do While (j < img.Height)
c = img.GetPixel(i, j)
Dim r As Integer = 0
r = Convert.ToInt16(c.R)
Dim g As Integer = 0
g = Convert.ToInt16(c.G)
Dim b As Integer = 0
b = Convert.ToInt16(c.B)
Dim ans As Integer = ((r _
+ (g + b)) _
/ 3)
If (ans > 128) Then
r = 255
g = 255
b = 255
Else
r = 0
g = 0
b = 0
End If
c = Color.FromArgb(r, g, b)
img.SetPixel(i, j, c)
j = (j + 1)
Loop
i = (i + 1)
Loop
''Image<Gray, Byte> normalizedimg = new Image<Gray, Byte>(img);
img.Save("D:\\imgnamNew.jpg")
Dim Bmp1 As New Image(Of Bgr, [Byte])("D:\\imgnamNew.jpg")
ImageFrame = Bmp1
''ImageBox1.Image = ImageFrame
''ImageBox1.Image.Save("D:\\imgnamNew.jpg")
'' MessageBox.Show("SUCESSFULLY DONE")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Function
end class
Module UseThread
Sub newthread()
ConvertImagerBnW()
End Sub
End Module
【问题讨论】:
-
公开方法的访问......
-
“我是 VB.Net 的新手” 我们需要看看你到目前为止写了什么......看起来问题不是与 .net 相关,但与 SoftDevel...
-
是的,我做了同样的改变,但不起作用
标签: vb.net function access-specifier