Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blit combination not supported #2

Open
steward-fu opened this issue Jan 14, 2024 · 1 comment
Open

Blit combination not supported #2

steward-fu opened this issue Jan 14, 2024 · 1 comment

Comments

@steward-fu
Copy link
Owner

-- code --
SDL_Surface* pokemonImage = IMG_Load(imagePath.c_str());
SDL_Rect pokemonRect;
pokemonRect.x = 0; // Adjust the x position according to your needs
pokemonRect.y = 0; // Adjust the y position according to your needs
pokemonRect.w = 128; // Adjust the width to fill the space to the left of the list
pokemonRect.h = 128; // Adjust the height to fill the window height
SDL_BlitScaled(pokemonImage, NULL, screen, &pokemonRect);

@Yorisoft
Copy link

I think I figured out the issue for that one btw. my images were 4bpp. Once I changed my code to transform it to 32 bpp it worked

SDL_Surface* optimizedSurface = NULL;
optimizedSurface = SDL_ConvertSurfaceFormat(pokemonImage, SDL_PIXELFORMAT_RGBA32, 0); < -- My bread and butter

if (optimizedSurface == NULL) {
    cout << "Unable to optimize image! SDL Error: " << SDL_GetError() << endl;
} else {
    // Free the old surface
    SDL_FreeSurface(pokemonImage);
    // Set the optimized surface to the old surface pointer
    pokemonImage = optimizedSurface;
}

Thank you!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants