There are others conditions that may update witdh and height but this one is the most obvious and error prone to me.
Questions
What is the exact purpose of this check ?
Why cannot we load not multiple by 4 PNG data ?
When check is removed, all seems to work fine. Is this related to Wii hardware ?
Do we really need to recompute image size + decode PNG data if content is zeroed after ?
Does this check can be moved to libpngu ?
Looking at the code, most PNG loading tricks are not needed if we drop content.
Function can be simplified (see https://github.com/GRRLIB/GRRLIB/commit/2654a8903641d085b813747f89da76a47009f176).
This may be silly, but what is the exact purpose of libpngu ?
Is it here to make an abstraction layer between GRRLIB and libpng ?
Does it come from somewhere else ? Most of the code in it look unused / dead.
Should we add some documentation on GRRLIB_LoadTexturePNG on the image size multiple by 4 (instead of not correct) ?
Hi,
This question may have been ask earlier on GRRLIB forum, but I did not find any reference to this issue.
Problem description
There is weird / maybe undocumented behavior with PNG texture loading. If texture width or height is not multiple of 4, then PNG data is zeroed.
This is due to the following check in
GRRLIB_LoadTexturePNG
: https://github.com/GRRLIB/GRRLIB/blob/3ee20bffc24c3e3d95f690d83369b2bf406eb35d/GRRLIB/GRRLIB/GRRLIB_texEdit.c#L173-L176Width and height parameter are changed in
libpngu
in functionPNGU_DecodeTo4x4RGBA8
here: https://github.com/GRRLIB/GRRLIB/blob/3ee20bffc24c3e3d95f690d83369b2bf406eb35d/GRRLIB/lib/pngu/pngu.c#L601-L602There are others conditions that may update witdh and height but this one is the most obvious and error prone to me.
Questions
What is the exact purpose of this check ? Why cannot we load not multiple by 4 PNG data ? When check is removed, all seems to work fine. Is this related to Wii hardware ?
Do we really need to recompute image size + decode PNG data if content is zeroed after ? Does this check can be moved to
libpngu
? Looking at the code, most PNG loading tricks are not needed if we drop content. Function can be simplified (see https://github.com/GRRLIB/GRRLIB/commit/2654a8903641d085b813747f89da76a47009f176).This may be silly, but what is the exact purpose of
libpngu
? Is it here to make an abstraction layer betweenGRRLIB
andlibpng
? Does it come from somewhere else ? Most of the code in it look unused / dead.Should we add some documentation on
GRRLIB_LoadTexturePNG
on the image size multiple by 4 (instead of not correct) ?Code to reproduce
I have made a branch on repository fork to store code and resources (see commit: https://github.com/GRRLIB/GRRLIB/commit/2b73935bef8455e8a19e0c4d7ebd867d962f6521).
Bellow are some screenshot of running application.
with image of 352*89:
with image of 352*82: