You are not logged in.

#1 2009-05-08 15:52:23

sammystag
Member

[RESOLVED] Problem with JPEG handling

Hi,

I have been updating my toddtris game for GRRLIB 4.0.0 and hit a problem whereby it would crash as soon as I loaded it. I tracked this down to a problem with the JPEG handling. The following logic to find the length of the char array in the GRRLIB_LoadTextureJPG function

Code:

    if((my_jpg[0]==0xff) && (my_jpg[1]==0xd8) && (my_jpg[2]==0xff)) {
        while(1) {
            if((my_jpg[n]==0xff) && (my_jpg[n+1]==0xd9))
                break;
            n++;
        }
        n+=2;
    }

The problem here is that if the JPEG contains 0xff 0xd9 before the end of the file the size is calculated incorrectly and a crash results - this is the case for the background image I use (images/ttbg.jpg in http://www.themightystags.com/toddtris_ … ris1.0.zip). If I change the GRRLIB_LoadTextureJPG to take n as a parameter and remove the logic above then it all works fine.

Thanks,

sammystag

Offline

 

Board footer

Powered by FluxBB