You are not logged in.

#1 2015-11-15 20:41:58

gako
Member
Registered: 2015-10-02
Posts: 241

bitmaps! xbm, xpm

Share your bitmaps!

------ XBM ------------
xbm is the older X window bitmap format.
They can be viewed or edited with the bitmap program which you most likely have installed already.

It does not support color formatting but the bitmap program, being part of
xapps, will take advantage of color definitions marked in your
Xresources/Xdefaults *color: settings.
*hint srot -s smile

bitmap comes with two other resourceful tools:
atobm - convert ASCII to bitmap
bmtoa - convert bitmap to ASCII

Need some inspiration?
Make a directory of your choosing and
cp /usr/include/X11/bitmaps/* new/directory/

That will copy over many already installed bitmaps for you to play around with.
Simply

bitmap new/directory/terminal for example

# You can edit xbm with basic text editor like nano/gedit/vim/ as well.
# These do not have file extension .xbm but they are in fact .xbm.
# xbm do not require file extension but useful to identify from xpm
# openbox use xbm for title border icons (close, maximize, etc.) as well as menu icons I think.


----- XPM ------------

xpm is the newer (well not that new smile ) bitmap format and supports
transparent cool as well as colored pixel definitions.

A good lightweight xpm editor is

sudo apt-get install pixmap

to open a xpm from command make sure to use -f flag
ex.

pixmap -f file.xpm

# you can also edit xpm with text editor
# as with xbm the extension .xpm is not required but useful for identification
# if the file has .xpm most file managers should be able to grab a thumbnail
# once file is written it is super easy to change colors (bg, fg, etc) with sed or text editor


------ Converting xbm - xpm - png ------------

I use imagemagick which comes with convert command

real simple examples:

convert file.xbm file.xpm
convert file.xbm file.png
convert file.xpm file.png


------ Now for some bitmaps ------------
some use case examples with the first one

save this to file alsamixer48x48.xbm

#define alsamixer48x48_width 48
#define alsamixer48x48_height 48
static unsigned char alsamixer48x48_bits[] = {
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x80,
   0xfd, 0xff, 0xff, 0xff, 0xff, 0xbf, 0xfd, 0xff, 0xff, 0xff, 0xff, 0xbf,
   0xfd, 0xff, 0xff, 0xff, 0xff, 0xbf, 0x3d, 0xfc, 0xe1, 0x0f, 0x7f, 0xb8,
   0xbd, 0xfd, 0x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8, 0x3d, 0xfc, 0xe1, 0x0f, 0x7f, 0xb8,
   0x3d, 0xfc, 0xe1, 0x0f, 0x7f, 0xb8, 0x3d, 0xfc, 0xe1, 0x0f, 0x7f, 0xb8,
   0x3d, 0xfc, 0xe1, 0x0f, 0x7f, 0xb8, 0x3d, 0xfc, 0xe1, 0x0f, 0x7f, 0xb8,
   0x3d, 0xfc, 0xe1, 0x0f, 0x7f, 0xb8, 0xfd, 0xff, 0xff, 0xff, 0xff, 0xbf,
   0x0d, 0x70, 0x80, 0x03, 0x1c, 0xa0, 0xad, 0x75, 0xb5, 0x5b, 0x5d, 0xad,
   0x0d, 0x70, 0x80, 0x03, 0x1c, 0xa0, 0xfd, 0xff, 0xff, 0xff, 0xff, 0xbf,
   0x01, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};

convert to xpm for color manipulation

convert alsamixer48x48.xbm alsamixer48x48.xpm

change background and foreground of new xpm

 sed -i -e 's/black/#403729/g' -e 's/white/#b8a882/g' alsamixer48x48.xpm

now convert new, colored xpm to png

convert alsamixer48x48.xpm alsamixer48x48.png

------ htop29x17.xpm ------------

/* XPM */
static char * htop_xpm[] = {
"29 17 2 1",
"       c #b8a882",
".      c #403729",
"    .  .  .  ...  .  .  .    ",
"    .  .  .  ...  .  .  .    ",
"  ...  .  .  ...  .  .  ..   ",
"    .  .  .  ...  .  .  .    ",
"    .  .  .  ...  .  .  .    ",
".............................",
"    .  .  .   .   .  .  .    ",
"    .  .  . . . . .  .  .    ",
"  ...  .  . . . . .  .  ...  ",
"    .  .  . . . . .  .  .    ",
"    .  .  .   .   .  .  .    ",
".............................",
"    .  .  .  ...  .  .  .    ",
"    .  .  .  ...  .  .  .    ",
"  ...  .  .  ...  .  .  ...  ",
"    .  .  .  ...  .  .  .    ",
"    .  .  .  ...  .  .  .    "};

------ ranger15x16.xpm ------------

/* XPM */
static char * ranger_xpm[] = {
"15 16 2 1",
"       c #403729",
".      c #b8a882",
"      ...      ",
"     .   .     ",
"    .  .  .    ",
"   .   .   .   ",
"   .       .   ",
"   .   .   .   ",
" ............. ",
"   .       .   ",
"   .       .   ",
"  .  .   .  .  ",
"  .         .  ",
"  .         .  ",
"   .........   ",
"   .... ....   ",
"    .......    ",
"     .....     "};

------ term16x16.xpm ------------

/* XPM */
static char * term_xpm[] = {
"16 16 2 1",
"       c #403729",
".      c #b8a882",
"                ",
" ..             ",
" ...            ",
"  ...           ",
"   ...          ",
"    ...         ",
"     ...        ",
"    ...         ",
"   ...          ",
"  ...           ",
" ...            ",
" ..             ",
"                ",
"        ........",
"        ........",
"        ........"}

--- bunsenlabsflame32x32.xpm ------------

/* XPM */
static char * bunsen_xpm[] = {
/* columns rows colors chars-per-pixel */
"32 32 2 1",
"       c #b8a882",
".      c #403729",
/* pixels */
"               .                ",
"              ..                ",
"             ...                ",
"            .. ..               ",
"           ..  ...              ",
"          ...    ..             ",
"         ...      ..            ",
"        ... .      ..           ",
"       .. .         .           ",
"      . ....        ..          ",
"       ..            .          ",
"      . ....         ..         ",
"       ..          .  .         ",
"      . ...    .      .         ",
"       ..     .     . .         ",
"      . . .    .     .          ",
"       . .    ...  .. .         ",
"      . .   ..  .    .          ",
"       . .  .   .     .         ",
"        .  ..    .   .          ",
"         . .     .   ..         ",
"        . .       . .           ",
"         ..        . ..         ",
"          .       . .           ",
"                   ...          ",
"                  ...           ",
"                   .            ",
"                  ..            ",
"                   .            ",
"                  .             ",
"                 .              ",
"                                "};

While bitmap and pixmap might feel a little dated, or ugly/buggy even to some, I find them great minimal tools.

Hope someone finds this useful and happy bitmapping.

Share your own creations/edits,

Offline

#2 2015-11-15 22:13:10

nereet
Member
Registered: 2015-10-01
Posts: 82

Re: bitmaps! xbm, xpm

You made my day, a lot more than useful for me thanks smile

Offline

#3 2015-11-15 22:50:21

gako
Member
Registered: 2015-10-02
Posts: 241

Re: bitmaps! xbm, xpm

nereet wrote:

You made my day, a lot more than useful for me thanks smile

Really good to hear nereet thx! Keep your eye open I'll probably add
a atobm & bmtoa section soon as well as more bitmaps. cool

Offline

#4 2015-11-16 08:50:12

ohnonot
...again
Registered: 2015-09-29
Posts: 3,909
Website

Re: bitmaps! xbm, xpm

i made this script some time ago, it utilizes some of the things you mentioned above.

Offline

#5 2015-11-17 18:37:24

gako
Member
Registered: 2015-10-02
Posts: 241

Re: bitmaps! xbm, xpm

Very cool ohnonot, I see you made a terminus variant too, looks nice.


--- left_ptr.xpm ------------

/* XPM */
static char * left_ptr_xpm[] = {
"24 22 3 1 4 1",
"       c None",
".      c #403729",
"X      c #eae5ca",
"                        ",
"    .                   ",
"    ..                  ",
"    ...                 ",
"    ....                ",
"    .X...               ",
"    .XX...              ",
"    .XXX...             ",
"    .XXXX...            ",
"    .XXXXX...           ",
"    .XXXXXX...          ",
"    .XXXXXXX...         ",
"    .XXXXXXXX...        ",
"    .XXXXXXXXX...       ",
"    .XXXXXXXXXX...      ",
"    .XXX...........     ",
"    .XX.............    ",
"    .X..                ",
"    ...                 ",
"    ..                  ",
"    .                   ",
"                        "};

Offline

Board footer

Powered by FluxBB