पीएचपी बीएमपी के लिए छवि कार्यों में निर्माण किया है नहीं है।
ऐसा करने के लिए कार्य करने के कुछ प्रयास किए गए हैं।
आप पीएचपी दस्तावेज में इस टिप्पणी में एक मजबूत और अच्छी तरह से प्रलेखित संस्करण पा सकते हैं: http://www.php.net/manual/en/function.imagecreatefromwbmp.php#86214
यहाँ उत्कृष्ट प्रलेखन के बिना उस टिप्पणी से समारोह जो बहुत लंबे समय तक है, लेकिन बहुत अधिक पठनीय बनाता है:
public function imagecreatefrombmp($p_sFile)
{
$file = fopen($p_sFile,"rb");
$read = fread($file,10);
while(!feof($file)&&($read<>""))
$read .= fread($file,1024);
$temp = unpack("H*",$read);
$hex = $temp[1];
$header = substr($hex,0,108);
if (substr($header,0,4)=="424d")
{
$header_parts = str_split($header,2);
$width = hexdec($header_parts[19].$header_parts[18]);
$height = hexdec($header_parts[23].$header_parts[22]);
unset($header_parts);
}
$x = 0;
$y = 1;
$image = imagecreatetruecolor($width,$height);
$body = substr($hex,108);
$body_size = (strlen($body)/2);
$header_size = ($width*$height);
$usePadding = ($body_size>($header_size*3)+4);
for ($i=0;$i<$body_size;$i+=3)
{
if ($x>=$width)
{
if ($usePadding)
$i += $width%4;
$x = 0;
$y++;
if ($y>$height)
break;
}
$i_pos = $i*2;
$r = hexdec($body[$i_pos+4].$body[$i_pos+5]);
$g = hexdec($body[$i_pos+2].$body[$i_pos+3]);
$b = hexdec($body[$i_pos].$body[$i_pos+1]);
$color = imagecolorallocate($image,$r,$g,$b);
imagesetpixel($image,$x,$height-$y,$color);
$x++;
}
unset($body);
return $image;
}
स्रोत
2010-10-29 04:09:02
हां, इस PHP मैनपेज पर एक नज़र डालें - इसमें बहुत सारे समाधान दिए गए हैं: http://us.php.net/manual/en/function.imagecreatefromwbmp.php – leepowers
बहुत बहुत धन्यवाद !! –