c mas masizat gif.cpp

This commit is contained in:
2025-03-15 19:20:04 +01:00
parent cad2c40024
commit 1bb8534db7
3 changed files with 111 additions and 234 deletions

View File

@@ -1,4 +1,3 @@
#include "texture.h"
#include <SDL2/SDL_error.h> // Para SDL_GetError
#include <SDL2/SDL_surface.h> // Para SDL_CreateRGBSurfaceWithFormatFrom
@@ -276,9 +275,10 @@ std::shared_ptr<Surface> Texture::loadSurface(const std::string &file_path)
// Cerrar el archivo (automáticamente manejado por std::ifstream)
file.close();
// Llamar a la función LoadGif
// Crear un objeto Gif y llamar a la función LoadGif
Gif gif;
Uint16 w, h;
Uint8 *rawPixels = LoadGif(buffer.data(), &w, &h);
Uint8 *rawPixels = gif.LoadGif(buffer.data(), &w, &h);
if (!rawPixels)
{
return nullptr;
@@ -348,7 +348,8 @@ std::vector<Uint32> Texture::loadPaletteFromFile(const std::string &file_path)
throw std::runtime_error("Error al leer el fichero: " + getFileName(file_path));
}
const auto *PAL = LoadPalette(buffer.data());
Gif gif;
const auto *PAL = gif.LoadPalette(buffer.data());
if (!PAL)
{
return palette;
@@ -380,4 +381,4 @@ void Texture::setPalette(int palette)
}
// Obtiene el renderizador
SDL_Renderer *Texture::getRenderer(){ return renderer_;}
SDL_Renderer *Texture::getRenderer() { return renderer_; }