Changes the PNG reader for paletted images to use the index of a
pixel to decide its transparency, rather than its color. This caused
pixels with non-zero index to be transparent if their index's color
happened to be the same as index 0's color.
Unfortunately, the indexed color -> RGBA conversion was being done
in libpng, so EasyRPG never saw the indices to begin with. So it
requires fairly invasive changes. For the sake of symmetry, I pulled
out functions for non-indexed images too. Not very pretty.
When writing a row of pixel data, instead of using a temporary
buffer of width w to hold the indices, put them in the last
w bytes of the row of pixel data. Then the index->RGBA loop looks
read nth index (from offset 3w+n)
convert to color
write color to nth pixel (offsets 4n..4n+3)
To check we don't overwrite a byte holding an index we'll later
need, we need to know that the offset of the last byte written,
4n+3, is less than the offset of the next byte read, 3w+(n+1).
4n+3 < 3w+(n+1) is equivalent to n < w-2/3, which is true since
n <= w-1.