We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 912

Summary: Under SDL 1.3 some images in TGA format do not display correctly.
Product: SDL Reporter: Ken Rogoway <Ken>
Component: videoAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: blocker    
Priority: P2    
Version: HG 2.0   
Hardware: x86   
OS: Windows (XP)   
Attachments: 3 Image files to show the issue

Description Ken Rogoway 2009-12-22 14:43:32 UTC
Created attachment 467 [details]
3 Image files to show the issue

There are 3 images in the attached ZIP:

"Image 1 - Original.tga"
"Image 2 - This is what it DOES look like.png"
"Image 3 - This is what it SHOULD look like.png"

If I use IMG_Load() to load the 1st image then when I display it using the new native SDL 1.3 API it looks like Image 2.  If I convert the image to a PNG (Image 3) and load it, it looks correct.

This may be a SDL_image issue and not an SDL 1.3 issue, but since it displays correctly if I use SDL-1.2.14 I am filing it as and SDL 1.3 issue.

Code snippet:

SDL_TextureID LoadImage( char *pFile, int& nW, int& nH )
{
    SDL_TextureID nID = 0;

    SDL_Surface *pSurface = IMG_Load( "Image 1 - Original.tga" );

    if ( NULL != pSurface )
    {
        nID = SDL_CreateTextureFromSurface( NULL, pSurface );

        // Save the width and height of the image
        nW = pSurface->w;
        nH = pSurface->h;

        SDL_FreeSurface( pSurface );
    }

    return nID;
}

void DrawImage( SDL_TextureID nSrcID, int nX, int nY, int nW, int nH )
{
    SDL_Rect dstRect;

    dstRect.x = nX;
    dstRect.y = nY;
    dstRect.w = nW;
    dstRect.h = nH;

    SDL_RenderCopy( nSrcID, NULL, &dstRect );
}
Comment 1 Sam Lantinga 2009-12-22 22:02:10 UTC
I am able to reproduce this here.  I'm looking into it.

Thanks!
Comment 2 Sam Lantinga 2009-12-22 22:39:36 UTC
This was a simple fix, committed in revision 5433.

Thanks!