mostra el render device en info_debug

This commit is contained in:
2026-03-27 10:18:41 +01:00
parent c5a7c9e70d
commit deb0a8677f
6 changed files with 38 additions and 10 deletions

View File

@@ -524,14 +524,24 @@ void Surface::renderWithVerticalFade(int x, int y, int fade_h, int canvas_height
}
// Vuelca los píxeles como ARGB8888 a un buffer externo (sin SDL_Texture ni SDL_Renderer)
void Surface::toARGBBuffer(Uint32* buffer) const { // NOLINT(readability-convert-member-functions-to-static)
if (!surface_data_ || (surface_data_->data == nullptr)) { return; }
void Surface::toARGBBuffer(Uint32* buffer) const {
if (!surface_data_ || !surface_data_->data || !buffer) { return; }
const int WIDTH = static_cast<int>(surface_data_->width);
const int HEIGHT = static_cast<int>(surface_data_->height);
const Uint8* src = surface_data_->data.get();
for (int y = 0; y < HEIGHT; ++y) {
for (int x = 0; x < WIDTH; ++x) {
buffer[(y * WIDTH) + x] = palette_[src[(y * WIDTH) + x]];
// Obtenemos el tamaño de la paleta para evitar accesos fuera de rango
const size_t PAL_SIZE = palette_.size();
for (int i = 0; i < WIDTH * HEIGHT; ++i) {
Uint8 color_index = src[i];
// Verificación de seguridad: ¿El índice existe en la paleta?
if (color_index < PAL_SIZE) {
buffer[i] = palette_[color_index];
} else {
buffer[i] = 0xFF000000; // Negro opaco si el índice es erróneo
}
}
}