heb beetje zitten kloojen met deze code, maar denk dat het beter moet kunnen
<?php
/*
* Copyright Bill Zeller, Minimal Verbosity.com
*
* Steal this code.
*
*/
function ImageColorAllocateHex( $image, $hex ) {
for( $i=0; $i<3; $i++ ) {
$temp = substr($hex, 2*$i, 2);
$rgb[$i] = 16 * hexdec( substr($temp, 0, 1) ) + hexdec(substr($temp, 1, 1));
}
$rgb = ImageColorAllocate ( $image, $rgb[0], $rgb[1], $rgb[2] );
return $rgb;
}
function getRGB($hex ) {
for( $i=0; $i<3; $i++ ) {
$temp = substr($hex, 2*$i, 2);
$rgb[$i] = 16 * hexdec( substr($temp, 0, 1) ) + hexdec(substr($temp, 1, 1));
}
return $rgb;
}
header ("Content-type: image/png");
$im = @imagecreatetruecolor(80, 15) or die ("Cannot Initialize new GD image stream");
imagerectangle($im, 0, 0, 79, 14, ImageColorAllocateHex($im, isset($outerBorder)?$outerBorder:"666666"));
imagerectangle($im, 1, 1, 78, 13, ImageColorAllocateHex($im, isset($innerBorder)?$innerBorder:"ffffff"));
$barPosition = isset($barPosition)?$barPosition:25;
imageline ($im, $barPosition, 1, $barPosition, 12, ImageColorAllocateHex($im, isset($innerBorder)?$innerBorder:"ffffff"));
imagefilledrectangle($im, 2, 2, $barPosition-1, 12, ImageColorAllocateHex($im, isset($leftFill)?$leftFill:"ff6600"));
imagefilledrectangle($im, $barPosition+1, 2, 77, 12, ImageColorAllocateHex($im, isset($rightFill)?$rightFill:"898E79"));
$images[65] = array("x"=>0, "y"=>0, "w"=>6);
$images[66] = array("x"=>6, "y"=>0, "w"=>6);
$images[67] = array("x"=>12, "y"=>0, "w"=>6);
$images[68] = array("x"=>18, "y"=>0, "w"=>6);
$images[69] = array("x"=>24, "y"=>0, "w"=>5);
$images[70] = array("x"=>29, "y"=>0, "w"=>5);
$images[71] = array("x"=>34, "y"=>0, "w"=>6);
$images[72] = array("x"=>40, "y"=>0, "w"=>6);
$images[73] = array("x"=>46, "y"=>0, "w"=>3);
$images[74] = array("x"=>49, "y"=>0, "w"=>6);
$images[75] = array("x"=>55, "y"=>0, "w"=>6);
$images[76] = array("x"=>61, "y"=>0, "w"=>5);
$images[77] = array("x"=>66, "y"=>0, "w"=>7);
$images[78] = array("x"=>73, "y"=>0, "w"=>7);
$images[79] = array("x"=>80, "y"=>0, "w"=>6);
$images[80] = array("x"=>86, "y"=>0, "w"=>6);
$images[81] = array("x"=>92, "y"=>0, "w"=>6);
$images[82] = array("x"=>98, "y"=>0, "w"=>6);
$images[83] = array("x"=>104, "y"=>0, "w"=>6);
$images[84] = array("x"=>110, "y"=>0, "w"=>5);
$images[85] = array("x"=>115, "y"=>0, "w"=>6);
$images[86] = array("x"=>121, "y"=>0, "w"=>7);
$images[87] = array("x"=>128, "y"=>0, "w"=>7);
$images[88] = array("x"=>135, "y"=>0, "w"=>7);
$images[89] = array("x"=>142, "y"=>0, "w"=>7);
$images[90] = array("x"=>149, "y"=>0, "w"=>5);
$images[32] = array("x"=>154, "y"=>0, "w"=>4);
$images[49] = array("x"=>0, "y"=>10, "w"=>5);
$images[50] = array("x"=>5, "y"=>10, "w"=>6);
$images[51] = array("x"=>11, "y"=>10, "w"=>6);
$images[52] = array("x"=>17, "y"=>10, "w"=>6);
$images[53] = array("x"=>23, "y"=>10, "w"=>6);
$images[54] = array("x"=>29, "y"=>10, "w"=>6);
$images[55] = array("x"=>35, "y"=>10, "w"=>6);
$images[56] = array("x"=>41, "y"=>10, "w"=>6);
$images[57] = array("x"=>47, "y"=>10, "w"=>6);
$images[48] = array("x"=>53, "y"=>10, "w"=>6);
$images[33] = array("x"=>59, "y"=>10, "w"=>3);// !
$images[64] = array("x"=>62, "y"=>10, "w"=>7);// @
$images[35] = array("x"=>69, "y"=>10, "w"=>7);// #
$images[36] = array("x"=>76, "y"=>10, "w"=>6);// $
$images[37] = array("x"=>82, "y"=>10, "w"=>7);// %
$images[94] = array("x"=>89, "y"=>10, "w"=>5);// ^
$images[38] = array("x"=>94, "y"=>10, "w"=>6);// &
$images[42] = array("x"=>100, "y"=>10, "w"=>7);// *
$images[40] = array("x"=>107, "y"=>10, "w"=>4);// (
$images[41] = array("x"=>111, "y"=>10, "w"=>4);// )
$images[95] = array("x"=>115, "y"=>10, "w"=>6);// _
$images[43] = array("x"=>121, "y"=>10, "w"=>7);// +
$images[96] = array("x"=>128, "y"=>10, "w"=>4);// `
$images[126] = array("x"=>132, "y"=>10, "w"=>6);// ~
$images[91] = array("x"=>138, "y"=>10, "w"=>4);// [
$images[93] = array("x"=>142, "y"=>10, "w"=>4);// ]
$images[92] = array("x"=>146, "y"=>10, "w"=>5);// \
$images[123] = array("x"=>151, "y"=>10, "w"=>5);// {
$images[125] = array("x"=>156, "y"=>10, "w"=>5);// }
$images[124] = array("x"=>161, "y"=>10, "w"=>3);// |
$images[59] = array("x"=>164, "y"=>10, "w"=>4);// ;
$images[58] = array("x"=>168, "y"=>10, "w"=>3);// :
$images[39] = array("x"=>171, "y"=>10, "w"=>3);// '
$images[34] = array("x"=>174, "y"=>10, "w"=>5);// "
$images[44] = array("x"=>179, "y"=>10, "w"=>4);// ,
$images[46] = array("x"=>183, "y"=>10, "w"=>3);// .
$images[47] = array("x"=>186, "y"=>10, "w"=>5);// /
$images[60] = array("x"=>191, "y"=>10, "w"=>5);// <
$images[62] = array("x"=>196, "y"=>10, "w"=>5);// >
$images[63] = array("x"=>201, "y"=>10, "w"=>6);// ?
$images[61] = array("x"=>207, "y"=>10, "w"=>5);// =
$letters = imagecreatefrompng("silkscreen/font.png");
$rgb = getRGB(isset($leftTextColor)?$leftTextColor:"ffffff");
$index = imagecolorexact($letters, 0, 0, 0);
imagecolorset ($letters, $index, $rgb[0], $rgb[1], $rgb[2]);
$leftText = isset($leftText)?stripslashes(strtoupper($leftText)):"RSS";
$leftPos = isset($leftTextPosition)?$leftTextPosition:5;
for($i=0;$i<strlen($leftText);$i++){
$c = ord($leftText[$i]);
imagecopy ($im, $letters, $leftPos, 5, $images[$c]["x"], $images[$c]["y"], $images[$c]["w"], 6);
$leftPos+=$images[$c]["w"];
}
$letters = imagecreatefrompng("silkscreen/font.png");
$rgb = getRGB(isset($rightTextColor)?$rightTextColor:"ffffff");
$index = imagecolorexact($letters, 0, 0, 0);
imagecolorset ($letters, $index, $rgb[0], $rgb[1], $rgb[2]);
$rightText = isset($rightText)?stripslashes(strtoupper($rightText)):"VALID";
$rightPos = isset($rightTextPosition)?$rightTextPosition:29;
for($i=0;$i<strlen($rightText);$i++){
$c = ord($rightText[$i]);
imagecopy ($im, $letters, $rightPos, 5, $images[$c]["x"], $images[$c]["y"], $images[$c]["w"], 6);
$rightPos+=$images[$c]["w"];
}
imagepng ($im);
?>
Link gekopieerd
?
Onbekende gebruiker
16-02-2006 23:41
ik weet (bijna) niks van GD maar ik zou zeggen dat je gewoon een template moet hebben, een soort van standaard voorbeeldje meot hebben waar GD dan een text op plaatst
Link gekopieerd
Het is een behoorlijk uitgebreid formulier, dus je kunt er van uit gaan dat daar een hele lap code achter zit. Zo'n script maak je niet ff in een half uurtje.
Link gekopieerd
deze code is het toch die de juiste werking geeft, aleen vraag ik mij af of het zou korter kunnen indien ik die png met de letters vervang door een tff font.
ik weet enkel niet hoe het aaan te passen
Link gekopieerd