Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Getting/Setting Pixels on GIF in VB5

Posted on 1999-07-03
6
Medium Priority
?
280 Views
Last Modified: 2010-05-02
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
0
Comment
Question by:kisrael
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 

Author Comment

by:kisrael
ID: 1521786
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)
next
next
0
 

Author Comment

by:kisrael
ID: 1521787
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!!!
0
 
LVL 3

Expert Comment

by:jbil
ID: 1521788
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
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Expert Comment

by:Kurvy
ID: 1521789
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
lngColour=GetPixel(picture1.hwnd,x,y)

using the API SetPixel you can then play with the colours

lngReturn=SetPixel(picture1.hwnd,x,y,AnyColor(as longValue))
0
 

Author Comment

by:kisrael
ID: 1521790
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 http://www.word.com/pixeltime/

You can see the results at
http://www.word.com/pixeltime/archive/browse.cgi?enlarge=1999%2f07%2f931113580%2e25894&frame=0&email=kisrael%40alienbill%2ecom

0
 

Accepted Solution

by:
sp25 earned 100 total points
ID: 1521791
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
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

660 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question