网站地图    收藏   

主页 > php专栏 > php函数大全 >

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格式程序

  1. function imagebmp($img,$file="",$rle=0) 
  2. { 
  3.  
  4.  
  5. $colorcount=imagecolorstotal($img); 
  6.  
  7. $transparent=imagecolortransparent($img); 
  8. $istransparent=$transparent!=-1; 
  9.  
  10.  
  11. if($istransparent) $colorcount--; 
  12.  
  13. if($colorcount==0) {$colorcount=0; $bitcount=24;}; 
  14. if(($colorcount>0)and($colorcount<=2)) {$colorcount=2; $bitcount=1;}; 
  15. if(($colorcount>2)and($colorcount<=16)) { $colorcount=16; $bitcount=4;}; 
  16. if(($colorcount>16)and($colorcount<=256)) { $colorcount=0; $bitcount=8;}; 
  17.  
  18.  
  19.                 $width=imagesx($img); 
  20.                 $height=imagesy($img); 
  21.  
  22.                 $zbytek=(4-($width/(8/$bitcount))%4)%4; 
  23.  
  24.                 if($bitcount<24) $palsize=pow(2,$bitcount)*4; 
  25.  
  26.                 $size=(floor($width/(8/$bitcount))+$zbytek)*$height+54; 
  27.                 $size+=$palsize; 
  28.                 $offset=54+$palsize; 
  29.  
  30.                 // bitmap file header 
  31.                 $ret = 'bm';                        // header (2b) 
  32.                 $ret .= int_to_dword($size);        // size of file (4b) 
  33.                 $ret .= int_to_dword(0);        // reserved (4b) 
  34.                 $ret .= int_to_dword($offset);        // byte location in the file which is first byte of image (4b) 
  35.                 // bitmap info header 
  36.                 $ret .= int_to_dword(40);        // size of bitmapinfoheader (4b) 
  37.                 $ret .= int_to_dword($width);        // width of bitmap (4b) 
  38.                 $ret .= int_to_dword($height);        // height of bitmap (4b) 
  39.           &

自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习

京ICP备14009008号-1@版权所有www.zixuephp.com

网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com

添加评论