Skip to content

Loading png property with format type 517 incorrectly #3

@GoogleCodeExporter

Description

@GoogleCodeExporter
Load the midforest backgrounds and try to view the basic sky background (no = 0)
All you see is a bunch of weird black and white stripes.
I've taken the liberty of fixing this issue in my own wzlib so here is the C++ 
code that I use.
Feel free to port it back over and fix your own code.
Buf1 and Buf2 are just pre-allocated arrays of uint8_t.

    case 517:
        {
            uint32_t len = sprite.data->width*sprite.data->height/128;
            Decompress(length, len);
            for (uint32_t i = 0; i < len*2; i++) {
                uint8_t b4 = (Buf1[i*2]&0x0F)|((Buf1[i*2]&0x0F)<<4);
                uint8_t b3 = (Buf1[i*2]&0xF0)|((Buf1[i*2]&0xF0)>>4);
                uint8_t b2 = (Buf1[i*2+1]&0x0F)|((Buf1[i*2+1]&0x0F)<<4);
                uint8_t b1 = (Buf1[i*2+1]&0xF0)|((Buf1[i*2+1]&0xF0)>>4);
                for (uint32_t j = 0; j < 256; j++) {
                    Buf2[i*1024+j*4] = b1;
                    Buf2[i*1024+j*4+1] = b2;
                    Buf2[i*1024+j*4+2] = b3;
                    Buf2[i*1024+j*4+3] = b4;
                }
            }
            glTexImage2D(GL_TEXTURE_2D, 0, 4, sprite.data->width, sprite.data->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, Buf2);
            break;
        }

Original issue reported on code.google.com by retep998 on 15 Sep 2011 at 6:58

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions