Skip to content

Instantly share code, notes, and snippets.

@yoya
Created July 13, 2016 12:52
Show Gist options
  • Save yoya/3370e1e96fcd7b6083d90a7ab12606f3 to your computer and use it in GitHub Desktop.
Save yoya/3370e1e96fcd7b6083d90a7ab12606f3 to your computer and use it in GitHub Desktop.
RGB444 の色を全部使うだけの画像
<?php
ini_set("memory_limit", '2G');
$nPixels = pow(2, 4 + 4 + 4);
$width = (int) sqrt($nPixels);
$height = $nPixels /$width;
$im = imagecreatetruecolor($width, $height);
if (! $im) {
echo "im is false";
exit (1);
}
$x = 0;
$y = 0;
for ($r = 0 ; $r < 0x100 ; $r+=0x11) {
// echo "r:$r\n";
for ($g = 0 ; $g < 0x100 ; $g+=0x11) {
// echo "g:$g\n";
for ($b = 0 ; $b < 0x100 ; $b+=0x11) {
// echo "b:$b\n";
$c = imagecolorallocate($im, $r, $g, $b);
imagesetpixel($im, $x, $y, $c);
$x++;
if ($width <= $x) {
$x = 0;
$y++;
}
}
}
}
imagepng($im);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment