0

My Class1 codes; (This codes from Class Library)

    Class SuperPicBox : Inherits PictureBox
    #Region "Effects"
    Dim bin As Image = MyBase.Image
    Private roma As Boolean
    Public Property Grayscale As Boolean
        Get
            Return roma
        End Get
        Set(value As Boolean)
            roma = value
            Select Case roma
                Case True
                    Dim bm As New Bitmap(bin)            'Error here
                    Dim X As Integer
                    Dim Y As Integer
                    Dim clr As Integer

                    For X = 0 To bm.Width - 1
                        For Y = 0 To bm.Height - 1
                            clr = (CInt(bm.GetPixel(X, Y).R) + _
                                   bm.GetPixel(X, Y).G + _
                                   bm.GetPixel(X, Y).B) \ 3
                            bm.SetPixel(X, Y, Color.FromArgb(clr, clr, clr))
                        Next Y
                    Next X

                    bin = bm

                Case False
                    MyBase.Image = MyBase.Image
            End Select
            Invalidate()
        End Set
    End Property
#End Region
End Class

and this Form 1 button 1 click event codes

SuperPicBox1.Grayscale = True

I am click button1. But not working! I'm getting Object reference to an instance of an object error

Ňɏssa Pøngjǣrdenlarp
  • 38,411
  • 12
  • 59
  • 178

0 Answers0