因为不是所有的WAP设备都能显示图像。因此,<img>中的“alt”必须使用,这样才能适用于那些不能显示图像的WAP设备。
“WAP Tiger”是一个非常简单的命令行BMP转换工具,可以去http://wap.infotiger.de/download.html下载。有 MS-DOS/
Windows 和 Linux 版本。
可以在http://www.rcp.co.uk/distributed/Downloads找到免费的Photoshop/Paint Shop Pro插件。
Macromedia 有一个为 Fireworks的外接插件可以让用户输出WBMPs。PC版本在:
http://download.macromedia.com/pub/fireworks/xtras/wbmp_im_ex.exe
Mac 版本在:
http://download.macromedia.com/pub/fireworks/xtras/wbmp_im_ex.hqx
echo("<?xml version=\"1.0\"?>\n");
echo("<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\"
\"http://www.wapforum.org/DTD/wml_1.1.xml\">\n\n");
echo("<!-- Code written in Microsoft NOTEPAD.EXE. (c) Espen Lyngaas 1999 Color Line ASA -->\n");
?>
<wml>
<?
for($card=1;$card<5;$card++) {
echo("<card id=\"image".$card."\" ontimer=\"#image".$card+1.">"\n");
echo("<timer value=\"10\"/>\n");
echo("<p>\n");
echo("<img src=\"anim".$card.".wbmp\" alt=\"Anim".$card."\"/>\n");
echo("</p>\n");
echo("</card>\n");
}
?>
<card id="image5" title="The End">
<p>
This is the end of the animation, but you can
<anchor>run it again.
<go href="#image1">
</go>
</anchor>
</p>
</card>
</wml>
如果WBMP图片看起来糟糕极了,该怎么办?
能够生成动态的WBMP图像吗?
因为当前版本的GD不再创建GIF图像,而是称作PNG (Portable Network Graphics)图像。所以使用当前版本的PHP,只需要修改少量的代码就可以将GIF 转换到 PNG。另外,可以用“DuPont’s Image Magick ”将PNG 或者转换成 WBMP,它能在两者之间相互转换,并适合于多种平台。
在代码里,笔者用到了PHP功能 ImageCreateFromGif(),要输一些文本到GIF图像上,可以使用PHP的 ImageGreate()创建一个空白的 GIF/PNG 图像。
以下是代码:
// path to blank GIF file – not really needed (see above)
$blank = "./wapclock_blank.gif";
// You can look at it here
// path to input file generated by PHP
$input = "/tmp/wapclock.gif";
// path to temporary output file. Extension is irrelevant
$output = "/tmp/wapclock.out";
// path to ImageMagick convert
$convert = "/usr/local/bin/convert";
if($format == "gif") {
// if it’s GIF, send that Content-type
header("Content-type: image/gif");
$type = "GIF";
}
else {
if($format == "wbmp") {
// if it’s WBMP, send that Content-type
header("Content-type: image/vnd.wap.wbmp");
$type = "WBMP";
}
else {
// hope that the browser can read this
header("Content-type: text/plain");
// or someone forgot to set the format variable
$type = "";
}
}
// turn off caching
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
// create a GIF file from an empty GIF file (see faq)
$im = imagecreatefromgif($blank);
// put the current time into the time variable
$time = date("H:m:s");
// Place time variable sort of in the middle, with font size 4
imagestring($im,4,6,15,$time,0);
// generate a GIF file with PHP (see faq)
ImageGif($im,$input);
// empty the GD temporary buffer
ImageDestroy($im);
if(strlen($type) > 0) {
// if the type is known
// do the conversion
exec($convert. " ".$input. " ".$type. ":".$output);
}
else {
// or do nothing
echo("Unknown format!\n");
// and stop
exit;
}
// open the converted file
$fd = fopen($output, "r");
// read verything into a variable
$contents = fread($fd,filesize($output));
// close the file
fclose($fd);
// pour out the contents
echo($contents);
?>
echo("<?xml version=\"1.0\"?>\n");
echo("<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\"
\"http://www.wapforum.org/DTD/wml_1.1.xml\">\n\n");
echo("<!—Code written in Microsoft NOTEPAD.EXE. (c) Espen Lyngaas 2000 Color Line ASA à \n");
?>
<wml>
<card id="wapclock" title="WAP Clock">
<do type="prev" label="Reload Image">
<go href="<?echo($PHP_SELF)?> "/>
</do>
<p>
<img src="http://wap.colorline.no/wap-faq/apps/gfxclock.html?format=wbmp"
alt="You should see an image…"/>
</p>
</card>
</wml>
针对多大的屏幕进行开发?
Ed Chew(Ed.Chew@scoot.co.uk) 检验过 “R380 Design Guideline for WAP Services”, 并且发现在Ericsson R380 有 360x120 像素的分辨率 (83x28mm), 0.23点距,浏览区域是限制在310(宽),100(高) pixels ,包括顶部的两个像素的空格,左边和右边的三个像素的空格,因此实际上只有304 x 98 像素。
为了弄清显示器到底有多大的大小,在http://wap.colorline.no/demos.html (选择 “Resolution matrix”)有一个分辨矩阵的演示程序。 页面将显示三个不同大小的图像,一个垂直和一个水平,它们是一个方向上十个像素,另外一个方向上只有一个像素,这样你马上就能知道屏幕到底有多大。另外他们的大小是:80x80,100x100 和 120x120像素,因为有些浏览器不能装载那些过大的图片。
由于有些显示器的点是长方形的,而不是正方形的,所以开发人员需要重新影射图像,让他们看起来像正方形,圆看起来像圆。但笔者不推荐这个方法,除非你知道用户所使用的WAP设备的真正比例。一个在7110上看起来很好的图到了R380上会很糟糕。
在WML中可以预先装入图片吗?
在下面的例子中,可能需要改变一下timer的数值,让它有时间来装入图片。
<!-- Adjust this timer to taste. -->
<timer value="10"/>
<p align="center">
<img src="spacer1.wbmp" alt="x"/>
</p>
<p>
<img src="1.wbmp" alt="1"/>
</p>
<p>
<img src="2.wbmp" alt="2"/>
</p>
<p>
<img src="3.wbmp" alt="3"/>
</p>
<p>
<img src="4.wbmp" alt="4"/>
</p>
<p>
<img src="5.wbmp" alt="5"/>
</p>
</card>
<card id="f1" ontimer="#f2">
<timer value="10"/>
<p align="center">
<img src="spacer15.wbmp" alt="x"/>
</p>
<p align="center">
<img src="1.wbmp" alt="1"/>
</p>
</card>
<card id="f2" ontimer="#f3">
<timer value="10"/>
<p align="center">
<img src="spacer10.wbmp" alt="x"/>
</p>
<p align="center">
<img src="2.wbmp" alt="2"/>
</p>
</card>
<card id="f3" ontimer="#f4">
<timer value="10"/>
<p align="center">
<img src="spacer08.wbmp" alt="x"/>
</p>
<p align="center">
<img src="3.wbmp" alt="3"/>
</p>
</card>
<card id="f4" ontimer="#f5">
<timer value="10"/>
<p align="center">
<img src="4.wbmp" alt="4"/>
</p>
</card>
<card id="f5" ontimer="#f1">
<timer value="10"/>
<p align="center">
<img src="5.wbmp" alt="5"/>
</p>
</card>
</wml>
为什么有些WBMP无法显示?