Fix loading of .pbm's (P4) when width is not a multiple of 8.
SVN revision: 58519
This commit is contained in:
parent
41c3a967d0
commit
de93dc7e22
|
@ -402,27 +402,59 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '4': /* binary 1bit monochrome */
|
case '4': /* binary 1bit monochrome */
|
||||||
data = malloc(1 * sizeof(DATA8));
|
data = malloc((w + 7) / 8 * sizeof(DATA8));
|
||||||
if (!data)
|
if (!data)
|
||||||
{
|
{
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
ptr2 = im->data;
|
ptr2 = im->data;
|
||||||
j = 0;
|
for (y = 0; y < h; y++)
|
||||||
while ((fread(data, 1, 1, f)) && (j < (w * h)))
|
|
||||||
{
|
{
|
||||||
for (i = 7; i >= 0; i--)
|
if (!fread(data, (w + 7) / 8, 1, f))
|
||||||
{
|
{
|
||||||
if (j < (w * h))
|
free(data);
|
||||||
|
fclose(f);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
ptr = data;
|
||||||
|
for (x = 0; x < w; x += 8)
|
||||||
|
{
|
||||||
|
j = (w - x >= 8) ? 8 : w - x;
|
||||||
|
for (i = 0; i < j; i++)
|
||||||
{
|
{
|
||||||
if (data[0] & (1 << i))
|
if (ptr[0] & (0x80 >> i))
|
||||||
*ptr2 = 0xff000000;
|
*ptr2 = 0xff000000;
|
||||||
else
|
else
|
||||||
*ptr2 = 0xffffffff;
|
*ptr2 = 0xffffffff;
|
||||||
ptr2++;
|
ptr2++;
|
||||||
}
|
}
|
||||||
j++;
|
ptr++;
|
||||||
|
}
|
||||||
|
if (progress)
|
||||||
|
{
|
||||||
|
char per;
|
||||||
|
int l;
|
||||||
|
|
||||||
|
per = (char)((100 * y) / im->h);
|
||||||
|
if (((per - pper) >= progress_granularity)
|
||||||
|
|| (y == (im->h - 1)))
|
||||||
|
{
|
||||||
|
l = y - pl;
|
||||||
|
|
||||||
|
/* fix off by one in case of the last line */
|
||||||
|
if (y == (im->h - 1))
|
||||||
|
l++;
|
||||||
|
|
||||||
|
if (!progress(im, per, 0, pl, im->w, l))
|
||||||
|
{
|
||||||
|
free(idata);
|
||||||
|
fclose(f);
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
pper = per;
|
||||||
|
pl = y;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue