GD php problem

Hi all,

i have another set of question on it…

i recently have another set of project dealing with gd php. so far im not too good about it and hardly understand the concept. but i hv some example to lead me…

ok here is the problem…

the example show me that im able to create gd image with several thumbnail on top of a base image…
ok this part i still understand it.

but i hv a specific coordinates which nd to locate the thumbnail on it…

So here is my sample gd image render

[php]<?php

//Source image paths (DISCLAIMER: this is just to demonstrate, to generate a real TT map you need 144 of these)
$srcImagePaths = Array(‘C:\ image\default_pic_01.png’,
‘C:\image\default_pic_02.png’,
‘C:\image\default_pic_03.png’,
‘C:\ image\default_pic_04.png’,
‘C:\ image\default_pic_05.png’,
‘C:\image\default_pic_01.png’,
‘C:\ image\default_pic_02.png’,
‘C:\image\default_pic_03.png’,
‘C:\ image\default_pic_04.png’,
‘C:\ image\default_pic_05.png’,
‘C:\ image\default_pic_01.png’,
‘C:\ image\default_pic_02.png’,
‘C:\ image\default_pic_03.png’,
‘C:\image\default_pic_04.png’,
‘C:\ image\default_pic_05.png’);

/*

  • INIT BASE IMAGE FILLED WITH BACKGROUND COLOR
    */

$tileWidth = $tileHeight = 60;
$numberOfTiles = 15;
$pxBetweenTiles = 1;
$leftOffSet = $topOffSet = 5;

$mapWidth = $mapHeight = ($tileWidth + $pxBetweenTiles) * $numberOfTiles;

$mapImage = imagecreatetruecolor($mapWidth, $mapHeight);
$bgColor = imagecolortransparent($mapImage);
imagefill($mapImage, 0, 0, $bgColor);

/*

  • PUT SRC IMAGES ON BASE IMAGE
    */

function indexToCoords($index)
{
global $tileWidth, $pxBetweenTiles, $leftOffSet, $topOffSet, $numberOfTiles;

$x = ($index % 5) * ($tileWidth + $pxBetweenTiles) + $leftOffSet;
$y = floor($index / 5) * ($tileWidth + $pxBetweenTiles) + $topOffSet;
return Array($x, $y);
}

foreach ($srcImagePaths as $index => $srcImagePath)
{
list ($x, $y) = indexToCoords($index);
$tileImg = imagecreatefrompng($srcImagePath);

imagecopy($mapImage, $tileImg, $x, $y, 0, 0, $tileWidth, $tileHeight);
imagesavealpha( $mapImage, true );
imagedestroy($tileImg);
}

/*

  • RESCALE TO THUMB FORMAT
    */
    $thumbImage = imagecreatetruecolor(500, 300);
    imagecopyresampled($thumbImage, $mapImage, 0, 0, 0, 0, $thumbSize, $thumbSize, $mapWidth, $mapWidth);

header (“Content-type: image/png”);
imagepng($thumbImage);

?>[/php]

i have 15 image to render…

below is all my image x and y

{ID:11, X:47,Y:141}, {ID:12, X:127,Y:141}, {ID:13, X:207,Y:141}, {ID:14, X:287,Y:141}, {ID:15, X:367,Y:141},
{ID:6, X:67,Y:91}, {ID:7, X:147,Y:91}, {ID:8, X:227,Y:91}, {ID:9, X:307,Y:91}, {ID:10, X:387,Y:91},
{ID:1, X:87,Y:41}, {ID:2, X:167,Y:41}, {ID:3, X:247,Y:41}, {ID:4, X:327,Y:41}, {ID:5, X:407,Y:41},

as you can see there is an image id on it… so how do it link it too…

thanks for all your big help.

hi

i hv the the data in dynamic array…

something similar like this

Array
(
[0] => Array
(
[gid] => 311
[length] => 408.804653251745
[x] => 112
[y] => 60
)
[1] => Array
(
[gid] => 312
[length] => 4304.33549546129
[x] =>20
[y] => 90
)
[2] => Array
(
[gid] => 313
[length] => 7470.68109219034
[x] => 70
[y] => 130
)
[3] => Array
(
[gid] => 314
[length] => 1926.81240867132
[x] => 55
[y] => 40
)
[4] => Array
(
[gid] => 315
[length] => 1828.52813742386
[x] => 77
[y] => 99
)
)

ok… this is something i i want to present. as for my x n y, i have 15 set of fix x n y coordinates which base on the user position id. if the position is 1, example the fix x n y is 20 , 30.

Sponsor our Newsletter | Privacy Policy | Terms of Service