Examples of displaying a WBMP image in ASP with csImageFile

csImageFile supports the wireless bitmap (WBMP) format for displaying 1-bit monochrome images in WAP browsers. This example shows how to create a wireless bitmap from code and display it using ASP. It is a simple image, just a piece of text with a border round it, but it demonstrates how to call an ASP script from inside the src tag of an image. It shows the content types needed for a WML page and a WBMP image.

The WML page

The WML page is produced from the code below. This is the page that the browser sees and it contains text and a placeholder for the image. It can be viewed in a WAP browser at this address - http://www.chestysoft.com/imagefile/wbmptest.asp.

WAP output

This shows the output from the demo. The WML page contains the text "A sample image" as well as the embedded image produced with the csImageFile component.

<%@ language=vbscript %> <% Response.ContentType = "text/vnd.wap.wml"%>
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//PHONE.COM//DTD WML 1.1//EN" "http://www.phone.com/dtd/wml11.dtd" >
  <card id="splash">
    <p align="center">A sample image</p>
    <p align="center"><img src="wimage.asp" alt="Image"/></p>

The image is created in the script called wimage.asp, called from the img tag.

The ASP script, wimage.asp

This uses the csImageFile component to generate a simple wireless bitmap. The Content Type is set to "image/vnd.wap.wbmp".

<%@ language=vbscript %>
Set wbmp = Server.CreateObject("csImageFile.Manage")
wbmp.PenColor = "000000"
wbmp.NewImage 94, 24, "ffffff"
wbmp.RoundRect 0, 6, 87, 23, 20, 20
wbmp.TextOpaque = false
wbmp.TextSize = 10
wbmp.Text 15, 8, "Hello World!"
Response.ContentType = "image/vnd.wap.wbmp"
Response.BinaryWrite wbmp.WBMPData

A WAP browser can be downloaded from Winwap Technologies to view WAP pages on a PC.

function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function eraseCookie(name) { createCookie(name,"",-1); } function AcceptCookies() { createCookie("cookie-site","true",120); createCookie("cookie-tracking","true",120); createCookie("cookie-remarketing","true",120); document.getElementById("overlay").style.display = "none"; } ]]>


This site uses cookies for functionality, traffic analysis and for targeted advertising. Click the Accept button to accept our Cookie Policy. The Cookie Policy page offers configuration for a reduced set of cookies for this site.