getPixels in a picture

What is the best way to get the pixels from any picture file in VB6.

I was thinking i could load the picture in a control that has a Device Context (maybe picturebox) and use the API function getPixel to get them. However that function requires an xPos and a yPos. How would i go about finding the xPos and yPos for all the pixels in the picture relative to the application and the screen.

If anyone has any idea how to do this or has a better way then I am all ears

thx in advance


P.S. what about setting pixels too, how could that be implemented?

Comments

  • : What is the best way to get the pixels from any picture file in VB6.
    :
    : I was thinking i could load the picture in a control that has a Device Context (maybe picturebox) and use the API function getPixel to get them. However that function requires an xPos and a yPos. How would i go about finding the xPos and yPos for all the pixels in the picture relative to the application and the screen.
    :
    : If anyone has any idea how to do this or has a better way then I am all ears
    :
    : thx in advance
    :
    :
    : P.S. what about setting pixels too, how could that be implemented?


    VB has its own version of the GetPixel API ("Object.Point") and of the SetPixel API ("Object.PSet"). You don't really need to mess with APIs here. PictureBoxes Objects have both these methods.
    Keep in mind that you should set Autoredraw to true, though.

    As for "pixel position", VB handles that with ScaleMode, ScaleWidth, and ScaleHeight; set a PictureBox's ScaleMode to "Pixels", and ScaleWidth and ScaleHeight will contain the width and height of the PictureBox in pixels.

    Hint: hiding the PictureBox (setting "visible" to false) while drawing will prevent some flickering and speed up the process. Just be sure to hide and show it in the same procedure, which should NOT contain a DoEvents. This will also need the AutoRedraw property to be set to true.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion