Exemplo n.º 1
0
        } else {
            header('Content-Type: image/png');
        }
        $myImage = imagecreatetruecolor(self::WIDTH, self::HEIGHT);
        if (false !== $myImage) {
            $color = imagecolorallocate($myImage, 255, 0, 0);
            for ($i = 0; $i < self::WIDTH; $i++) {
                $color = imagecolorallocate($myImage, $i, 255 - $i, 0);
                if (false !== $color) {
                    imageline($myImage, 0, self::HEIGHT - 1, $i, 0, $color);
                }
                $color = imagecolorallocate($myImage, $i, 0, 255 - $i);
                if (false !== $color) {
                    imageline($myImage, self::WIDTH - 1, 0, self::WIDTH - 1 - $i, self::HEIGHT - 1, $color);
                }
            }
            $color = imagecolorallocate($myImage, 0, 0, 255);
            imagestring($myImage, 4, 10, 30, 'Hello', $color);
            $color = imagecolorallocate($myImage, 255, 255, 255);
            imagestring($myImage, 4, 10, 50, 'C# to PHP is fantastic', $color);
            if ($jpg) {
                imagejpeg($myImage, null, $compression);
            } else {
                imagepng($myImage);
            }
            imagedestroy($myImage);
        }
    }
}
DynamicImage::PhpMain();