feat(fonts): deinterlace GIF i font ari-w9500 per placeholders
Fix: gif.cpp no desfeia l'interlace, trinxava qualsevol GIF entrellaçat (tota la sortida de Pillow). Afegeix Defaults::UI::Font per centralitzar noms/rutes i mou data/font → data/fonts. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
03f1c5f926
commit
eb07e7e564
18 files changed
+859
-14
No files matched your search
@@ -198,10 +198,33 @@ namespace GIF {
|
||||
readBytes(buffer, &lzw_code_size, sizeof(uint8_t));
|
||||
|
||||
std::vector<uint8_t> compressed_data = readSubBlocks(buffer);
|
||||
int uncompressed_data_length = image_descriptor.image_width * image_descriptor.image_height;
|
||||
std::vector<uint8_t> uncompressed_data(uncompressed_data_length);
|
||||
const int IMG_W = image_descriptor.image_width;
|
||||
const int IMG_H = image_descriptor.image_height;
|
||||
std::vector<uint8_t> uncompressed_data(static_cast<std::size_t>(IMG_W) * IMG_H);
|
||||
|
||||
decompress(lzw_code_size, compressed_data.data(), static_cast<int>(compressed_data.size()), uncompressed_data.data());
|
||||
|
||||
// Interlaced GIF (flag 0x40 al byte de fields): les files no arriben
|
||||
// en ordre lineal, sinó en 4 passades (8:0, 8:4, 4:2, 2:1). Reordena
|
||||
// al buffer lineal que espera Surface. Sense aquest pas, les fuentes
|
||||
// i qualsevol GIF entrellaçat es veien completament trinxats.
|
||||
constexpr uint8_t INTERLACE_FLAG = 0x40;
|
||||
if ((image_descriptor.fields & INTERLACE_FLAG) != 0) {
|
||||
constexpr int PASS_START[4] = {0, 4, 2, 1};
|
||||
constexpr int PASS_STEP[4] = {8, 8, 4, 2};
|
||||
std::vector<uint8_t> deinterlaced(static_cast<std::size_t>(IMG_W) * IMG_H);
|
||||
int src_row = 0;
|
||||
for (int pass = 0; pass < 4; ++pass) {
|
||||
for (int dst_row = PASS_START[pass]; dst_row < IMG_H; dst_row += PASS_STEP[pass]) {
|
||||
std::memcpy(deinterlaced.data() + (static_cast<std::size_t>(dst_row) * IMG_W),
|
||||
uncompressed_data.data() + (static_cast<std::size_t>(src_row) * IMG_W),
|
||||
IMG_W);
|
||||
++src_row;
|
||||
}
|
||||
}
|
||||
return deinterlaced;
|
||||
}
|
||||
|
||||
return uncompressed_data;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user