Getting/Setting Pixels on GIF in VB5

How do I get and set individual pixels on a Picture control in VB5?  I think it has something to do with properly setting ScaleMode and then doing something math, but I can't get Pset and Point to get me what I'm looking for
Who is Participating?
sp25Connect With a Mentor Commented:
Use The PSET and POINT functions,

PixelRGB = Picture1.Point(X,Y)            
This will return the Red Green Blue Value of the pixel at location X,Y

Picture1.Pset (X , Y), RGB
This will set the location X,Y with Red Green Blue Color Specified
kisraelAuthor Commented:
Is it something like this?
widthInPixels = picture1.width/Screen.TwipsPerPixelX
HeightInPixels = picture1.height/Screen.TwipsPerPixelY

for y = 0 to heightInPixels -1
for x = 0 to widthInPixels - 1
                picture1.PSet (x * Screen.TwipsPerPixelX, y * Screen.TwipsPerPixelY)
kisraelAuthor Commented:
Bonus points if someone can tell me how to translate the return value
of the point function (a Long) back into seperate R,G,B values-- even
more points if they can explain why the RGB() fuinction (which goes the
other way) doesn't mention it!!!
The new generation of project management tools

With’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
 getRGB Me.Point(X, Y)
End Sub

Private Sub getRGB(ByVal col As Long)
Dim crimson As Byte
Dim verde As Byte
Dim azure As Byte

crimson = col And &HFF
verde = (col And &HFF00) / 256 Mod 256
azure = (col And &HFF0000) / 65536

Text2.Text = " R = " & crimson & " G = " & verde & " B = " & azure
End Sub
jbil looks to have given you the colours, the reason is that colours are actually stored as a 24 bit integer where red is the high bit , green the middle and blue the low.

As an alternative to the method for getting the colour from point, you could use the folowing API call GetPixel which once again returns the 24 bit integer.

picture1.scalemode=3 ' Value for Pixel

using the API SetPixel you can then play with the colours

lngReturn=SetPixel(picture1.hwnd,x,y,AnyColor(as longValue))
kisraelAuthor Commented:
Yeah, I think i figured out all the tools I need.

In case you're wondering, i made this coolish app that takes a
small greyscale GIF and converts it into 5 shades of grey (9 counting
the dithering it does.)

It can then take over control of the mouse, and paint that picture one
grey color at a time on the drawing app at

You can see the results at

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.