<?php

// When there is images/module_icon_custom.png
if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $mydirname .'/images/module_icon_custom.png')) {
	$use_custom_icon = TRUE;
	$icon_fullpath = XOOPS_ROOT_PATH . '/modules/' . $mydirname .'/images/module_icon_custom.png';
} else {	//Write dirname in blank icon
	$use_custom_icon = FALSE;
	$icon_fullpath = dirname(__FILE__) . '/images/module_icon.png';
}

//------------------------------------------
header("Content-type: image/png");

if (! $use_custom_icon && 
	function_exists('imagecreatefrompng') && function_exists('imagecolorallocate') && 
	function_exists('imagestring') && function_exists('imagepng')) 
{

	$im = imagecreatefrompng($icon_fullpath);
	$color = imagecolorallocate($im, 0, 0, 0); // black
	$px = ( 92 - 6 * strlen( $mydirname ) ) / 2 ;
	imagestring($im, 2, $px, 35, $mydirname, $color);
	imagepng($im);
	imagedestroy($im);

} else {
	readfile($icon_fullpath);
}
