php将bmp格式图片转换成jpg格式程序 - php函数
来源:自学PHP网
时间:2014-11-25 00:26 作者:
阅读:次
[导读] functionimagebmp($img,$file=,$rle=0){$colorcount=imagecolorstotal($img);$transparent=imagecolortransparent($img);$istransparent=......
php将bmp格式图片转换成jpg格式程序
- function imagebmp($img,$file="",$rle=0)
- {
-
-
- $colorcount=imagecolorstotal($img);
-
- $transparent=imagecolortransparent($img);
- $istransparent=$transparent!=-1;
-
-
- if($istransparent) $colorcount--;
-
- if($colorcount==0) {$colorcount=0; $bitcount=24;};
- if(($colorcount>0)and($colorcount<=2)) {$colorcount=2; $bitcount=1;};
- if(($colorcount>2)and($colorcount<=16)) { $colorcount=16; $bitcount=4;};
- if(($colorcount>16)and($colorcount<=256)) { $colorcount=0; $bitcount=8;};
-
-
- $width=imagesx($img);
- $height=imagesy($img);
-
- $zbytek=(4-($width/(8/$bitcount))%4)%4;
-
- if($bitcount<24) $palsize=pow(2,$bitcount)*4;
-
- $size=(floor($width/(8/$bitcount))+$zbytek)*$height+54;
- $size+=$palsize;
- $offset=54+$palsize;
-
-
- $ret = 'bm';
- $ret .= int_to_dword($size);
- $ret .= int_to_dword(0);
- $ret .= int_to_dword($offset);
-
- $ret .= int_to_dword(40);
- $ret .= int_to_dword($width);
- $ret .= int_to_dword($height);
- &
|