ICO loader: Minor optimization

Or maybe not. A decent compiler would probably do this anyway.
This commit is contained in:
Kim Woelders 2021-12-23 08:39:26 +01:00
parent cbe7408bd8
commit 8bc72491e8
1 changed files with 10 additions and 15 deletions

View File

@ -363,62 +363,57 @@ ico_load(ico_t * ico, ImlibImage * im, int load_data)
pxls = ie->pxls;
mask = ie->mask;
pdst = im->data + (h - 1) * w; /* Start in lower left corner */
switch (ie->bih.bpp)
{
case 1:
for (y = 0; y < h; y++)
for (y = 0; y < h; y++, pdst -= 2 * w)
{
for (x = 0; x < w; x++)
{
pdst = &(im->data[(h - 1 - y) * w + x]);
pixel = cmap[ico_data_get_bit(pxls, w, x, y)];
if (ico_data_get_bit(mask, w, x, y) == 0)
pixel |= 0xff000000;
*pdst = pixel;
*pdst++ = pixel;
}
}
break;
case 4:
for (y = 0; y < h; y++)
for (y = 0; y < h; y++, pdst -= 2 * w)
{
for (x = 0; x < w; x++)
{
pdst = &(im->data[(h - 1 - y) * w + x]);
pixel = cmap[ico_data_get_nibble(pxls, w, x, y)];
if (ico_data_get_bit(mask, w, x, y) == 0)
pixel |= 0xff000000;
*pdst = pixel;
*pdst++ = pixel;
}
}
break;
case 8:
for (y = 0; y < h; y++)
for (y = 0; y < h; y++, pdst -= 2 * w)
{
for (x = 0; x < w; x++)
{
pdst = &(im->data[(h - 1 - y) * w + x]);
pixel = cmap[pxls[y * w + x]];
if (ico_data_get_bit(mask, w, x, y) == 0)
pixel |= 0xff000000;
*pdst = pixel;
*pdst++ = pixel;
}
}
break;
default:
for (y = 0; y < h; y++)
for (y = 0; y < h; y++, pdst -= 2 * w)
{
for (x = 0; x < w; x++)
{
pdst = &(im->data[(h - 1 - y) * w + x]);
psrc = &pxls[(y * w + x) * ie->bih.bpp / 8];
pixel = PIXEL_ARGB(0, psrc[2], psrc[1], psrc[0]);
@ -427,7 +422,7 @@ ico_load(ico_t * ico, ImlibImage * im, int load_data)
else if (ico_data_get_bit(mask, w, x, y) == 0)
pixel |= 0xff000000;
*pdst = pixel;
*pdst++ = pixel;
}
}
break;