Path: utzoo!attcan!uunet!mcvax!kth!draken!d87-jse From: d87-jse@nada.kth.se (Joakim Sernbrant) Newsgroups: comp.windows.x Subject: Re: converting icons Message-ID: <1014@draken.nada.kth.se> Date: 12 May 89 13:02:52 GMT References: <2194@valhalla.ee.rochester.edu> Reply-To: d87-jse@nada.kth.se (Joakim Sernbrant) Organization: Royal Institute of Technology, Stockholm, Sweden Lines: 90 In article <2194@valhalla.ee.rochester.edu> deke@ee.rochester.edu (Dikran Kassabian) writes: > >I'd like to be able to use some of the classier icons I've collected and >had been using with suntools. As a first pass, I just pulled out the >sunview icon header, put in my notion of a reasonable X icon header, and >used 'bitmap' to display the icon image. It looked almost right... but >not quite. It was as though each of the objects were mirror imaged, but >were correctly placed relative to eachother. Additionally, some of the >borders seemed out of place. > The problem is that the bits are stored from left to right in one format and right to left in the other (can't remember which) ... Here is a quick hack I did to convert bitmaps from Sun to X (use it any way you like) : --------- CUT HERE ---------- /* s u n t o x b m . c Convert Sun icons to X bitmaps. usage: suntoxbm < file.icon > file.xbm */ #include main(argc, argv) int argc; char **argv; { char c, s[100], *name = argv[1]; int w, h, x, n; scanf("%*s%*s%*[^=]%*c%d%*[^=]%*c%d%*s%*s%*s%*s", &w, &h); printf("#define %s_width %d\n", name, w); printf("#define %s_height %d\n", name, w); printf("static char %s_bits[] = {\n"); n = 0; printf(" "); while ((c = getchar()) != -1) { if (c == 'x') { x = gethex(); if (n == 12 ) { printf(",\n "); n = 0; } else if (n) printf(", "); printf("0x%02x, ", reverse((x & 0xff00) >> 8)); printf("0x%02x", reverse(x & 0xff)); n += 2; } } printf("};\n"); } int reverse(x) int x; { int i, y = 0; for (i = 0; i < 8; i++) { y <<= 1; y |= ((x & 1) == 1); x >>= 1; } return y; } int gethex() { int i, c, x = 0; for (i=0; i < 4; i++) { x <<= 4; c = getchar(); if (isupper(c)) c = tolower(c); if (c >= 'a') x += c - 'a' + 10; else x += c - '0'; } return x; } -- -- Joakim Sernbrant, Royal Institute of Technology, Stockholm, Sweden -- Internet: d87-jse@nada.kth.se --