Link to home
Start Free TrialLog in
Avatar of sidwelle
sidwelleFlag for United States of America

asked on

pset in VB.net

Trying to set a pixel in a picturebox with out any luck.
Please look at the code and tell me what is missing.

If I set the 'bmTemp' to the image of the picturebox, why would I want an new instance as the error message suggests ?  The picture box is empty, but does that mean is has no image at all ?


Public Sub DrawAPixel(ByVal x As Integer, ByVal y As Integer, ByVal clr As Color)

        Dim bmTemp As Bitmap
        bmTemp = pctGraph.Image
        Dim MyClr As Color

        bmTemp.SetPixel(x, y, clr)

    End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Meir Rivkin
Meir Rivkin
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sidwelle

ASKER

Thanks
You could also draw the pixels in the Paint() event of your PictureBox using the supplied "e.Graphics".

Store the data about which pixels to set in a class Level List type structure.

Which approach is better really depends on your application...