]> git.mdlowis.com Git - proto/labwc.git/commit
icon-loader: add a new loader for XPM icons, used by many legacy X11 apps
authorJohn Lindgren <john@jlindgren.net>
Mon, 30 Sep 2024 07:41:25 +0000 (03:41 -0400)
committerJohn Lindgren <john@jlindgren.net>
Tue, 1 Oct 2024 01:17:19 +0000 (21:17 -0400)
commitc9e0a6e125f95ba6efe0d200fffca4bf319539df
tree6fde75edf67a21820548362bb8627362f42df0dd
parent887ec70ba412eac11e700750e7c5a0966f68d4f9
icon-loader: add a new loader for XPM icons, used by many legacy X11 apps

Adapted from gdk-pixbuf, see the original at:

  https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/blob/master/gdk-pixbuf/io-xpm.c

rgb.txt is from X.org, see:

  https://gitlab.freedesktop.org/xorg/app/rgb/-/blob/master/rgb.txt

Differences from the gdk-pixbuf version:

- GdkPixbuf replaced with struct lab_data_buffer
- Progressive and in-memory loading code removed
- Two functions that had separate BSD copyright rewritten
- Stores colors as ARGB32 earlier in the decoding process for efficiency
- Limited to 1024x1024 px and 1024 colors to prevent abuse
- Uses struct buf to build strings, in place of manual g_new/g_realloc
- Uses xzalloc/xznew_n for other memory allocations
- Uses g_strlcpy in place of banned strcpy/strncpy/strncat
- Uses standard C types (int, bool, etc.) in place of the GLib ones
- Follows labwc coding style (whitespace, braces, letter case, etc.)
- Et cetera ...

v2: add Perl fixes from @domo141
include/img/img-xpm.h [new file with mode: 0644]
scripts/checkpatch.pl
src/icon-loader.c
src/img/gen-color-table.pl [new file with mode: 0755]
src/img/img-xpm.c [new file with mode: 0644]
src/img/meson.build
src/img/rgb.txt [new file with mode: 0644]
src/img/xpm-color-table.h [new file with mode: 0644]