Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-21-2013, 06:32 PM   PM User | #1
sonny
Regular Coder

 
sonny's Avatar
 
Join Date: Apr 2008
Location: United States
Posts: 567
Thanks: 88
Thanked 0 Times in 0 Posts
sonny can only hope to improve
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
sonny is offline   Reply With Quote
Old 02-21-2013, 06:51 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,640
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Are you talking about using a separate image? You can use imagecopymerge to overlay a part of an image onto another image.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Old 02-21-2013, 07:09 PM   PM User | #3
sonny
Regular Coder

 
sonny's Avatar
 
Join Date: Apr 2008
Location: United States
Posts: 567
Thanks: 88
Thanked 0 Times in 0 Posts
sonny can only hope to improve
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
sonny is offline   Reply With Quote
Old 02-21-2013, 07:53 PM   PM User | #4
sonny
Regular Coder

 
sonny's Avatar
 
Join Date: Apr 2008
Location: United States
Posts: 567
Thanks: 88
Thanked 0 Times in 0 Posts
sonny can only hope to improve
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
sonny is offline   Reply With Quote
Old 02-21-2013, 07:53 PM   PM User | #5
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,640
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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).
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Old 02-21-2013, 07:57 PM   PM User | #6
sonny
Regular Coder

 
sonny's Avatar
 
Join Date: Apr 2008
Location: United States
Posts: 567
Thanks: 88
Thanked 0 Times in 0 Posts
sonny can only hope to improve
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..
sonny is offline   Reply With Quote
Old 02-21-2013, 08:08 PM   PM User | #7
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,640
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Old 02-21-2013, 08:19 PM   PM User | #8
sonny
Regular Coder

 
sonny's Avatar
 
Join Date: Apr 2008
Location: United States
Posts: 567
Thanks: 88
Thanked 0 Times in 0 Posts
sonny can only hope to improve
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
sonny is offline   Reply With Quote
Old 02-21-2013, 08:24 PM   PM User | #9
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,640
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:57 PM.


Advertisement
Log in to turn off these ads.