GD copy an image...
Posted: Sun Dec 17, 2006 7:03 pm
Alright, im working on a map generater code bit. It uses GD and positioning data to place objects and such on the map image. The map image is also started off by being applyed a background, from the background file. Which is looped multiple times throughout the destination image. But for now, I just need to create the map image thats 512 x 384 px, I need to place the 16x16 jpg image at position 0,0 on the map image, and I need to write the map .jpg as map.jpg on the server.
Ive been reading tutorials and keep getting stuck, heres what I have.
And I get the error: The image "http://localhost/map_prototype.php?do=add" cannot be displayed, because it contains errors.
Ive tried several things with no luck. I cant figure out what any of this is doing, Or even how to display my page as well as create this image, as this is ignoring the HTML completely.
Ive been reading tutorials and keep getting stuck, heres what I have.
Code: Select all
$bg = 'tiles/littleroot/bg.jpg';
// start gd
header ("Content-type: image/png");
$img = imagecreatetruecolor(512, 384) or die("Cannot Initialize new GD image stream.");
imagecopy($img, $bg, 0, 0, 0, 0, 16, 16);
imagejpeg($img, 'map.jpg');
imagedestroy($img);Ive tried several things with no luck. I cant figure out what any of this is doing, Or even how to display my page as well as create this image, as this is ignoring the HTML completely.