forked from enlightenment/efl
evas - ico loader - detect probable p0ng entry in ico file
ico files were defined to have bmp's in each key - in fact a subset of them. unbenknownst to yours truly, vista now allows them to also be pngs and thus the ico loader rejects them as corrupt. at least detect it and complain right now
This commit is contained in:
parent
dee1640d0f
commit
10405ffc41
|
@ -554,6 +554,15 @@ evas_image_load_file_data_ico(void *loader_data,
|
|||
|
||||
// read bmp header time... let's do some checking
|
||||
if (!read_uint(map, fsize, &position, &dword)) goto close_file; // headersize - dont care
|
||||
if (dword != 40) // must be 40 if bmp entry - if not, something else
|
||||
{
|
||||
ERR("ICO at %i offset, size %i in %s is not a standard ico bmp "
|
||||
" file entry. It may be PNG (new as of Vista - not in original spec)",
|
||||
(int)position, (int)chosen.bmsize,
|
||||
eina_file_filename_get(f));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!read_uint(map, fsize, &position, &dword)) goto close_file; // width
|
||||
if (dword > 0)
|
||||
{
|
||||
|
@ -607,8 +616,7 @@ evas_image_load_file_data_ico(void *loader_data,
|
|||
if (cols > cols2) cols = cols2;
|
||||
if (cols > 256) cols = 256;
|
||||
}
|
||||
else
|
||||
cols = 0;
|
||||
else cols = 0;
|
||||
if (bitcount > 8) cols = 0;
|
||||
|
||||
pal = alloca(256 * 4);
|
||||
|
@ -639,34 +647,13 @@ evas_image_load_file_data_ico(void *loader_data,
|
|||
for (j = 0; j < w; j++)
|
||||
{
|
||||
if (j >= w) break;
|
||||
if ((j & 0x7) == 0x0)
|
||||
{
|
||||
*pix = pal[*p >> 7];
|
||||
}
|
||||
else if ((j & 0x7) == 0x1)
|
||||
{
|
||||
*pix = pal[(*p >> 6) & 0x1];
|
||||
}
|
||||
else if ((j & 0x7) == 0x2)
|
||||
{
|
||||
*pix = pal[(*p >> 5) & 0x1];
|
||||
}
|
||||
else if ((j & 0x7) == 0x3)
|
||||
{
|
||||
*pix = pal[(*p >> 4) & 0x1];
|
||||
}
|
||||
else if ((j & 0x7) == 0x4)
|
||||
{
|
||||
*pix = pal[(*p >> 3) & 0x1];
|
||||
}
|
||||
else if ((j & 0x7) == 0x5)
|
||||
{
|
||||
*pix = pal[(*p >> 2) & 0x1];
|
||||
}
|
||||
else if ((j & 0x7) == 0x6)
|
||||
{
|
||||
*pix = pal[(*p >> 1) & 0x1];
|
||||
}
|
||||
if ((j & 0x7) == 0x0) *pix = pal[*p >> 7];
|
||||
else if ((j & 0x7) == 0x1) *pix = pal[(*p >> 6) & 0x1];
|
||||
else if ((j & 0x7) == 0x2) *pix = pal[(*p >> 5) & 0x1];
|
||||
else if ((j & 0x7) == 0x3) *pix = pal[(*p >> 4) & 0x1];
|
||||
else if ((j & 0x7) == 0x4) *pix = pal[(*p >> 3) & 0x1];
|
||||
else if ((j & 0x7) == 0x5) *pix = pal[(*p >> 2) & 0x1];
|
||||
else if ((j & 0x7) == 0x6) *pix = pal[(*p >> 1) & 0x1];
|
||||
else
|
||||
{
|
||||
*pix = pal[*p & 0x1];
|
||||
|
@ -736,9 +723,7 @@ evas_image_load_file_data_ico(void *loader_data,
|
|||
unsigned char a, r, g, b;
|
||||
|
||||
if (j >= w) break;
|
||||
b = p[0];
|
||||
g = p[1];
|
||||
r = p[2];
|
||||
b = p[0]; g = p[1]; r = p[2];
|
||||
p += 3;
|
||||
a = 0xff;
|
||||
*pix = ARGB_JOIN(a, r, g, b);
|
||||
|
@ -761,10 +746,7 @@ evas_image_load_file_data_ico(void *loader_data,
|
|||
unsigned char a, r, g, b;
|
||||
|
||||
if (j >= w) break;
|
||||
b = p[0];
|
||||
g = p[1];
|
||||
r = p[2];
|
||||
a = p[3];
|
||||
b = p[0]; g = p[1]; r = p[2]; a = p[3];
|
||||
p += 4;
|
||||
if (a) none_zero_alpha = 1;
|
||||
*pix = ARGB_JOIN(a, r, g, b);
|
||||
|
@ -788,15 +770,14 @@ evas_image_load_file_data_ico(void *loader_data,
|
|||
for (j = 0; j < w; j++)
|
||||
{
|
||||
if (j >= w) break;
|
||||
if (*m & (1 << (7 - (j & 0x7))))
|
||||
A_VAL(pix) = 0x00;
|
||||
else
|
||||
A_VAL(pix) = 0xff;
|
||||
if (*m & (1 << (7 - (j & 0x7)))) *pix = 0;
|
||||
else A_VAL(pix) = 0xff;
|
||||
if ((j & 0x7) == 0x7) m++;
|
||||
pix++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
prop->premul = EINA_TRUE;
|
||||
|
|
Loading…
Reference in New Issue