WAP常见问题问答大全(Yorky搜集整理 2004-06-18)
This is the end of the animation, but you can run it again.
如果使用PHP,可以看看更简单的程序:
header(\ echo(\
echo(\\\\
echo(\ ?>
for($card=1;$card<5;$card++) {
echo(\ echo(\ echo(\
echo(\ echo(\ echo(\ }
第 6 页 共 32 页
WAP常见问题问答大全(Yorky搜集整理 2004-06-18)
?>
This is the end of the animation, but you can run it again.
10. 如果WBMP图片看起来糟糕极了,该怎么办?
WBMP只有两种颜色,要是图片漂亮需要一定的技巧。但是可以减少图片的颜色。这里有一个叫做Floyd-Steinberg的方法可以做到。这样的一个程序是Jasc Paint Shop Pro。Paint Shop Pro的价格不是很贵,而且有直接保存为WBMP的插件。还可以使用30天免费版本。 11. 能够生成动态的WBMP图像吗?
当然。可以使用PHP、ASP 或者 Perl 来完成。这可能需要一种图像转换工具,因为服务端的脚本语言不支持WBMP的转换。
下面有一个PHP 的例子来说明使用脚本语言来完成的过程。
因为当前版本的GD不再创建GIF图像,而是称作PNG (Portable Network Graphics)图像。所以使用当前版本的PHP,只需要修改少量的代码就可以将GIF 转换到 PNG。另外,可以用“DuPont’s Image Magick ”将PNG 或者转换成 WBMP,它能在两者之间相互转换,并适合于多种平台。
在代码里,笔者用到了PHP功能 ImageCreateFromGif(),要输一些文本到GIF图像上,可以使用PHP的 ImageGreate()创建一个空白的 GIF/PNG 图像。 以下是代码:
// hardcoded \
// path to blank GIF file – not really needed (see above) $blank = \// You can look at it here
// path to input file generated by PHP
第 7 页 共 32 页
WAP常见问题问答大全(Yorky搜集整理 2004-06-18)
$input = \
// path to temporary output file. Extension is irrelevant $output = \// path to ImageMagick convert
$convert = \ if($format == \// if it’s GIF, send that Content-type
header(\ $type = \ } else {
if($format == \// if it’s WBMP, send that Content-type
header(\ $type = \ } else {
// hope that the browser can read this header(\ // or someone forgot to set the format variable $type = \ } }
// turn off caching
header(\
header(\ header(\ header(\
// create a GIF file from an empty GIF file (see faq) $im = imagecreatefromgif($blank);
第 8 页 共 32 页
WAP常见问题问答大全(Yorky搜集整理 2004-06-18)
// put the current time into the time variable $time = date(\
// 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. \ } else { // or do nothing
echo(\// and stop exit; }
// open the converted file $fd = fopen($output, \// read verything into a variable
$contents = fread($fd,filesize($output)); // close the file fclose($fd); // pour out the contents echo($contents); ?>
第 9 页 共 32 页
WAP常见问题问答大全(Yorky搜集整理 2004-06-18)
以上的代码是输出GIF的WBMP数据流。为了使用真正的图像,必须像下面这么写:
header(\ echo(\
echo(\\\\
echo(\—Code written in Microsoft NOTEPAD.EXE. (c) Espen Lyngaas 2000 Color Line ASA à \\n\ ?>
12. 针对多大的屏幕进行开发?
WAP设备的显示状况千差万别,有些支持图形,有些只支持文本。下面给出一些型号的屏幕尺寸:Mitsubishi 还没有公布的WAP电话有3行12个字符的显示器。Nokia 7110 的屏幕是96个像素宽,65个像素高,最大的显示图像是95个像素宽,45的像素高,高和宽的比例大约是1.25。因此一个正方型应该是一个实际宽高比为1:1.25的长方形,对于圆来说也是一样。
Ericsson's R320 有一个类似大小的显示屏幕。精确的大小是101像素宽,52像素高。可以显示4行文本,而且自动换行是默认的方式。
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 像素。
第 10 页 共 32 页