Decompile fn_07872 (BitmapImage::DecodePng)

Batch #15743 by Yommy: 0 byte-identical, 1 confirmed by peer review.

- fn_07872 BitmapImage::DecodePng: logic confirmed by peer review

Peer-reviewed-by: eAthena, Toshiro
Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
This commit is contained in:
ragnarok-clanker 2026-11-10 10:40:03 +00:00
commit 2609a0f794

View file

@ -98,14 +98,14 @@ bool BitmapImage::DecodePng(const void* data, int bytes, const char*) {
}
png_read_image(png, rows);
const std::uint32_t count = static_cast<std::uint32_t>(this->width) * static_cast<std::uint32_t>(this->height);
this->pixels = static_cast<std::uint32_t*>(std::malloc(count > 0x3FFFFFFFu ? 0xFFFFFFFFu : count * 4u));
this->pixels = new std::uint32_t[this->width * this->height];
for (int y = 0; y < this->height; ++y) {
const unsigned char* pixel = rows[y];
std::uint32_t* out = &this->pixels[this->width * y];
for (int x = 0; x < this->width; ++x) {
const unsigned char* pixel = rows[y] + 4u * x;
this->pixels[static_cast<std::uint32_t>(y) * this->width + x] =
pixel[2] | (pixel[1] << 8) | (pixel[0] << 16) | (static_cast<std::uint32_t>(pixel[3]) << 24);
*out++ = (((((pixel[3] << 8) + pixel[0]) << 8) + pixel[1]) << 8) + pixel[2];
pixel += 4;
}
}