• Monday, May 4, 2015

    VB6->VB.Net - PictureBox PSet and point alternative

    In VB6, PictureBox Control have two methods namely PSet, and point which sets the color of given pixel position or retrieve the color for same.

    But in VB.Net, PictureBox Control doesn't have these two methods. But there is an alternative and best way.

    Here, we create an image of 100 x 100 pixels in which we set the pixels.

    Dim bmp As New Bitmap(100, 100)

            For X = 0 To bmp.Width - 1

                For Y = 0 To bmp.Height - 1
                    bmp.SetPixel(X, Y,Color.Black)
                Next Y
            Next X

            PictureBox1.Image = bmp

    To get an pixel use:

    Dim col As Color, R As Integer, G As Integer, B As Integer
    col = bmp.GetPixel(X,Y)
    R = col.R
    G = col.G
    B = col.B

    Masoom Rizvi

    Author & Editor

    Hi, This is Syed Masoom Rizvi, who is continue exploring the world of programming ,programming and programming... :)


    Post a Comment