php在线生成ico文件的代码_PHP教程

index.php

代码如下:

ICO图标在线转换

ICO图标在线转换

phpthumb.ico.php

代码如下:

//

// available at http://phpthumb.sourceforge.net ///

//

/// //

// phpthumb.ico.php - .ICO output format functions //

// ///

//

class phpthumb_ico {

function phpthumb_ico() {

return true;

}

function GD2ICOstring(&$gd_image_array) {

foreach ($gd_image_array as $key => $gd_image) {

$ImageWidths[$key] = ImageSX($gd_image);

$ImageHeights[$key] = ImageSY($gd_image);

$bpp[$key] = ImageIsTrueColor($gd_image) ? 32 : 24;

$totalcolors[$key] = ImageColorsTotal($gd_image);

$icXOR[$key] = '';

for ($y = $ImageHeights[$key] - 1; $y >= 0; $y--) {

for ($x = 0; $x < $ImageWidths[$key]; $x++) {

$argb = $this->GetPixelColor($gd_image, $x, $y);

$a = round(255 * ((127 - $argb['alpha']) / 127));

$r = $argb['red'];

$g = $argb['green'];

$b = $argb['blue'];

if ($bpp[$key] == 32) {

$icXOR[$key] .= chr($b).chr($g).chr($r).chr($a);

} elseif ($bpp[$key] == 24) {

$icXOR[$key] .= chr($b).chr($g).chr($r);

}

if ($a < 128) {

@$icANDmask[$key][$y] .= '1';

} else {

@$icANDmask[$key][$y] .= '0';

}

}

// mask bits are 32-bit aligned per scanline

while (strlen($icANDmask[$key][$y]) % 32) {

$icANDmask[$key][$y] .= '0';

}

}

$icAND[$key] = '';

foreach ($icANDmask[$key] as $y => $scanlinemaskbits) {

for ($i = 0; $i < strlen($scanlinemaskbits); $i += 8) {

$icAND[$key] .= chr(bindec(str_pad(substr($scanlinemaskbits, $i, 8), 8, '0', STR_PAD_LEFT)));

}

}

}

foreach ($gd_image_array as $key => $gd_image) {

$biSizeImage = $ImageWidths[$key] * $ImageHeights[$key] * ($bpp[$key] / 8);

// BITMAPINFOHEADER - 40 bytes

$BitmapInfoHeader[$key] = '';

$BitmapInfoHeader[$key] .= "\x28\x00\x00\x00"; // DWORD biSize;

$BitmapInfoHeader[$key] .= $this->LittleEndian2String($ImageWidths[$key], 4); // LONG biWidth;

// The biHeight member specifies the combined

// height of the XOR and AND masks.

$BitmapInfoHeader[$key] .= $this->LittleEndian2String($ImageHeights[$key] * 2, 4); // LONG biHeight;

$BitmapInfoHeader[$key] .= "\x01\x00"; // WORD biPlanes;

$BitmapInfoHeader[$key] .= chr($bpp[$key])."\x00"; // wBitCount;

$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00"; // DWORD biCompression;

$BitmapInfoHeader[$key] .= $this->LittleEndian2String($biSizeImage, 4); // DWORD biSizeImage;

$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00"; // LONG biXPelsPerMeter;

$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00"; // LONG biYPelsPerMeter;

$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00"; // DWORD biClrUsed;

$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00"; // DWORD biClrImportant;

}

$icondata = "\x00\x00"; // idReserved; // Reserved (must be 0)

$icondata .= "\x01\x00"; // idType; // Resource Type (1 for icons)

$icondata .= $this->LittleEndian2String(count($gd_image_array), 2); // idCount; // How many images?

$dwImageOffset = 6 + (count($gd_image_array) * 16);

foreach ($gd_image_array as $key => $gd_image) {

// ICONDIRENTRY idEntries[1]; // An entry for each image (idCount of 'em)

$icondata .= chr($ImageWidths[$key]); // bWidth; // Width, in pixels, of the image

$icondata .= chr($ImageHeights[$key]); // bHeight; // Height, in pixels, of the image

$icondata .= chr($totalcolors[$key]); // bColorCount; // Number of colors in image (0 if >=8bpp)

$icondata .= "\x00"; // bReserved; // Reserved ( must be 0)

$icondata .= "\x01\x00"; // wPlanes; // Color Planes

$icondata .= chr($bpp[$key])."\x00"; // wBitCount; // Bits per pixel

$dwBytesInRes = 40 + strlen($icXOR[$key]) + strlen($icAND[$key]);

$icondata .= $this->LittleEndian2String($dwBytesInRes, 4); // dwBytesInRes; // How many bytes in this resource?

$icondata .= $this->LittleEndian2String($dwImageOffset, 4); // dwImageOffset; // Where in the file is this image?

$dwImageOffset += strlen($BitmapInfoHeader[$key]);

$dwImageOffset += strlen($icXOR[$key]);

$dwImageOffset += strlen($icAND[$key]);

}

foreach ($gd_image_array as $key => $gd_image) {

$icondata .= $BitmapInfoHeader[$key];

$icondata .= $icXOR[$key];

$icondata .= $icAND[$key];

}

return $icondata;

}

function LittleEndian2String($number, $minbytes=1) {

$intstring = '';

while ($number > 0) {

$intstring = $intstring.chr($number & 255);

$number >>= 8;

}

return str_pad($intstring, $minbytes, "\x00", STR_PAD_RIGHT);

}

function GetPixelColor(&$img, $x, $y) {

if (!is_resource($img)) {

return false;

}

return @ImageColorsForIndex($img, @ImageColorAt($img, $x, $y));

}

}

?>

http://www.bkjia.com/PHPjc/318401.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/318401.htmlTechArticleindex.php 代码如下:?PHP $output=""; if(isset($_GET['action'])$_GET['action']=='make'){ if(isset($_FILES['upimage']['tmp_name'])$_FILES['upimage']['tmp_name']is_upl...

本条技术文章来源于互联网,如果无意侵犯您的权益请点击此处反馈版权投诉

本文系统来源:php中文网

php转换透明ico,php在线生成ico文件的代码_PHP教程相关推荐

  1. 三个在线生成.ico图片的网站

    三个在线生成".ico"图片的网站 很多人都有为做一个"ico"图片文件而痛苦过.很多所谓的制作和转换成ico的软件其实都很烂,而且很复杂.今天就介绍三个在线生 ...

  2. php用asp文件js,asp下用fso生成js文件的代码

    asp下用fso生成js文件的代码 更新时间:2008年06月24日 23:47:54   作者: asp下使用fso生成js代码的方法 Set fso= Server.CreateObject(&q ...

  3. 启动(程序还没执行生成dump文件的代码)就崩溃的处理流程

    何志丹 如果有专业人员,利用Windbg启动这个程序,在分析就可以了. 上次崩溃,让大家手忙脚乱.所以列了一个启动(程序还没执行生成dump文件的代码)就崩溃的处理流程. 1,用我写的opendll. ...

  4. 在线转换pdf和虚拟打印机生成pdf文件操作攻略

    由于PDF具有稳定的格式和良好的视图,使得PDF格式文件越来越受工作族的欢迎.但大多人仍习惯Word编辑,所以就有了Word文档转换PDF的需求,那么有什么好的转换Word的方法呢? 小编就来介绍两种 ...

  5. Python生成.exe文件亲测实践教程(初级+进阶,含资源文件程序的打包)

    使用打包工具PyInstaller的基础操作: 此部分包括安装模块+模块的常见指令的使用 具体流程可以参考以下两篇文章非常详细 (9条消息) Python如何生成可执行的.exe文件_zhaochon ...

  6. 在线编辑php文件的代码

    说明:把以下代码保存为任意的文件名,比如edit.php, 其中file.php是要修改的文件名称. 这样,你在浏览器访问edit.php的时候,就可以在线编辑file.php了. 如果想在线编辑任意 ...

  7. matlab 如何生成mif,用matlab生成mif文件(示例代码)

    a=0:255miffile('rom_ipp.mif',a,8,256) 这是在matlab中调用的miffile函数来生成mif文件 ''单引号里面为所生成文件的名字 注:所生成的文件在matla ...

  8. 在线生成.SVG文件

    原因:设计网站为了在不同分辨率的手机上达到最佳显示效果,就将图片转换成SVG矢量图,就上网找到了在线工具 1.SVG在线编译器 2.导入图片,再导出图片即可获得SVG文件

  9. 在线生成二维码(图文教程)

    如今,二维码已经无处不在,甚至在出门旅游时,也会遇到路人让你扫码关注公众号,领取礼品等操作.因此,了解如何生成二维码是非常必要的.那么二维码有这几种,包括网址.文字.电话号码.短信.地图.邮箱等. 生 ...

  10. quartus生成qdb文件_Quartus II简明教程——下载程序到Altera开发板

    通过开发板的JTAG接口既能实现对FPGA器件的在线配置,也可编程串行配置器件. 以下配置皆以EP3C16为例,配置时要选对应的芯片型号,如:你用的芯片是Cyclone II系列的EP2C8,那么下面 ...

最新文章

  1. php 判断时间超过5分钟_小学音乐20分钟试讲面试,只有5天复习时间可以逆袭吗?...
  2. 8. American Friendship 美国式的友谊
  3. 【S操作】冰箱正常运行监控系统需求整理
  4. 深入BCB理解VCL的消息机制
  5. rose顺序图转换为协作图_【S7200指令教程】顺序控制指令SCR SCRT SCRE
  6. linux中date命令详解,Linux 之date命令详解
  7. [支付宝]手机网站支付快速接入
  8. 阶段1 语言基础+高级_1-3-Java语言高级_06-File类与IO流_05 IO字符流_9_JDK7和JDK9流中异常的处理...
  9. layui中table表格的操作列(删除,编辑)等按钮的操作
  10. 用python实现2048小游戏
  11. android设备分辨率排行,[图表]主流安卓旗舰手机像素密度排行榜出炉
  12. 02 - Redis源码结构介绍
  13. GIS开源软件大全(备用)
  14. 部署ServletContext的时候报错 Class com.xxxxx.ContextServlet is not a Servlet
  15. echarts图表入门级教程(An introductory chart tutorial)
  16. 移动web之四种常用布局
  17. 十二、Vue项目 - 详情页动态路由、banner布局和公用图片画廊组件拆分
  18. vulnhub靶机-DC2-Writeup
  19. 建立三層之前,我們需要做什麼;建立中間時,我們需要注意什麼;中間層規則是動態連接的好還是編譯鏈入好.日期:2004-05-18...
  20. 学校计算机教学演示,浅析计算机教学的方法

热门文章

  1. Jo-SRC: A Contrastive Approach for Combating Noisy Labels
  2. 使用tkinter canvas绘制中国象棋棋盘
  3. 史上最全Android版本号信息:)_我是亲民_新浪博客
  4. JavaScript网页编程
  5. C语言实现安全性极高的游戏存档并读档
  6. 曙光服务器通过ipmi安装系统,曙光服务器ipmi部署记录精编版
  7. 华为、海尔之后,阿里在全屋智能领域有新动作,这次牵手的是萤石
  8. linux 复制文件提示略过目录xxx
  9. 月报总结|Moonbeam 11月份大事一览
  10. 永恒的风控:大宗商品贸易融资背后的核心风险该如何规避?