mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-02-01 19:41:16 +00:00
Fix saving of default textures (#490)
This commit is contained in:
parent
d74e6ab401
commit
04b0e9a470
@ -708,19 +708,19 @@ void WriteDefaultTexture(LegoStorage* p_storage, const char* p_name)
|
|||||||
memset(&desc, 0, sizeof(desc));
|
memset(&desc, 0, sizeof(desc));
|
||||||
desc.dwSize = 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);
|
LegoImage* image = new LegoImage(desc.dwWidth, desc.dwHeight);
|
||||||
|
|
||||||
if (image != NULL) {
|
if (image != NULL) {
|
||||||
if (desc.dwWidth == desc.lPitch) {
|
if (desc.dwWidth == desc.lPitch) {
|
||||||
memcpy(desc.lpSurface, image->GetBits(), desc.dwWidth * desc.dwHeight);
|
memcpy(image->GetBits(), desc.lpSurface, desc.dwWidth * desc.dwHeight);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
MxU8* surface = (MxU8*) desc.lpSurface;
|
MxU8* surface = (MxU8*) desc.lpSurface;
|
||||||
const LegoU8* bits = image->GetBits();
|
LegoU8* bits = image->GetBits();
|
||||||
|
|
||||||
for (MxS32 i = 0; i < desc.dwHeight; i++) {
|
for (MxS32 i = 0; i < desc.dwHeight; i++) {
|
||||||
memcpy(surface, bits, desc.dwWidth);
|
memcpy(bits, surface, desc.dwWidth);
|
||||||
surface += desc.lPitch;
|
surface += desc.lPitch;
|
||||||
bits += desc.dwWidth;
|
bits += desc.dwWidth;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,7 +46,7 @@ class LegoImage {
|
|||||||
{
|
{
|
||||||
m_palette->colors[p_i] = p_paletteEntry.GetColor();
|
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 Read(LegoStorage* p_storage, LegoU32 p_square);
|
||||||
LegoResult Write(LegoStorage* p_storage);
|
LegoResult Write(LegoStorage* p_storage);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user