Converting RAW .crb emblems into images...

02/28/2014 18:27 Timlock#16
Quote:
Originally Posted by LastThief* View Post
Time to write my own script :3
Code:
function get_emblem($type, $id) {
	global $site_dir, $db_shard;
	$indir = "C:/SRO_CREST/SRO_CREST/";
	$outdir = $site_dir . "emblem/";
	
	$sql = ($type == 'union') ? "SELECT u.CurCrestRev FROM _AlliedClans u WHERE u.ID = '".$id."'" : "SELECT g.CurCrestRev FROM _Guild g WHERE g.ID = '".$id."'";
	if ( !($result = $db_shard->sql_query($sql)) )
	{
		die('could not query emblem data');
	}
	$row = $db_shard->sql_fetchrow($result);
	$file = ($type == 'union') ? "A64_".$id."_".$row['CurCrestRev'] : "G64_".$id."_".$row['CurCrestRev'];
	
	if(!file_exists($outdir.$file.'.bmp'))
	{
		$begin = "secret";
		$color_list = "secret";
		
		$ary = explode(' ', $begin);
		foreach($ary AS $key)
		{
			$content = $content . pack('H*', $key);
		}
		
		$ary_color = explode('-', $color_list);
		foreach($ary_color AS $key)
		{
			$prt = explode('=', trim($key));
			$convert[$prt[0]] = $prt[1];
		}
		
		$hex = unpack("H*", file_get_contents($indir.$file.'.crb'));
		$ary2 = str_split($hex);
		$count=0;
		foreach($hex as $key)
		{
			$ary2 = str_split($key, 2);
			foreach($ary2 as $key2)
			{
				if(empty($convert[$key2])) $convert[$key2] = '000000';
				$ary3 = str_split($convert[$key2], 2);
				$content = $content . pack("H*", $ary3[0]) . pack("H*", $ary3[1]) . pack("H*", $ary3[2]);
				$count++;
			}
		}
		file_put_contents($outdir.$file.".bmp", $content);
	}
	return $outdir.$file.'.bmp';
}
echo '<img src="'.get_emblem('guild', $guild_id).'" width="16" height="16" />';
echo '<img src="'.get_emblem('union', $guild_id).'" width="16" height="16" />';
That should give you some hints...
07/17/2015 21:21 thadox#17
thanks