Deuglification.
This commit is contained in:
parent
db33b8c6a1
commit
4a8aa48317
|
@ -164,6 +164,7 @@ load(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity,
|
||||||
c = fgetc(f);
|
c = fgetc(f);
|
||||||
if (c == EOF)
|
if (c == EOF)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (!quote)
|
if (!quote)
|
||||||
{
|
{
|
||||||
if ((pc == '/') && (c == '*'))
|
if ((pc == '/') && (c == '*'))
|
||||||
|
@ -171,6 +172,7 @@ load(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity,
|
||||||
else if ((pc == '*') && (c == '/') && (comment))
|
else if ((pc == '*') && (c == '/') && (comment))
|
||||||
comment = 0;
|
comment = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!comment)
|
if (!comment)
|
||||||
{
|
{
|
||||||
if ((!quote) && (c == '"'))
|
if ((!quote) && (c == '"'))
|
||||||
|
@ -387,6 +389,13 @@ load(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity,
|
||||||
}
|
}
|
||||||
if (cpp == 1)
|
if (cpp == 1)
|
||||||
{
|
{
|
||||||
|
#define PIX_RGB(_r, _g, _b) (((_r) << 16) | ((_g) << 8) | (_b))
|
||||||
|
#define PIX_ARGB(_r, _g, _b) ((0xff << 24) | PIX_RGB(_r, _g, _b))
|
||||||
|
|
||||||
|
#define CM1_TRANS() cmap[lookup[col[0] - ' '][0]].transp
|
||||||
|
#define CM1_R() (unsigned char)cmap[lookup[col[0] - ' '][0]].r
|
||||||
|
#define CM1_G() (unsigned char)cmap[lookup[col[0] - ' '][0]].g
|
||||||
|
#define CM1_B() (unsigned char)cmap[lookup[col[0] - ' '][0]].b
|
||||||
if (transp)
|
if (transp)
|
||||||
{
|
{
|
||||||
for (i = 0;
|
for (i = 0;
|
||||||
|
@ -394,38 +403,20 @@ load(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity,
|
||||||
i++)
|
i++)
|
||||||
{
|
{
|
||||||
col[0] = line[i];
|
col[0] = line[i];
|
||||||
if (cmap
|
if (CM1_TRANS())
|
||||||
[lookup[(int)col[0] - 32][0]].transp)
|
|
||||||
{
|
{
|
||||||
r = (unsigned
|
r = CM1_R();
|
||||||
char)cmap[lookup[(int)col[0] -
|
g = CM1_G();
|
||||||
32][0]].r;
|
b = CM1_B();
|
||||||
g = (unsigned
|
*ptr++ = PIX_RGB(r, g, b);
|
||||||
char)cmap[lookup[(int)col[0] -
|
|
||||||
32][0]].g;
|
|
||||||
b = (unsigned
|
|
||||||
char)cmap[lookup[(int)col[0] -
|
|
||||||
32][0]].b;
|
|
||||||
*ptr++ =
|
|
||||||
0x00ffffff & ((r << 16) | (g << 8)
|
|
||||||
| b);
|
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
r = (unsigned
|
r = CM1_R();
|
||||||
char)cmap[lookup[(int)col[0] -
|
g = CM1_G();
|
||||||
32][0]].r;
|
b = CM1_B();
|
||||||
g = (unsigned
|
*ptr++ = PIX_ARGB(r, g, b);
|
||||||
char)cmap[lookup[(int)col[0] -
|
|
||||||
32][0]].g;
|
|
||||||
b = (unsigned
|
|
||||||
char)cmap[lookup[(int)col[0] -
|
|
||||||
32][0]].b;
|
|
||||||
*ptr++ =
|
|
||||||
(0xff << 24) | (r << 16) | (g <<
|
|
||||||
8) |
|
|
||||||
b;
|
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -437,24 +428,20 @@ load(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity,
|
||||||
i++)
|
i++)
|
||||||
{
|
{
|
||||||
col[0] = line[i];
|
col[0] = line[i];
|
||||||
r = (unsigned
|
r = CM1_R();
|
||||||
char)cmap[lookup[(int)col[0] -
|
g = CM1_G();
|
||||||
32][0]].r;
|
b = CM1_B();
|
||||||
g = (unsigned
|
*ptr++ = PIX_ARGB(r, g, b);
|
||||||
char)cmap[lookup[(int)col[0] -
|
|
||||||
32][0]].g;
|
|
||||||
b = (unsigned
|
|
||||||
char)cmap[lookup[(int)col[0] -
|
|
||||||
32][0]].b;
|
|
||||||
*ptr++ =
|
|
||||||
(0xff << 24) | (r << 16) | (g << 8) |
|
|
||||||
b;
|
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (cpp == 2)
|
else if (cpp == 2)
|
||||||
{
|
{
|
||||||
|
#define CM2_TRANS() cmap[lookup[col[0] - ' '][col[1] - ' ']].transp
|
||||||
|
#define CM2_R() (unsigned char)cmap[lookup[col[0] - ' '][col[1] - ' ']].r
|
||||||
|
#define CM2_G() (unsigned char)cmap[lookup[col[0] - ' '][col[1] - ' ']].g
|
||||||
|
#define CM2_B() (unsigned char)cmap[lookup[col[0] - ' '][col[1] - ' ']].b
|
||||||
if (transp)
|
if (transp)
|
||||||
{
|
{
|
||||||
for (i = 0;
|
for (i = 0;
|
||||||
|
@ -463,45 +450,20 @@ load(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity,
|
||||||
{
|
{
|
||||||
col[0] = line[i++];
|
col[0] = line[i++];
|
||||||
col[1] = line[i];
|
col[1] = line[i];
|
||||||
if (cmap
|
if (CM2_TRANS())
|
||||||
[lookup[(int)col[0] - 32]
|
|
||||||
[(int)col[1] - 32]].transp)
|
|
||||||
{
|
{
|
||||||
r = (unsigned
|
r = CM2_R();
|
||||||
char)cmap[lookup[(int)col[0] -
|
g = CM2_G();
|
||||||
32][(int)col[1]
|
b = CM2_B();
|
||||||
- 32]].r;
|
*ptr++ = PIX_RGB(r, g, b);
|
||||||
g = (unsigned
|
|
||||||
char)cmap[lookup[(int)col[0] -
|
|
||||||
32][(int)col[1]
|
|
||||||
- 32]].g;
|
|
||||||
b = (unsigned
|
|
||||||
char)cmap[lookup[(int)col[0] -
|
|
||||||
32][(int)col[1]
|
|
||||||
- 32]].b;
|
|
||||||
*ptr++ =
|
|
||||||
0x00ffffff & ((r << 16) | (g << 8)
|
|
||||||
| b);
|
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
r = (unsigned
|
r = CM2_R();
|
||||||
char)cmap[lookup[(int)col[0] -
|
g = CM2_G();
|
||||||
32][(int)col[1]
|
b = CM2_B();
|
||||||
- 32]].r;
|
*ptr++ = PIX_ARGB(r, g, b);
|
||||||
g = (unsigned
|
|
||||||
char)cmap[lookup[(int)col[0] -
|
|
||||||
32][(int)col[1]
|
|
||||||
- 32]].g;
|
|
||||||
b = (unsigned
|
|
||||||
char)cmap[lookup[(int)col[0] -
|
|
||||||
32][(int)col[1]
|
|
||||||
- 32]].b;
|
|
||||||
*ptr++ =
|
|
||||||
(0xff << 24) | (r << 16) | (g <<
|
|
||||||
8) |
|
|
||||||
b;
|
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -514,27 +476,20 @@ load(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity,
|
||||||
{
|
{
|
||||||
col[0] = line[i++];
|
col[0] = line[i++];
|
||||||
col[1] = line[i];
|
col[1] = line[i];
|
||||||
r = (unsigned
|
r = CM2_R();
|
||||||
char)cmap[lookup[(int)col[0] -
|
g = CM2_G();
|
||||||
32][(int)col[1] -
|
b = CM2_B();
|
||||||
32]].r;
|
*ptr++ = PIX_ARGB(r, g, b);
|
||||||
g = (unsigned
|
|
||||||
char)cmap[lookup[(int)col[0] -
|
|
||||||
32][(int)col[1] -
|
|
||||||
32]].g;
|
|
||||||
b = (unsigned
|
|
||||||
char)cmap[lookup[(int)col[0] -
|
|
||||||
32][(int)col[1] -
|
|
||||||
32]].b;
|
|
||||||
*ptr++ =
|
|
||||||
(0xff << 24) | (r << 16) | (g << 8) |
|
|
||||||
b;
|
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#define CM0_TRANS(_j) cmap[_j].transp
|
||||||
|
#define CM0_R(_j) (unsigned char)cmap[_j].r
|
||||||
|
#define CM0_G(_j) (unsigned char)cmap[_j].g
|
||||||
|
#define CM0_B(_j) (unsigned char)cmap[_j].b
|
||||||
if (transp)
|
if (transp)
|
||||||
{
|
{
|
||||||
for (i = 0;
|
for (i = 0;
|
||||||
|
@ -551,43 +506,20 @@ load(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity,
|
||||||
{
|
{
|
||||||
if (!strcmp(col, cmap[j].str))
|
if (!strcmp(col, cmap[j].str))
|
||||||
{
|
{
|
||||||
if (cmap[j].transp)
|
if (CM0_TRANS(j))
|
||||||
{
|
{
|
||||||
r = (unsigned
|
r = CM1_R();
|
||||||
char)cmap[lookup[(int)
|
g = CM1_G();
|
||||||
col
|
b = CM1_B();
|
||||||
[0] -
|
*ptr++ = PIX_RGB(r, g, b);
|
||||||
32]
|
|
||||||
[0]].r;
|
|
||||||
g = (unsigned
|
|
||||||
char)cmap[lookup[(int)
|
|
||||||
col
|
|
||||||
[0] -
|
|
||||||
32]
|
|
||||||
[0]].g;
|
|
||||||
b = (unsigned
|
|
||||||
char)cmap[lookup[(int)
|
|
||||||
col
|
|
||||||
[0] -
|
|
||||||
32]
|
|
||||||
[0]].b;
|
|
||||||
*ptr++ =
|
|
||||||
0x00ffffff & ((r << 16)
|
|
||||||
| (g << 8)
|
|
||||||
| b);
|
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
r = (unsigned char)
|
r = CM0_R(j);
|
||||||
cmap[j].r;
|
g = CM0_G(j);
|
||||||
g = (unsigned char)
|
b = CM0_B(j);
|
||||||
cmap[j].g;
|
*ptr++ = PIX_ARGB(r, g, b);
|
||||||
b = (unsigned char)
|
|
||||||
cmap[j].b;
|
|
||||||
*ptr++ =
|
|
||||||
(0xff << 24) | (r << 16)
|
|
||||||
| (g << 8) | b;
|
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
j = ncolors;
|
j = ncolors;
|
||||||
|
@ -611,12 +543,10 @@ load(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity,
|
||||||
{
|
{
|
||||||
if (!strcmp(col, cmap[j].str))
|
if (!strcmp(col, cmap[j].str))
|
||||||
{
|
{
|
||||||
r = (unsigned char)cmap[j].r;
|
r = CM0_R(j);
|
||||||
g = (unsigned char)cmap[j].g;
|
g = CM0_G(j);
|
||||||
b = (unsigned char)cmap[j].b;
|
b = CM0_B(j);
|
||||||
*ptr++ =
|
*ptr++ = PIX_ARGB(r, g, b);
|
||||||
(0xff << 24) | (r << 16) |
|
|
||||||
(g << 8) | b;
|
|
||||||
count++;
|
count++;
|
||||||
j = ncolors;
|
j = ncolors;
|
||||||
}
|
}
|
||||||
|
@ -642,6 +572,7 @@ load(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Scan in line from XPM file */
|
/* Scan in line from XPM file */
|
||||||
if ((!comment) && (quote) && (c != '"'))
|
if ((!comment) && (quote) && (c != '"'))
|
||||||
{
|
{
|
||||||
|
@ -666,11 +597,13 @@ load(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity,
|
||||||
line[i++] = c;
|
line[i++] = c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i >= lsz)
|
if (i >= lsz)
|
||||||
{
|
{
|
||||||
lsz += 256;
|
lsz += 256;
|
||||||
line = realloc(line, lsz);
|
line = realloc(line, lsz);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((ptr) && ((ptr - im->data) >= (w * h * (int)sizeof(DATA32)))) ||
|
if (((ptr) && ((ptr - im->data) >= (w * h * (int)sizeof(DATA32)))) ||
|
||||||
((context > 1) && (count >= pixels)))
|
((context > 1) && (count >= pixels)))
|
||||||
done = 1;
|
done = 1;
|
||||||
|
|
Loading…
Reference in New Issue