converted from bmp to jpg

This commit is contained in:
2025-11-22 21:46:00 +01:00
parent 28dd513619
commit 77a9237e25
47 changed files with 187 additions and 112 deletions

View File

@ -26,7 +26,9 @@
#include "../../gameplay/core/Game.h"
#include "../../gameplay/effects/LineEffect.h"
#include <SDL3/SDL.h>
#include <SDL3_image/SDL_image.h>
#include <SDL3_ttf/SDL_ttf.h>
#include "../../utils/ImagePathResolver.h"
#include <iostream>
#include <cmath>
#include <fstream>
@ -1044,17 +1046,20 @@ void ApplicationManager::setupStateHandlers() {
if (m_cachedBgLevel != bgLevel) {
if (m_nextLevelBackgroundTex) { SDL_DestroyTexture(m_nextLevelBackgroundTex); m_nextLevelBackgroundTex = nullptr; }
char bgPath[256];
std::snprintf(bgPath, sizeof(bgPath), "assets/images/tetris_main_back_level%d.bmp", bgLevel);
SDL_Surface* s = SDL_LoadBMP(bgPath);
std::snprintf(bgPath, sizeof(bgPath), "assets/images/tetris_main_back_level%d.jpg", bgLevel);
const std::string resolvedBgPath = AssetPath::resolveImagePath(bgPath);
SDL_Surface* s = IMG_Load(resolvedBgPath.c_str());
if (s && renderer.getSDLRenderer()) {
m_nextLevelBackgroundTex = SDL_CreateTextureFromSurface(renderer.getSDLRenderer(), s);
SDL_DestroySurface(s);
m_levelFadeAlpha = 0.0f;
m_levelFadeElapsed = 0.0f;
m_cachedBgLevel = bgLevel;
if (resolvedBgPath != bgPath) {
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Loaded level %d background via %s", bgLevel, resolvedBgPath.c_str());
}
} else {
m_cachedBgLevel = -1; // dont change if missing
m_cachedBgLevel = -1; // don't change if missing
m_cachedBgLevel = -1; // don't change if missing
if (s) SDL_DestroySurface(s);
}
}

View File

@ -3,8 +3,10 @@
#include "../../audio/Audio.h"
#include "../../audio/SoundEffect.h"
#include <SDL3/SDL.h>
#include <SDL3_image/SDL_image.h>
#include <SDL3_ttf/SDL_ttf.h>
#include <filesystem>
#include "../../utils/ImagePathResolver.h"
AssetManager::AssetManager()
: m_renderer(nullptr)
@ -379,19 +381,25 @@ SDL_Texture* AssetManager::loadTextureFromFile(const std::string& filepath) {
return nullptr;
}
// Load using SDL_LoadBMP (matching main.cpp pattern)
SDL_Surface* surface = SDL_LoadBMP(filepath.c_str());
if (!surface) {
setError("Failed to load surface from: " + filepath + " - " + SDL_GetError());
const std::string resolvedPath = AssetPath::resolveImagePath(filepath);
SDL_Texture* texture = IMG_LoadTexture(m_renderer, resolvedPath.c_str());
if (!texture) {
std::string message = "Failed to load texture from: ";
message += filepath;
message += " (resolved: ";
message += resolvedPath;
message += ") - ";
message += SDL_GetError();
setError(message);
return nullptr;
}
SDL_Texture* texture = SDL_CreateTextureFromSurface(m_renderer, surface);
SDL_DestroySurface(surface);
if (!texture) {
setError("Failed to create texture from surface: " + filepath + " - " + SDL_GetError());
return nullptr;
if (resolvedPath != filepath) {
std::string message = "Loaded alternative image path for ";
message += filepath;
message += ": ";
message += resolvedPath;
logInfo(message);
}
return texture;