<?
class image
{//DigiHex Systems\\


	function init() {}


	function img($src, $margin_left=0, $margin_right=0) {
		return '<img src="'.$src.'" alt="" '.($margin_left!=0 || $margin_right!=0 ? 'style="'.($margin_left>0 ? 'margin-left:'.$margin_left.'px;':'').($margin_right>0 ? 'margin-right:'.$margin_right.'px;':'').'" ':'').'/>';
	}


	function flag($src, $margin_left=0, $margin_right=0, $tip=false) {
		global $X;

		$tip=(!empty($tip) ? $X->FORM->tip($tip).' ':'');
		return '<img src="/admin/images/flags/'.strtolower($src).'.gif" '.$tip.'alt="" '.($margin_left!=0 || $margin_right!=0 ? 'style="'.($margin_left>0 ? 'margin-left:'.$margin_left.'px;':'').($margin_right>0 ? 'margin-right:'.$margin_right.'px;':'').'" ':'').'/>';
	}


	function flag2($src, $margin_left=0, $margin_right=8, $tip=false) {
		global $X;

		$tip=(!empty($tip) ? $X->FORM->tip($tip).' ':'');
		return '<img src="/admin/images/flags/'.strtolower($src).'.gif" '.$tip.'alt="" '.($margin_left!=0 || $margin_right!=0 ? 'style="border:1px solid #ccc; '.($margin_left>0 ? 'margin-left:'.$margin_left.'px;':'').($margin_right>0 ? 'margin-right:'.$margin_right.'px;':'').'" ':'').'/>';
	}



	function tick($bool, $margin_left=0, $margin_right=0) {
		$img=((int)$bool==0 ? 'tick-no.gif' : 'tick-yes.gif');
		return '<img src="'.ICONS.'/button/'.$img.'" alt="" '.($margin_left!=0 || $margin_right!=0 ? 'style="'.($margin_left>0 ? 'margin-left:'.$margin_left.'px;':'').($margin_right>0 ? 'margin-right:'.$margin_right.'px;':'').'" ':'').'/>';
	}


	function del($post, $dir) {
		global $X;
		$file=$_POST[$post];
		if(empty($file)) return false;

		@unlink($dir.$file);
		@unlink($dir.$X->FILE->add_suffix($file,'_'));
		@unlink($dir.$X->FILE->add_suffix($file,'__'));
		@unlink($dir.$X->FILE->add_suffix($file,'___'));
		@unlink($dir.$X->FILE->add_suffix($file,'____'));
		@unlink($dir.$X->FILE->add_suffix($file,'_____'));
		@unlink($dir.$X->FILE->add_suffix($file,'______'));
		return true;
	}


	function resize($src, $sizes) {
		return require($this->PATH.'/resize.php');
	}


	function resize_free($src, $sizes) {
		return require($this->PATH.'/resize_free.php');
	}


	function rotate($src, $angle, $param) {
		return require($this->PATH.'/rotate.php');
	}


	function GIF_info($file_name) {
		$fp			= fopen($file_name,'rb');
		$result		= @fread($fp,13);
		if(empty($result)) return false;
		$signature	= substr($result,0,3);
		$version		= substr($result,3,3);
		$width		= ord(substr($result,6,1)) + ord(substr($result,7,1))*256;
		$height		= ord(substr($result,8,1)) + ord(substr($result,9,1))*256;
		$color_flag	= ord(substr($result,10,1)) >> 7;
		$bg			= ord(substr($result,11));

		if($color_flag) {
			$tableSizeNeeded 	= ($bg+1)*3;
			$result 				= fread($fp, $tableSizeNeeded);
			$transparentRed	= ord(substr($result, $bg*3, 1));
			$transparentGreen	= ord(substr($result, $bg*3+1, 1));
			$transparentBlue	= ord(substr($result, $bg*3+2, 1));
		}
		fclose($fp);

		return array(
			'version'			=> $version,
			'color_flag' 		=> $color_flag,
			'transparent_r' 	=> $transparentRed,
			'transparent_g'	=> $transparentGreen,
			'transparent_b' 	=> $transparentBlue,
			'width' 				=> $width,
			'height' 			=> $height,
		);
	}


}//DigiHex Systems\\
?>