CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   PHP (http://www.codingforums.com/forumdisplay.php?f=6)
-   -   use image instaed of rectangle on map (http://www.codingforums.com/showthread.php?t=288073)

sonny 02-21-2013 06:32 PM

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

Fou-Lu 02-21-2013 06:51 PM

Are you talking about using a separate image? You can use imagecopymerge to overlay a part of an image onto another image.

sonny 02-21-2013 07:09 PM

Quote:

Originally Posted by Fou-Lu (Post 1315062)
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

sonny 02-21-2013 07:53 PM

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

Fou-Lu 02-21-2013 07:53 PM

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).

sonny 02-21-2013 07:57 PM

Quote:

Originally Posted by Fou-Lu (Post 1315080)
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

Fou-Lu 02-21-2013 08:08 PM

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.

sonny 02-21-2013 08:19 PM

Quote:

Originally Posted by Fou-Lu (Post 1315085)
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

Fou-Lu 02-21-2013 08:24 PM

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.


All times are GMT +1. The time now is 01:23 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.