#pragma once #include // Para SDL_Renderer, SDL_Texture #include // Para SDL_DisplayID, SDL_GetDisplays #include // Para std::string /** * @brief Helper class para pre-escalar logos usando stb_image_resize2 * * Proporciona funciones para: * - Detectar resolución nativa del monitor * - Cargar PNG y escalar a tamaño específico con algoritmos de alta calidad * - Crear texturas SDL desde buffers escalados * * Usado por AppLogo para pre-generar versiones de logos al tamaño exacto * de pantalla, eliminando el escalado dinámico de SDL y mejorando calidad visual. */ class LogoScaler { public: /** * @brief Detecta la resolución nativa del monitor principal * * @param native_width [out] Ancho nativo del display en píxeles * @param native_height [out] Alto nativo del display en píxeles * @return true si se pudo detectar, false si hubo error */ static bool detectNativeResolution(int& native_width, int& native_height); /** * @brief Carga un PNG y lo escala al tamaño especificado * * Usa stb_image para cargar y stb_image_resize2 para escalar con * algoritmo Mitchell (balance calidad/velocidad) en espacio sRGB. * * @param path Ruta al archivo PNG (ej: "data/logo/logo.png") * @param target_width Ancho destino en píxeles * @param target_height Alto destino en píxeles * @param out_width [out] Ancho real de la imagen escalada * @param out_height [out] Alto real de la imagen escalada * @return Buffer RGBA (4 bytes por píxel) o nullptr si falla * IMPORTANTE: El caller debe liberar con free() cuando termine */ static unsigned char* loadAndScale(const std::string& path, int target_width, int target_height, int& out_width, int& out_height); /** * @brief Crea una textura SDL desde un buffer RGBA * * @param renderer Renderizador SDL activo * @param data Buffer RGBA (4 bytes por píxel) * @param width Ancho del buffer en píxeles * @param height Alto del buffer en píxeles * @return Textura SDL creada o nullptr si falla * IMPORTANTE: El caller debe destruir con SDL_DestroyTexture() */ static SDL_Texture* createTextureFromBuffer(SDL_Renderer* renderer, unsigned char* data, int width, int height); };