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" >
<wml>
  <card id="splash">
    <p align="center">A sample image</p>
    <p align="center"><img src="wimage.asp" alt="Image"/></p>
  </card>
</wml>

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.

Cookies

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.