mirror of https://github.com/mgba-emu/mgba.git
Util: Fix PowerPC PNG read/write pixel order
This commit is contained in:
parent
19b81a2163
commit
d85548ac18
1
CHANGES
1
CHANGES
|
@ -11,6 +11,7 @@ Bugfixes:
|
|||
- GBA Audio: Fix 8-bit writes to audio channel 3 and 4 registers
|
||||
- GBA Audio: Fix audio channels being silenced at the wrong time
|
||||
- VFS: Fix return values of VFileFILE.read and .write
|
||||
- Util: Fix PowerPC PNG read/write pixel order
|
||||
Misc:
|
||||
- Qt: Window size command line options are now supported
|
||||
- Qt: Increase usability of key mapper
|
||||
|
|
|
@ -65,9 +65,15 @@ bool PNGWritePixels(png_structp png, unsigned width, unsigned height, unsigned s
|
|||
for (i = 0; i < height; ++i) {
|
||||
unsigned x;
|
||||
for (x = 0; x < width; ++x) {
|
||||
#if defined(__POWERPC__) || defined(__PPC__)
|
||||
row[x * 3] = pixelData[stride * i * 4 + x * 4 + 3];
|
||||
row[x * 3 + 1] = pixelData[stride * i * 4 + x * 4 + 2];
|
||||
row[x * 3 + 2] = pixelData[stride * i * 4 + x * 4 + 1];
|
||||
#else
|
||||
row[x * 3] = pixelData[stride * i * 4 + x * 4];
|
||||
row[x * 3 + 1] = pixelData[stride * i * 4 + x * 4 + 1];
|
||||
row[x * 3 + 2] = pixelData[stride * i * 4 + x * 4 + 2];
|
||||
#endif
|
||||
}
|
||||
png_write_row(png, row);
|
||||
}
|
||||
|
@ -167,9 +173,16 @@ bool PNGReadPixels(png_structp png, png_infop info, void* pixels, unsigned width
|
|||
png_read_row(png, row, 0);
|
||||
unsigned x;
|
||||
for (x = 0; x < pngWidth; ++x) {
|
||||
|
||||
#if defined(__POWERPC__) || defined(__PPC__)
|
||||
pixelData[stride * i * 4 + x * 4 + 3] = row[x * 3];
|
||||
pixelData[stride * i * 4 + x * 4 + 2] = row[x * 3 + 1];
|
||||
pixelData[stride * i * 4 + x * 4 + 1] = row[x * 3 + 2];
|
||||
#else
|
||||
pixelData[stride * i * 4 + x * 4] = row[x * 3];
|
||||
pixelData[stride * i * 4 + x * 4 + 1] = row[x * 3 + 1];
|
||||
pixelData[stride * i * 4 + x * 4 + 2] = row[x * 3 + 2];
|
||||
#endif
|
||||
}
|
||||
}
|
||||
free(row);
|
||||
|
|
Loading…
Reference in New Issue