int rowsInPass1 = (height + 7) / 8;
int rowsInPass2 = (height + 3) / 8;
int rowsInPass3 = (height + 1) / 4;
int rowsInPass4 = (height) / 2;
DataBuffer db = result.getRaster().getDataBuffer();
for (int row = 0; row < height; row++)
{
int y;
if (id.interlaceFlag)
{
int the_row = row;
if (the_row < rowsInPass1)
y = the_row * 8;
else
{
the_row -= rowsInPass1;
if (the_row < (rowsInPass2))
y = 4 + (the_row * 8);
else
{
the_row -= rowsInPass2;
if (the_row < (rowsInPass3))
y = 2 + (the_row * 4);
else
{
the_row -= rowsInPass3;
if (the_row < (rowsInPass4))
y = 1 + (the_row * 2);
else
throw new ImageReadException(
"Gif: Strange Row");
}
}
}
} else
y = row;
for (int x = 0; x < width; x++)
{
int index = 0xff & id.imageData[counter++];
int rgb = colorTable[index];
if (transparentIndex == index)
rgb = 0x00;
db.setElem(y * width + x, rgb);
}
}
}