History

scripts/pnmtologo: fix for plain PBM

PBM generated with current tools do not have a whitespace between the digits. Therefore the pnmtologo tool fails to gernerate the required C-Array for these images. This patch fixes that behaviour and can handle both 'old style' and 'new style' PBM files.

Andreas Bießmann committed 14 years ago

Commit fc96b211 parent 16f89091 file · +7 −0Browse files

Showing the changes to scripts (1 of 1 file). Show all

Unified · Split

scripts/pnmtologo.c+7−0
@@ -74,6 +74,7 @@ static unsigned int logo_height; · 73 unmodified lines
7474 static struct color **logo_data;
7575 static struct color logo_clut[MAX_LINUX_LOGO_COLORS];
7676 static unsigned int logo_clutsize;
77+static int is_plain_pbm = 0;
7778
7879 static void die(const char *fmt, ...)
7980 __attribute__ ((noreturn)) __attribute ((format (printf, 1, 2)));
@@ -103,6 +104,11 @@ static unsigned int get_number(FILE *fp) · 23 unmodified lines
103104 val = 0;
104105 while (isdigit(c)) {
105106 val = 10*val+c-'0';
107+ /* some PBM are 'broken'; GiMP for example exports a PBM without space
108+ * between the digits. This is Ok cause we know a PBM can only have a '1'
109+ * or a '0' for the digit. */
110+ if (is_plain_pbm)
111+ break;
106112 c = fgetc(fp);
107113 if (c == EOF)
108114 die("%s: end of file\n", filename);
@@ -167,6 +173,7 @@ static void read_image(void) · 58 unmodified lines
167173 switch (magic) {
168174 case '1':
169175 /* Plain PBM */
176+ is_plain_pbm = 1;
170177 for (i = 0; i < logo_height; i++)
171178 for (j = 0; j < logo_width; j++)
172179 logo_data[i][j].red = logo_data[i][j].green =

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t