Dave's Brain

Browse - Programming Tips - Can you suggest a programmer-friendly graphics format?

Date: 2008may2
Domain: graphics

Q.  Can you suggest a programmer-friendly graphics format?

A.  Most graphics formats are binary.  If you open up a JPEG file,
for example, in a text editor you can see "JFIF" surrounded but a
bunch of noise.  But not so with the XPM format!  Open up a XPM
file and you'll see:

/* XPM */ static char * roundb_xpm[] = { /* width height ncolors cpp [x_hot y_hot] */ "13 13 5 2 7 7", /* colors */ " s none m none c none", ". s topShadowColor m white c lightblue", "X s iconColor1 m black c black", "o s bottomShadowColor m black c #646464646464", "O s selectColor m white c red", /* pixels */ " ", " . . . ", " . . X X X o o ", " . X X X X X X X o ", " . X X X X X X X o ", " . X X X X O X X X X o ", " . X X X O O O X X X o ", " . X X X X O X X X X o ", " . X X X X X X X o ", " . X X X X X X X o ", " o o X X X o o ", " o o o ", " " };
(This example is taken from http://www.w3.org/People/danield/xpm_story.html ) It looks like C code and the ball it represents. Now that's what I call programer-friendly! Even though its text its not outragously space-inefficent. That's because it uses a palette. I'd like it if XBM was used more but its not exactly in fashion.

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.