【发布时间】:2014-04-03 16:26:38
【问题描述】:
我一直致力于使用 PHP 将样本保存为图像,我在这方面取得了先机,到目前为止它保存了第一种颜色、最后一种颜色和黑色 - 但将最后一种颜色迭代三个块。
<?php
$colours = $_GET['c'];
$swatches = explode("|", $colours);
// Create image
$im = imagecreatetruecolor(120, 30);
foreach ($swatches as $key => $rgb_set)
{
if ($rgb_set=="") break;
list($r, $g, $b) = explode(",", $rgb_set);
$x_pos = (24 * $key);
$swatch = imagecolorallocate($im, $r, $g, $b);
imagefilledrectangle($im, $x_pos, 0, 24, 30, $swatch);
}
// Set the content type header
header('Content-Type: image/png');
// Save the image
imagepng($im);
imagedestroy($im);
有谁知道我做错了什么或如何解决这个问题,以便它从调色板下载所有 5 个色板?
【问题讨论】: