dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: RGB Values

  1. #1
    Join Date
    Dec 2007
    Posts
    6

    RGB Values

    How do u get the RGB values of any image and display it in a textbox?

    Cheers.
    Last edited by Billie; December 6th, 2007 at 05:38 PM. Reason: needed to add detail

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: RGB Values

    Do you mean a POINT in an image? Color.FromArgb(r,g,b) works to set it
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Dec 2007
    Posts
    6

    Re: RGB Values

    i'll try that method. btw wot i meant was a mousemove method. you know if you move the mouse over an image, it can show the position of x and y (e.g 243, 325) but instead of this i want the rgb values.

    Cheers!

  4. #4
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: RGB Values

    Billie, this is somewhat similar to what you have asked before in this thread. You can use mousemove event handler along with GetPixel method of the bitmap class to get the RGB Value of a specific pixel.

  5. #5
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    1,080

    Re: RGB Values

    I guess the problem is whether or not you know exactly where the mouse is in relation to the image. If the mouse is over a PictureBox then you can get the position in relation to the top, left corner of the PictureBox. It will often be the case that the top, left corner of the PictureBox does not correspond to the top, left corner of the Image. Even if it does, it will often be the case that the Image is not displayed in its original proportions. You need to ensure that these criteria are met in order to use that method. Otherwise you'd have to use an API function I would guess.
    Tutorials: Home & Learn | Start VB.NET | Learn VB.NET | C# Station | GotDotNet | Games in VB.NET 101 Samples: 2002 | 2003 | 2005 | More .NET 2.0 (VB.NET, C#) Articles: VB.NET | C# | ASP.NET | MoreFree Components: WFC | XPCC | ElementsEx | VBPP | Mentalis | ADO.NET/MySQL | VisualStyles | Charting (NPlot, ZedGraph) | iTextSharp (PDF) | SDF (CF) ● Free Literature: VB 2005 (eBook) | VB6 to VB.NET (eBook) | MSDN Magazine (CHM format) ● Bookmarks: MSDN | WinForms .NET | ASP.NET | WinForms FAQ | WebForms FAQ | GotDotNet | Code Project | DevBuzz (CF) ● Code Converter: C#/VB.NET | VB.NET/C# | VS 2005 add-in

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)