Fix saving of default textures (#490)

This commit is contained in:
Christian Semmler 2025-07-02 17:45:21 -07:00 committed by GitHub
parent d74e6ab401
commit 04b0e9a470
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View File

@ -708,19 +708,19 @@ void WriteDefaultTexture(LegoStorage* p_storage, const char* p_name)
memset(&desc, 0, sizeof(desc));
desc.dwSize = sizeof(desc);
if (surface->Lock(NULL, &desc, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WRITEONLY, NULL) == DD_OK) {
if (surface->Lock(NULL, &desc, DDLOCK_SURFACEMEMORYPTR, NULL) == DD_OK) {
LegoImage* image = new LegoImage(desc.dwWidth, desc.dwHeight);
if (image != NULL) {
if (desc.dwWidth == desc.lPitch) {
memcpy(desc.lpSurface, image->GetBits(), desc.dwWidth * desc.dwHeight);
memcpy(image->GetBits(), desc.lpSurface, desc.dwWidth * desc.dwHeight);
}
else {
MxU8* surface = (MxU8*) desc.lpSurface;
const LegoU8* bits = image->GetBits();
LegoU8* bits = image->GetBits();
for (MxS32 i = 0; i < desc.dwHeight; i++) {
memcpy(surface, bits, desc.dwWidth);
memcpy(bits, surface, desc.dwWidth);
surface += desc.lPitch;
bits += desc.dwWidth;
}

View File

@ -46,7 +46,7 @@ class LegoImage {
{
m_palette->colors[p_i] = p_paletteEntry.GetColor();
}
const LegoU8* GetBits() const { return (LegoU8*) m_surface->pixels; }
LegoU8* GetBits() const { return (LegoU8*) m_surface->pixels; }
LegoResult Read(LegoStorage* p_storage, LegoU32 p_square);
LegoResult Write(LegoStorage* p_storage);