Fix image serialization bugs (#238)

This commit is contained in:
Christian Semmler 2025-06-04 17:20:53 -07:00 committed by GitHub
parent 0b8a7a758d
commit 8e55368615
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 3 deletions

View File

@ -754,14 +754,13 @@ void WriteDefaultTexture(LegoStorage* p_storage, const char* p_name)
paletteEntries[i].SetBlue(entries[i].peBlue);
}
SDL_Palette* newPalette = SDL_CreatePalette(i);
image->SetPalette(SDL_CreatePalette(i));
if (i > 0) {
for (MxS32 j = 0; j < i; j++) {
image->SetPaletteEntry(j, paletteEntries[j]);
}
}
image->SetPalette(newPalette);
LegoTexture texture;
texture.SetImage(image);

View File

@ -162,7 +162,7 @@ LegoResult LegoImage::Write(LegoStorage* p_storage)
if ((result = p_storage->Write(&m_surface->h, sizeof(int))) != SUCCESS) {
return result;
}
if ((result = p_storage->Write(&m_surface->h, sizeof(int))) != SUCCESS) {
if ((result = p_storage->Write(&m_palette->ncolors, sizeof(int))) != SUCCESS) {
return result;
}
if (m_palette) {