I'm working with an 8x8 1-bit icon to start off with (2-color palette) and can't seem to get it to display correctly. Here's my generation code:
Code: Select all
$image = imagecreatetruecolor($width, $height);
// Create bitmaps
for($i = 0; $i < $length / 2; $i++, $bitslength +=
{
$xorbits .= str_pad(decbin(ord($maps[$i])), 8, '0', STR_PAD_LEFT);
}
for(; $i < $length; $i++)
{
$andbits .= str_pad(decbin(ord($maps[$i])), 8, '0', STR_PAD_LEFT);
}
// Set pixel colors
for($y = $height - 1, $offset = 0; $y >= 0 && $offset < $bitslength; $y--)
{
for($x = 0; $x < $width && $offset < $bitslength; $x++, $offset++)
{
if($andbits[$offset] == 0)
{
imagesetpixel($image, $x, $y, imagecolorexact(255, 255, 255));
}
}
}
header('Content-type: image/png');
imagepng($image);If anyone has any experience in XOR/AND maps or bit manipulation, please offer some advice.