DungeonCrawl
Loading...
Searching...
No Matches
media_output.c File Reference

Implements functionality for outputing media to the screen. More...

#include "media_output.h"
#include "../../../logging/logger.h"
#include "../../io_handler.h"
#include "../common/output_handler.h"
#include "media_files.h"
#include "media_output_handler.h"
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Functions

bool display_image_at (const char *filename, int x, int y, int height, int width, scale_type_t scale_type)
 Display an image file at specified coordinates with scaling.
bool display_image_cell (const char *filename, int x, int y)
 Fill a single terminal cell with an image.

Detailed Description

Implements functionality for outputing media to the screen.

Definition in file media_output.c.

Function Documentation

◆ display_image_at()

bool display_image_at ( const char * filename,
int x,
int y,
int height,
int width,
scale_type_t scale_type )

Display an image file at specified coordinates with scaling.

Parameters
filenameImage file name (PNG supported, loaded from src/art/png/)
xX coordinate in terminal cells
yY coordinate in terminal cells
heightHeight in terminal cells
widthWidth in terminal cells (0 for auto)
scale_typeScaling mode to use
Returns
true on success, false on failure

Definition at line 32 of file media_output.c.

32 {
33 // Validate parameters
34 if (!filename || height < 0) {
35 // Allow height=0 for automatic scaling
36 log_msg(ERROR, "media_output", "Invalid parameters for display_png_at");
37 return false;
38 }
39 loaded_visual_t* resource = ready_media(filename, x, y, height, width, scale_type);
40 if (!resource) {
41 log_msg(ERROR, "media_output", "Failed to load image for display");
42 return false;
43 }
44 return display_image(resource);
45}
void log_msg(const log_level_t level, const char *module, const char *format,...)
Logs a formatted message with a specified log level and module.
Definition logger.c:246
loaded_visual_t * ready_media(const char *filename, int x, int y, int height, int width, scale_type_t scale_type)
Prepares a media resource for display.
struct loaded_visual_s loaded_visual_t
Structure to represent a loaded visual.

◆ display_image_cell()

bool display_image_cell ( const char * filename,
int x,
int y )

Fill a single terminal cell with an image.

Parameters
filenameImage file name (PNG supported, loaded from src/art/png/)
xX coordinate in terminal cells
yY coordinate in terminal cells
Returns
true on success, false on failure

Definition at line 54 of file media_output.c.

54 {
55 // Validate parameters
56 if (!filename) {
57 log_msg(ERROR, "media_output", "Invalid filename for fill_cell_with_png");
58 return false;
59 }
60 loaded_visual_t* resource = ready_media(filename, x, y, 1, 1, SCALE_CELL);
61 if (!resource) {
62 log_msg(ERROR, "media_output", "Failed to load image for cell");
63 return false;
64 }
65 return display_image(resource);
66}