[英]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. 我正在尝试通过php使用Imagick从jpg生成8bit bmp。 But i would like the pixel colors to start at index 16 rather than 0. The code below shows how to generate the bmp 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?
但是我希望像素颜色从索引16而不是0开始。以下代码显示了如何以我需要的正确格式生成bmp,但是调色板索引默认为0。有没有办法确保调色板开始在另一个索引?
$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();
我不认为Imagick内置了任何功能,因此您必须创建一个新的调色板(从具有偏移量的旧调色板中复制颜色),然后使用$pixel = $average::getImagePixelColor()
然后执行$pixel->getColor()
根据新的调色板,选择$pixel->getColor()
和$pixel->setColor()
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.