Programs that generate PNG images of the current time without using the GD Library
Source: Internet
Author: User
Programs that do not use the GD library to generate PNG format images of the current time. this program does not use the GD library to generate PNG format images of the current time, which is very helpful to people. how can teaman organize? Phpfunctionset_4pixel ($ r, $ g, $ B, $ x, $ y) {global $ sx, $ sy, $ pixels; $ ofs3 * ($ sx * $ y + $ x); $ pixels [$ ofs] chr ($ r programs that generate PNG images of the current time without using the GD Library
This program can generate PNG format images of the current time without using the GD Library, which is of great reference to teaman.
Function set_4pixel ($ r, $ g, $ B, $ x, $ y)
{
Global $ sx, $ sy, $ pixels;
$ Ofs = 3 * ($ sx * $ y + $ x );
$ Pixels [$ ofs] = chr ($ r );
$ Pixels [$ ofs + 1] = chr ($ g );
$ Pixels [$ ofs + 2] = chr ($ B );
$ Pixels [$ ofs + 3] = chr ($ r );
$ Pixels [$ ofs + 4] = chr ($ g );
$ Pixels [$ ofs + 5] = chr ($ B );
$ Ofs + = 3 * $ sx;
$ Pixels [$ ofs] = chr ($ r );
$ Pixels [$ ofs + 1] = chr ($ g );
$ Pixels [$ ofs + 2] = chr ($ B );
$ Pixels [$ ofs + 3] = chr ($ r );
$ Pixels [$ ofs + 4] = chr ($ g );
$ Pixels [$ ofs + 5] = chr ($ B );
}
// Function for generating digital images
Function draw2digits ($ x, $ y, $ number)
{
Draw_digit ($ x, $ y, (int) ($ number/10 ));
Draw_digit ($ x + 11, $ y, $ number % 10 );
}
Function draw_digit ($ x, $ y, $ digit)
{
Global $ sx, $ sy, $ pixels, $ digits, $ lines;
// Add the result to $ result
$ Result. = $ chunk;
}
// Main program
$ Sx = 80;
$ Sy = 21;
$ Pixels = "";
// Fill
For ($ h = 0; $ h <$ sy; $ h ++ ){
For ($ w = 0; $ w <$ sx; $ w ++ ){
$ R = 100/$ sx * $ w + 155;
$ G = 100/$ sy * $ h + 155;
$ B = 255-(100/($ sx + $ sy) * ($ w + $ h ));
$ Pixels. = chr ($ r );
$ Pixels. = chr ($ g );
$ Pixels. = chr ($ B );
}
}
$ Date = getdate ();
$ S = $ date ["seconds"];
$ M = $ date ["minutes"];
$ H = $ date ["hours"];
$ Digits = array (95, 5,118,117, 45,121,123, 69,127,125 );
$ Lines = array (1, 1, 1, 2, 0, 1, 0, 2, 1, 0, 1, 1, 0, 0, 0, 1, 0, 2, 1, 2, 0, 1, 1, 1, 0, 0, 1, 0 );
// Create a cyclic verification table
$ Z =-306674912; // = 0xedb88320
For ($ n = 0; $ n <256; $ n ++ ){
$ C = $ n;
For ($ k = 0; $ k <8; $ k ++ ){
$ C2 = ($ c> 1) & 0x7fffffff;
If ($ c & 1) $ c = $ z ^ ($ c2); else $ c = $ c2;
}
$ Crc_table [$ n] = $ c;
}
// Do not translate the text below. please refer to it yourself
// Scanline:
// Filter byte: 0 = none
// RGB bytes for the line
// The scanline is compressed with "zlib", method 8 (RFC-1950 ):
// Compression method/flags code: 1 byte ($78 = method 8, 32 k window)
// Additional flags/check bits: 1 byte ($01: FCHECK = 1, FDICT = 0, FLEVEL = 0)
// Compressed data blocks: n bytes
// One block (RFC-1951 ):
// Bit 0: BFINAL: 1 for the last block
// Bit 1 and 2: BTYPE: 0 for no compression
// Next 2 bytes: LEN (LSB first)
// Next 2 bytes: one's complement of LEN
// LEN bytes uncompressed data
// Check value: 4 bytes (Adler-32 checksum of the uncompressed data)
//
$ Len = ($ sx * 3 + 1) * $ sy;
$ Data = pack ("c *", 0x78, 0x01,
1,
$ Len & 255,
($ Len> 8) & 255,
255-($ len & 255 ),
255-($ len> 8) & 255 ));
$ Start = strlen ($ data );
$ I2 = 0;
For ($ h = 0; $ h <$ sy; $ h ++ ){
$ Data. = chr (0 );
For ($ w = 0; $ w <$ sx * 3; $ w ++ ){
$ Data. = $ pixels [$ i2 ++];
}
}
// Calculate a Adler32 checksum with the bytes data [start .. len-1]
$ S1 = 1;
$ S2 = 0;
For ($ n = $ start; $ n <strlen ($ data); $ n ++ ){
$ S1 = ($ s1 + ord ($ data [$ n]) % 65521;
$ S2 = ($ s2 + $ S1.) % 65521;
}
$ Adler = ($ s2 <16) | $ s1;
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.