Eden Ridgway's Blog

.Net and Web Development Information

  Home :: Contact :: Syndication  :: Login
  105 Posts :: 1 Stories :: 78 Comments :: 3 Trackbacks

Search

Article Categories

Archives

Post Categories

Development

General

While browsing the net I came across a code example that looked like this:

<script> var
icon = '#define icon_width 4\n#define icon_height 4\nstatic char icon_bits[] = { 0x05,
0x0A, 0x05, 0x0A };';
<
/script>
<
img src="javascript:icon;">

Not having seen anything like this before, I did some more digging to discover that the icon was in fact an XBM image definition. I was quite excited at the prospect of being able to dynamically generate images in a browser client only to discover that as of Windows XP SP2, XBM images no longer render in IE by default (source: Karma's Nucleus Dev Blog). You can however override this by setting the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Security BlockXBM dword value to zero. Here is a registry file to make things a little easier: UnblockXBM.zip. After applying this registry change, reboot your machine.

An incredible showcase of what can be achieved using dynamic XBM image generation can be found at the Wolfenstein 5K site. It's actually one of the most impressive things I've seen on the web for ages (pity about the performance though). There is also a XBM Image Creation Library for JavaScript available to ease generation of these images.

I also found a rather interesting CSS & div based image rendering example on Karma's blog. That must have taken quite some time to get right and I most certainly would not entertain using it as a way of effectively embedding your images in your client side controls/javascript.

As a side note, XBM images do render in FireFox by default, so I wonder how they address the apparent security concerns with the C based image format. However, since FireFox also supports the data url scheme, the XBM image support is a lot less important. For those who don't know what I'm going on about, the data url scheme allows you to embed a base64 encoded image directly into your HTML like this:

<img src="data:image/gif;base64,R0lGODlhDwAPAKECAAAAzMzM/////
wAAACwAAAAADwAPAAACIISPeQHsrZ5ModrLlN48CXF8m2iQ3YmmKqVlRtW4ML
wWACH+H09wdGltaXplZCBieSBVbGVhZCBTbWFydFNhdmVyIQAAOw=="
alt="Base64 encoded image" width="150" height="150"/>

In conclusion, it's a great sadness for me that the XBM format is no longer supported in IE. If anyone knows of a way to generate a dynamic image from JavaScript in IE (not using VML or CSS) I'm all ears.

Here are some more resources if you are interested:

posted on Sunday, November 13, 2005 3:56 AM
Comments have been closed on this topic.