wjaguar has added many features - here is a build for testing
(no external images in this one - just the default builtins)
mtpaint 3.34+svn
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
I wanted to have more colors in my xpm files without adding unnecessary size, this tarball contains a patch to allow mtpaint to use 92 colors vs 64, it is also set up so that it can more easily be modified for more than 2 characters wide. (the tarball also has a few builtin xpms that were reduced by about 1kb total)
here is what it looks like:
to add 3+ character wide support ws[3] would need to be increased to ws[4] and would need to compute ws[2] and tmp[2], which is basically i or k / (strlen(ascii)*strlen(ascii)) ... I think, if not, its a good place to start
here is what it looks like:
Code: Select all
--- src/png.c~ 2012-03-01 06:33:16.000000000 +0800
+++ src/png.c 2012-06-01 17:30:10.950797471 +0800
@@ -3925,8 +3925,8 @@ fail: fclose(fp);
return (res);
}
-static const char base64[] =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
+static const char ascii[] =
+ "!#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~",
hex[] = "0123456789ABCDEF";
/* Extract valid C identifier from filename */
@@ -3947,7 +3947,7 @@ static int save_xpm(char *file_name, ls_
{
unsigned char rgbmem[XPM_MAXCOL * 4], *src;
const char *ctb;
- char ws[3], *buf, *tmp;
+ char ws[4], *buf, *tmp;
str_hash cuckoo;
FILE *fp;
int bpp = settings->bpp, w = settings->width, h = settings->height;
@@ -4001,7 +4001,8 @@ static int save_xpm(char *file_name, ls_
trans = settings->xpm_trans;
}
- cpp = cols > 64 ? 2 : 1;
+ cpp = cols > (strlen(ascii)+1) ? 2 : 1;
+ /* cpp = cols > ((strlen(ascii)+1)*(strlen(ascii)+1)) ? 3 : cpp; */
buf = malloc(w * cpp + 16);
if (!buf) return -1;
@@ -4022,19 +4023,21 @@ static int save_xpm(char *file_name, ls_
else fprintf(fp, "\"%d %d %d %d\",\n", w, h, cols, cpp);
/* Create colortable */
- ctb = cols > 16 ? base64 : hex;
- ws[1] = ws[2] = '\0';
+ ctb = cols > 16 ? ascii : hex;
+ ws[1] = ws[2] = '\0'; /* ws[3]='\0'; */
for (i = 0; i < cols; i++)
{
if (i == trans)
{
ws[0] = ' ';
if (cpp > 1) ws[1] = ' ';
+ /* if (cpp > 2) ws[2] = ' '; */
fprintf(fp, "\"%s\tc None\",\n", ws);
continue;
}
- ws[0] = ctb[i & 63];
- if (cpp > 1) ws[1] = ctb[i >> 6];
+ ws[0] = ctb[i % strlen(ascii)];
+ if (cpp > 1) ws[1] = ctb[i / strlen(ascii)];
+ /* if (cpp > 2) ws[2] = ctb[i / (strlen(ascii)*strlen(ascii))]; */
src = rgbmem + i * 4;
fprintf(fp, "\"%s\tc #%02X%02X%02X\",\n", ws,
src[0], src[1], src[2]);
@@ -4052,8 +4055,10 @@ static int save_xpm(char *file_name, ls_
if (k == trans) tmp[0] = tmp[1] = ' ';
else
{
- tmp[0] = ctb[k & 63];
- tmp[1] = ctb[k >> 6];
+
+ tmp[0] = ctb[k % strlen(ascii)];
+ tmp[1] = ctb[k / strlen(ascii)];
+ /* tmp[2] = ctb[k / (strlen(ascii)*strlen(ascii))]; */
}
}
strcpy(tmp, i < h - 1 ? "\",\n" : "\"\n};\n");
- Attachments
-
- xpm_colors.patch.gz
- updated patch fixes colors > 184 and has 3 wide support commented out for future use
- (1 KiB) Downloaded 390 times
-
- fixed_icons.tar.gz
- (2.45 KiB) Downloaded 383 times
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
I just realized the hex part may be broken... Need to test something with 16 colors, but it looks like it may be totally unnecessary anyways.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].