CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2000
    Location
    Tokyo and Memphis
    Posts
    238

    what color that pixel?

    Hi

    I'd like to click on a point on a photo and for the computer to tell me what value the color of that point is - that cell.

    I'm currently without my books so I'm lost a bit at the moment.

    I'd also like to change the color of a point.

    Any words of wisdom - many thanks. Many, many.

    Phil


  2. #2
    Join Date
    Feb 2001
    Location
    Germany
    Posts
    23

    Re: what color that pixel?


    Hi,

    solutions to get the color could be:

    Private Sub Form_Click ()
    Dim MidColor ' Color of the form center
    MidColor = Point(Width / 2, Height / 2)
    end sub

    and to set the color use object.PSet:

    object.PSet [Step] (x, y), [color]

    Hope that fits,

    mabrin



  3. #3
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: what color that pixel?

    Say the photo is in Picture1. Then, in its MouseDown event, write


    private sub picture1_mousedown(......, X as Single, Y as Single)
    dim col as long, newcol as long
    dim red as byte, green as byte, blue as byte
    'get the pixel value at that point
    col=picture1.point(x,y)
    'Separate them into Red Green and Blue Components
    red=col and &hff
    green=(col and &hff00&)/&h100&
    blue=(col and &hff0000&)/&h10000&
    'Modify the values -- Add a constant to increase the brightness
    red=red+10
    green=green+10
    blue=blue+10
    'Use RGB() to determine the new pixel value
    newcol=RGB(red, green, blue)
    'Write this new pixel with the PSet method
    picture1.pset(x,y),newcol
    end sub





  4. #4
    Join Date
    Nov 2000
    Location
    Tokyo and Memphis
    Posts
    238

    Re: what color that pixel?

    Thanks to all

    I'll try these ideas out

    Again MANY THANKS

    Phil



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured