Jump to content

problems repeating image in GD


almightyegg

Recommended Posts

<?php

header("Content-type: image/png");

$w = 300;
$h = 200;
$im = ImageCreate($w, $h);

$white = ImageColorAllocate($im, 255,255,255);
$black = ImageColorAllocate($im, 0, 0, 0);
$red = ImageColorAllocate($im, 255, 50, 50);
$green = ImageColorAllocate($im, 30, 100, 30);
$blue = ImageColorAllocate($im, 50, 50, 255);

//	DRAW BACKGROUND
ImageFilledRectangle($im, 0, 0, $w, $h, $black);
ImageFilledRectangle($im, 0, 0, 10, 10, $green);
ImageFilledRectangle($im, 0, 10, 10, 10, $green);
ImageFilledRectangle($im, 0, 20, 10, 10, $green);
ImageFilledRectangle($im, 0, 30, 10, 10, $green);

# Output the image to the browser
ImagePng($im);


?>

 

It only prints 1 green rectangle, the first one....the others are meant to be directly below each other...why aren't they showing???

Link to comment
https://forums.phpfreaks.com/topic/69386-problems-repeating-image-in-gd/
Share on other sites

Wierd, yes it seems to go (w, h, x, y)... I didn't think it did (x, y, w, h) is normal!

<?php

header("Content-type: image/jpeg");

$w = 300;
$h = 200;
//$im = ImageCreate($w, $h);
$im = imagecreatetruecolor($w, $h);

$white = ImageColorAllocate($im, 255,255,255);
$black = ImageColorAllocate($im, 0, 0, 0);
$red = ImageColorAllocate($im, 255, 50, 50);
$green = ImageColorAllocate($im, 30, 100, 30);
$blue = ImageColorAllocate($im, 50, 50, 255);

//	DRAW BACKGROUND
ImageFilledRectangle($im, 0, 0, $w, $h, $black);
ImageFilledRectangle($im, 50, 2, 10, 10, $red);
ImageFilledRectangle($im, 0, 24, 10, 10, $blue);
ImageFilledRectangle($im, 30, 36, 10, 10, $green);

# Output the image to the browser
imagejpeg($im);
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.