(SOLVED)[SDL2] - BMP Sprite Sheet - Load Individual Sprites - Transparency Not Working?

Hi,

Working on a new SDL2 project.
When we try to load individual sprites on a sprite sheet, the BMP transparency is not working?

Please see below code:
Any help would be appreciated, thanks!

Jesse

//-------------------------------------------------------------------------------------------------
bool VisualsCore::LoadASCIICharacterSprites(void)
{
    SDL_Surface *spriteSheet = NULL;
    SDL_Surface *charTemp = NULL;
    SDL_Rect dstRect;
    SDL_Rect srcRect;
    Uint32 textureFormat;
    int textureAccess;
    int textureWidth;
    int textureHeight;

    spriteSheet = SDL_LoadBMP("resources/fonts/Characters.bmp");
    if (spriteSheet == NULL)
    {
        printf( "Image loading failed: %s\n", SDL_GetError() );
        CoreFailure = true;
        return(false);
    }

    dstRect.x = 0;
    dstRect.y = 0;
    dstRect.w = 7;
    dstRect.h = 7;
    srcRect.x = 1;
    srcRect.y = 1;
    srcRect.w = 8;
    srcRect.h = 8;
    for (int index = 32; index < 128; index++) // Test - only loads 1st ASCII character
    {
        charTemp = SDL_LoadBMP("resources/visuals/charTemp.bmp");
        if (charTemp == NULL)
        {
            printf( "Image loading failed: %s\n", SDL_GetError() );
            CoreFailure = true;
            return(false);
        }

        SDL_BlitSurface(spriteSheet, &srcRect, charTemp, &dstRect);
        Sprites[index].Texture = SDL_CreateTextureFromSurface(Renderer, charTemp);

        Sprites[index].ScreenX = (1024/2);
        Sprites[index].ScreenY = (640/2);
        Sprites[index].ScaleX = 1.0f;
        Sprites[index].ScaleY = 1.0f;
        Sprites[index].Rotation = 0.0f;
        Sprites[index].RedHue = 255;
        Sprites[index].GreenHue = 255;
        Sprites[index].BlueHue = 255;
        Sprites[index].Transparency = 255;
        Sprites[index].FlipX = false;
        Sprites[index].FlipY = false;
        SDL_QueryTexture(Sprites[index].Texture, &textureFormat, &textureAccess, &textureWidth, &textureHeight);
        Sprites[index].WidthOriginal = textureWidth;
        Sprites[index].HeightOriginal = textureHeight;
        Sprites[index].AnimationTimer = -1;

        SDL_FreeSurface(charTemp);
    }

    SDL_FreeSurface(spriteSheet);

    return(true);
}

//-------------------------------------------------------------------------------------------------

Nevermind, we got it working:

SDL_PixelFormat* pixelFormat = charTemp->format;
Uint32 color = SDL_MapRGB(pixelFormat, 0, 0, 0);
SDL_SetColorKey(charTemp, SDL_TRUE, color);

before:

SDL_BlitSurface(spriteSheet, &srcRect, charTemp, &dstRect);

Lol, I love how you’re solving your own posts. Don’t stop posting, it’s all good info :+1:t2: