Color Selector

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ragnar
    New Member
    • May 2007
    • 2

    Color Selector

    The follow code enables users to select colors by clicking on an image:

    [CODE=php]
    <? php
    $im = imagecreatefrom jpeg("ColorWhee l.jpg");
    $x = $img1_x;
    $y = $img1_y;
    $clr1 = dechex(ImageCol orAt($im, $x, $y));
    php ?>

    <html>
    <form action = "pig.php">
    <input type="image" name="img1" height="350" width="350" src="ColorWheel .jpg"></p>
    </form>
    </html>
    [/CODE]

    Although it works, it is rather cumbersome in that the page must refresh to retrieve the selected color. Is there a way to replicate the "ImageColor At" command using Java - perhaps initiated by a mouseover?

    Any help/advice would be greatly appreciated - I have been trying to find a solution for a very long time. Thank you very much in advance
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, Ragnar. Welcome to TSDN!

    I'm moving your post to the JavaScript forum, where you'll get more relevant exposure.

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      Originally posted by Ragnar
      Is there a way to replicate the "ImageColor At" command using Java - perhaps initiated by a mouseover?
      Yes, this is possible using javascript.

      Save the PHP that returns the colors in a separate file. Read up on AJAX by checking out the tutorial links in the Offsite Links thread.

      You will need to pass the image and the current x and y co-ordinates. For the position of the mouse, see link.

      Comment

      • Ragnar
        New Member
        • May 2007
        • 2

        #4
        Originally posted by acoder
        Yes, this is possible using javascript.

        Save the PHP that returns the colors in a separate file. Read up on AJAX by checking out the tutorial links in the Offsite Links thread.

        You will need to pass the image and the current x and y co-ordinates. For the position of the mouse, see link.
        Thank you very much ACODER. Give me some time to study the links you gave me and I'll tell you how it works out. I really appreciate it!

        Comment

        Working...