-
-
/** - * Create bmp format pictures
- *
- * @author: legend
- * @description: create Bitmap-File with GD library
- * @version: 0.1
- *
- * @param resource $im image resource
- * @param string $filename If you want to save as a file, please specify the file name. If it is empty, it will be output directly in the browser
- * @param integer $bit image quality (1, 4, 8, 16, 24, 32 bits)
- * @param integer $compression compression Mode, 0 means no compression, 1 uses RLE8 compression algorithm for compression
- *
- * @return integer
- */
- function imagebmp(&$im, $filename = ”, $bit = 8, $compression = 0)
- {
- if (!in_array($bit, array(1, 4, 8, 16, 24, 32)))
- {
- $bit = 8;
- }
- else if ($bit == 32) // todo:32 bit
- {
- $bit = 24;
- }
$bits = pow(2, $bit);
// 调整调色板
- imagetruecolortopalette($im, true, $bits);
- $width = imagesx($im);
- $height = imagesy($im);
- $colors_num = imagecolorstotal($im);
if ($bit <= 8)
- {
- // 颜色索引
- $rgb_quad = ”;
- for ($i = 0; $i < $colors_num; $i ++)
- {
- $colors = imagecolorsforindex($im, $i);
- $rgb_quad .= chr($colors['blue']) . chr($colors['green']) . chr($colors['red']) . “
|