开发者

How to use Imagick php to generate a bmp file with a palette offset

I'm trying to use Imagick via php to generate a 8bit bmp from jpg. But i would like the pixel colors to start at index 16 rather than 0. The code below shows how to generate the bmp 开发者_JAVA百科in the correct format i need, but the palette index defaults to 0. Is there a way to make sure the palette start at another index?

$average = new Imagick( "icon.jpg" );
$average->setCompression(Imagick::COMPRESSION_NO);
$average->quantizeImage( 32, Imagick::COLORSPACE_RGB, 0, false, false );
imagecolorset ($average, 0, 255, 255, 255);
$average->setImageFormat( "bmp" );

header( "Content-Type: image/bmp" );
echo $average;

$average->clear();
$average->destroy();


I don't think Imagick has anything built in for it, so you would have to create a new palette (copy colors from the old one with an offset) and then use $pixel = $average::getImagePixelColor() and then do $pixel->getColor() and $pixel->setColor() according to the new palette.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜