Location: PHPKode > scripts > Html_graph.php > html_graph-php/Gifpix.class.php
<?PHP
// Class GifPix and Function Hex2Bin
// By Roberto Bertó <hide@address.com> under GPL license. 
// Free like Linux!

/**
 * A class to create 1x1 size gif image without GD. 
 * @author Roberto Bertó
*/

class Gifpix {
	
	// PRIVATE VARS
	
	var $ini = '47494638396101000100f70000';
	var $end;
	var $nor = '2c000000000100010000080400010404003b';
	var $inc = '21f90401000000002c000000000100010000080400010404003b';

/**
 * Constructor of the class Gifpix.
 * @public
 * @returns void
 */	
	function gifpix () {
		$this->end = str_repeat('f',1530);
	}

/**
 * Internal function.
 * @private
 * @returns string
 */	
	function hex2bin ($s) {
		$n = strlen($s);
		if ($n % 2 != 0) { return FALSE; }

		$t = "";
		for ($x = 1; $x <= $n/2; $x++) {
			$t .= chr(hexdec(substr($s,2* $x - 2,2)));
		}
		return $t;

	}

/**
 * function to create the image.
 * @public
 * @returns string
 */	
	function create ($color,$incolor = 0) {
		$hex = $this->ini;
		$hex .= $color;
		$hex .= $this->end;
		if ($incolor == 1) { $hex .= $this->inc; }
		else { $hex .= $this->nor; }
		return $this->hex2bin($hex);
	}
}
?>
Return current item: Html_graph.php