Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    Regular Coder sonny's Avatar
    Join Date
    Apr 2008
    Location
    United States
    Posts
    567
    Thanks
    88
    Thanked 0 Times in 0 Posts

    use image instaed of rectangle on map

    Hi, I currently use this line to create a tiny red dot plotted on a world map
    anyone know how I can use a dot image instead?

    PHP Code:
    $dotcolor imagecolorallocate ($im255,0,0);//red
    imagefilledrectangle($im,$pt["x"]-2,$pt["y"]-2,$pt["x"]+2,$pt["y"]+2,$dotcolor); 
    Thanks
    Sonny

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,980
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Are you talking about using a separate image? You can use imagecopymerge to overlay a part of an image onto another image.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    Regular Coder sonny's Avatar
    Join Date
    Apr 2008
    Location
    United States
    Posts
    567
    Thanks
    88
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    Are you talking about using a separate image? You can use imagecopymerge to overlay a part of an image onto another image.

    I'm trying to do exactly this below on a world map image, only with a dot image instaed
    PHP Code:
    imagefilledrectangle($im,$pt["x"]-2,$pt["y"]-2,$pt["x"]+2,$pt["y"]+2,$dotcolor); 
    Thanks
    Sonny

  • #4
    Regular Coder sonny's Avatar
    Join Date
    Apr 2008
    Location
    United States
    Posts
    567
    Thanks
    88
    Thanked 0 Times in 0 Posts
    PHP Code:
    imagefilledrectangle($im,$pt["x"]-2,$pt["y"]-2,$pt["x"]+2,$pt["y"]+2,$dotcolor);// WORKS

    imagecopymerge resource $dst_im resource $src_im int $dst_x int $dst_y int $src_x int $src_y int $src_w int $src_h int $pct )
    imagecopymerge($imdot.png$pt["x"]-2$pt["y"]-2$pt["x"]+2,$pt["y"]+2110); 
    Fou, that seems to be what I need
    But can't get this to work, having a hard time transferring the values from imagefilledrectangle
    over to imagecopymerge,

    Sonny

  • #5
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,980
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    So not an external image?
    Just use the imagefilledellipse method. The method is almost identical to the rectangle, but you provide w/h instead of end x/y. You can use some pi with the existing points to calculate the width (and height would be the same if you want a circle instead of an ellipse).
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #6
    Regular Coder sonny's Avatar
    Join Date
    Apr 2008
    Location
    United States
    Posts
    567
    Thanks
    88
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    So not an external image?
    Just use the imagefilledellipse method. The method is almost identical to the rectangle, but you provide w/h instead of end x/y. You can use some pi with the existing points to calculate the width (and height would be the same if you want a circle instead of an ellipse).
    It is a external image named dot.png
    and the blank world map is a image as well.

    I would like to use a dot image,
    just need help transferring the values from rectangle above if anyone knows how
    please show me.

    Thanks
    Sonny
    Last edited by sonny; 02-21-2013 at 08:01 PM.

  • #7
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,980
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Oh I see you posted one just before I.
    image merging requires two image resources, so the second image needs to be opened with a createImageFrom* call to get a separate resource. Then you provide the arguments for x/y starting points on the destination, the source' x/y, and width/height arguments (presumably the full image?), and finally the alpha.
    If you need to make use of 2 sets of x/y components for a size like you had in the other one, you'll probably need to scale the dot's image resource prior to merging it. I don't think the resize works at a scaling level, but I could be wrong on that.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #8
    Regular Coder sonny's Avatar
    Join Date
    Apr 2008
    Location
    United States
    Posts
    567
    Thanks
    88
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    Oh I see you posted one just before I.
    image merging requires two image resources, so the second image needs to be opened with a createImageFrom* call to get a separate resource. Then you provide the arguments for x/y starting points on the destination, the source' x/y, and width/height arguments (presumably the full image?), and finally the alpha.
    If you need to make use of 2 sets of x/y components for a size like you had in the other one, you'll probably need to scale the dot's image resource prior to merging it. I don't think the resize works at a scaling level, but I could be wrong on that.
    Well, was worth a try, guess I will just stay with imagefilledrectangle, did not know it was
    that complicated, thought I could transfer the values over to imagecopymerge and create
    a simple 1x1 red image. if anyone familer working with imagecopymerge can show me how
    to correctly use a dot image as I currently do now with imagefilledrectangle, please let me
    know.

    Sonny

  • #9
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,980
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    See now I'm a bit confused.
    1x1 red image (solid I assume?) doesn't need a separate image for it. I thought that dot.png would be an external image, but if you are only working with a 1x1 (square) image, I don't see any reason to make a change.
    If you're talking about 'dot' being a circle, than use what I suggested with imagefilledellipse.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Posting Permissions

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