Make a XBM picture

Source: Internet
Author: User
Tags define array count
XBM XBM is a simple two-color image Bitmap format, used more in the early CGI, and is currently used on counter
<?php
SETXBM (1234567890,0);

function SETXBM ($num, $mode =0) {
Settype ($num, "string");
$mode = $mode 0xff:0x00;
$int _width = strlen ($num); Number of digits
$count _width=8; Single digit width
$count _height=16; Height

$bitmap = Array (
0 => Array (0xff, 0xFF, 0xFF, 0xc3, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0xc3, 0xFF, 0xFF, 0xFF),
1 => Array (0xFF, 0xFF, 0xFF, 0XCF, 0xc7, 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0xFF, 0xFF, 0xFF),
2 => Array (0xFF, 0xFF, 0xFF, 0xc3, 0x99, 0x9f, 0x9f, 0XCF, 0xe7, 0xf3, 0xf9, 0xf9, 0x81, 0xFF, 0xFF, 0xFF),
3 => Array (0xFF, 0xFF, 0xFF, 0xc3, 0x99, 0x9f, 0x9f, 0xc7, 0x9f, 0x9f, 0x9f, 0x99, 0xc3, 0xFF, 0xFF, 0xFF),
4 => Array (0xFF, 0xFF, 0xFF, 0XCF, 0XCF, 0xc7, 0xc7, 0XCB, 0XCB, 0xCD, 0x81, 0XCF, 0x87, 0xFF, 0xFF, 0xFF),
5 => Array (0xFF, 0xFF, 0xFF, 0x81, 0xf9, 0xf9, 0xf9, 0xc1, 0x9f, 0x9f, 0x9f, 0x99, 0xc3, 0xFF, 0xFF, 0xFF),
6 => Array (0xFF, 0xFF, 0xFF, 0xc7, 0xf3, 0xf9, 0xf9, 0xc1, 0x99, 0x99, 0x99, 0x99, 0xc3, 0xFF, 0xFF, 0xFF),
7 => Array (0xFF, 0xFF, 0xFF, 0x81, 0x99, 0x9f, 0x9f, 0XCF, 0XCF, 0xe7, 0xe7, 0xf3, 0xf3, 0xFF, 0xFF, 0xFF),
8 => Array (0xFF, 0xFF, 0xFF, 0xc3, 0x99, 0x99, 0x99, 0xc3, 0x99, 0x99, 0x99, 0x99, 0xc3, 0xFF, 0xFF, 0xFF),
9 => Array (0xFF, 0xFF, 0xFF, 0xc3, 0x99, 0x99, 0x99, 0x99, 0x83, 0x9f, 0x9f, 0XCF, 0xe3, 0xFF, 0xFF, 0xff)
);

echo "#define Counter_width". ($count _width * $int _width). " \ r \ n ";
echo "#define Counter_height". $count _height. " \ r \ n ";
echo "Static unsigned char counter_bits[] = {\ r \ n";
for ($i =0; $i < $count _height + + $i) {
for ($j = 0; $j < $int _width + + $j) {
printf ("0x%2x,", $bitmap [$num [$j]][$i]^ $mode);
}
}
echo "\ r \ n};";
}
?>


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.