The Battle for Wesnoth  1.19.4+dev
Classes | Namespaces | Macros | Functions | Variables
picture.cpp File Reference

Routines for images: load, scale, re-color, etc. More...

#include "picture.hpp"
#include "filesystem.hpp"
#include "game_config.hpp"
#include "image_modifications.hpp"
#include "log.hpp"
#include "serialization/base64.hpp"
#include "serialization/string_utils.hpp"
#include "sdl/rect.hpp"
#include "sdl/texture.hpp"
#include <SDL2/SDL_image.h>
#include <boost/algorithm/string.hpp>
#include <array>
#include <set>
Include dependency graph for picture.cpp:

Go to the source code of this file.

Classes

struct  std::hash< image::locator >
 
class  image::cache_type< T >
 

Namespaces

 image
 Functions to load and save images from/to disk.
 

Macros

#define ERR_IMG   LOG_STREAM(err, log_image)
 
#define WRN_IMG   LOG_STREAM(warn, log_image)
 
#define LOG_IMG   LOG_STREAM(info, log_image)
 
#define DBG_IMG   LOG_STREAM(debug, log_image)
 
#define ERR_CFG   LOG_STREAM(err, log_config)
 

Functions

void image::flush_cache ()
 Purges all image caches. More...
 
std::ostream & image::operator<< (std::ostream &s, const locator &l)
 
static void image::add_localized_overlay (const std::string &ovr_file, surface &orig_surf)
 
static surface image::load_image_file (const image::locator &loc)
 
static surface image::load_image_sub_file (const image::locator &loc)
 
static surface image::load_image_data_uri (const image::locator &loc)
 
static int8_t image::col_to_uchar (int i)
 
light_string image::get_light_string (int op, int r, int g, int b)
 Returns the light_string for one light operation. More...
 
static surface image::apply_light (surface surf, const light_string &ls)
 
static surface image::load_from_disk (const locator &loc)
 
void image::set_color_adjustment (int r, int g, int b)
 Changes Time of Day color tint for all applicable image types. More...
 
static surface image::get_hexed (const locator &i_locator, bool skip_cache=false)
 
static surface image::get_tod_colored (const locator &i_locator, bool skip_cache=false)
 
static TYPE image::simplify_type (const image::locator &i_locator, TYPE type)
 translate type to a simpler one when possible More...
 
surface image::get_surface (const locator &i_locator, TYPE type=UNSCALED, bool skip_cache=false)
 Returns an image surface suitable for software manipulation. More...
 
surface image::get_lighted_image (const image::locator &i_locator, const light_string &ls)
 Caches and returns an image with a lightmap applied to it. More...
 
texture image::get_lighted_texture (const image::locator &i_locator, const light_string &ls)
 
surface image::get_hexmask ()
 Retrieves the standard hexagonal tile mask. More...
 
point image::get_size (const locator &i_locator, bool skip_cache=false)
 Returns the width and height of an image. More...
 
bool image::is_in_hex (const locator &i_locator)
 Checks if an image fits into a single hex. More...
 
bool image::is_empty_hex (const locator &i_locator)
 Checks if an image is empty after hex masking. More...
 
bool image::exists (const locator &i_locator)
 Returns true if the given image actually exists, without loading it. More...
 
static void image::precache_file_existence_internal (const std::string &dir, const std::string &subdir)
 
void image::precache_file_existence (const std::string &subdir="")
 Precache the existence of files in a binary path subdirectory (e.g. More...
 
bool image::precached_file_exists (const std::string &file)
 
save_result image::save_image (const locator &i_locator, const std::string &filename)
 
save_result image::save_image (const surface &surf, const std::string &filename)
 
texture image::get_texture (const locator &i_locator, TYPE type=UNSCALED, bool skip_cache=false)
 Returns an image texture suitable for hardware-accelerated rendering. More...
 
texture image::get_texture (const image::locator &i_locator, scale_quality quality, TYPE type, bool skip_cache)
 Returns a texture for the corresponding image. More...
 

Variables

static lg::log_domain log_image ("image")
 
static lg::log_domain log_config ("config")
 

Detailed Description

Routines for images: load, scale, re-color, etc.

Definition in file picture.cpp.

Macro Definition Documentation

◆ DBG_IMG

#define DBG_IMG   LOG_STREAM(debug, log_image)

Definition at line 44 of file picture.cpp.

◆ ERR_CFG

#define ERR_CFG   LOG_STREAM(err, log_config)

Definition at line 47 of file picture.cpp.

◆ ERR_IMG

#define ERR_IMG   LOG_STREAM(err, log_image)

Definition at line 41 of file picture.cpp.

◆ LOG_IMG

#define LOG_IMG   LOG_STREAM(info, log_image)

Definition at line 43 of file picture.cpp.

◆ WRN_IMG

#define WRN_IMG   LOG_STREAM(warn, log_image)

Definition at line 42 of file picture.cpp.

Variable Documentation

◆ base64

std::string_view base64

Definition at line 177 of file picture.cpp.

◆ data

std::string_view data

Definition at line 178 of file picture.cpp.

Referenced by gui2::dialogs::campaign_selection::add_campaign_to_tree(), gui2::tree_view_node::add_child(), gui2::dialogs::statistics_dialog::add_damage_row(), gui2::dialogs::statistics_dialog::add_hits_row(), gui2::tree_view::add_node(), gui2::dialogs::mp_options_helper::add_node_and_get_widget(), gui2::multi_page::add_page(), gui2::listbox::add_row(), gui2::tree_view_node::add_sibling(), gui2::dialogs::mp_staging::add_side_node(), gui2::dialogs::statistics_dialog::add_stat_row(), image::cache_type< T >::add_to_cache(), gui2::dialogs::help_browser::add_topic(), wesnothd::server::adminmsg_handler(), replay_recorder_base::append_config(), BF_crypt(), game_events::wml_menu_item::can_show(), events::chat_handler::change_logging(), ng::connect_engine::connect_engine(), storyscreen::controller::controller(), gui2::dialogs::custom_tod::copy_to_clipboard_callback(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::create_item(), gui2::pane::create_item(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::create_items(), campaignd::data_apply_addlist(), campaignd::data_apply_removelist(), default_map_generator_job::default_generate_map(), events::map_command_handler< Worker >::dispatch(), gui2::dialogs::mp_options_helper::display_custom_options(), gui2::dialogs::mp_create_game::display_games_of_type(), gui2::dialogs::game_load::display_savegame_internal(), events::chat_command_handler::do_info(), events::chat_command_handler::do_network_send(), do_replay_handle(), events::console_handler::do_set_alias(), events::console_handler::do_set_var(), events::console_handler::do_turn(), events::console_handler::do_unit(), ng::depcheck::manager::does_require(), ai::engine_lua::engine_lua(), ai::default_recruitment::recruitment::execute(), gui2::dialogs::game_load::execute(), gui2::chatbox::find_or_create_window(), game_events::wml_event_pump::fire(), game_events::wml_menu_item::fire_event(), editor::editor_map::from_string(), gamemap::gamemap(), gui2::dialogs::mp_join_game::generate_side_list(), gui2::dialogs::generator_settings::generator_settings(), ai::default_recruitment::recruitment::get_best_leader_from_ratio_scores(), events::cmd_arg_parser::get_data(), gui2::dialogs::preferences_dialog::get_friends_list_row_data(), ng::depcheck::manager::get_required(), display::get_submerge_data(), wesnothd::game::handle_choice(), wesnothd::server::handle_player_in_game(), wesnothd::server::handle_player_in_lobby(), wesnothd_connection::handle_read(), wesnothd::server::handle_whisper(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::impl_create_items(), impl_end_level_data_collect(), impl_end_level_data_get(), game_lua_kernel::impl_end_level_data_set(), ng::connect_engine::import_user(), gui2::policy::select_action::selection::init(), gui2::policy::select_action::show::init(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::init(), ng::create_engine::init_all_levels(), ng::create_engine::init_generated_level_data(), gui2::tree_view_node::init_grid(), ng::depcheck::manager::insert_element(), intf_add_dialog_item(), intf_add_item_of_type(), game_lua_kernel::intf_fire_event(), intf_name_generator(), campaignd::server::load_config(), prefs::load_credentials(), lua_fileops::lua_filestream::lua_read_data(), movetype::terrain_info::make_data_writable(), gui2::dialogs::mp_lobby::make_game_row_data(), gui2::dialogs::mp_lobby::network_handler(), gui2::dialogs::mp_join_game::network_handler(), gui2::dialogs::mp_staging::network_handler(), plugins_manager::notify_event(), gui2::dialogs::file_dialog::on_bookmark_add_cmd(), gui2::dialogs::statistics_dialog::on_primary_list_select(), game_events::filter_formula::operator()(), gui2::dialogs::mp_options_helper::type_node_data::operator<(), gui2::canvas::parse_cfg(), gui2::implementation::parse_list_data(), ng::side_engine::place_user(), gui2::player_list_helper::player_list_helper(), wesnothd::server::pm_handler(), gui2::dialogs::game_load::populate_game_list(), gui2::dialogs::addon_uninstall_list::pre_show(), gui2::dialogs::campaign_difficulty::pre_show(), gui2::dialogs::campaign_selection::pre_show(), gui2::dialogs::depcheck_select_new::pre_show(), gui2::dialogs::drop_down_menu::pre_show(), gui2::dialogs::custom_tod::pre_show(), gui2::dialogs::file_dialog::pre_show(), gui2::dialogs::game_stats::pre_show(), gui2::dialogs::language_selection::pre_show(), gui2::dialogs::log_settings::pre_show(), gui2::dialogs::migrate_version_selection::pre_show(), gui2::dialogs::faction_select::pre_show(), gui2::dialogs::mp_change_control::pre_show(), gui2::dialogs::mp_create_game::pre_show(), gui2::dialogs::simple_item_selector::pre_show(), gui2::dialogs::terrain_layers::pre_show(), gui2::dialogs::theme_list::pre_show(), gui2::dialogs::unit_attack::pre_show(), gui2::dialogs::wml_message_base::pre_show(), ng::create_engine::prepare_for_other(), wesnothd::game::process_change_turns_wml(), mp::lobby_info::process_gamelist(), gui2::dialogs::mp_lobby::process_gamelist(), mp::lobby_info::process_gamelist_diff(), gui2::dialogs::mp_lobby::process_gamelist_diff(), mp::lobby_info::process_gamelist_diff_impl(), gui2::chatbox::process_message(), wesnothd::game::process_message(), gui2::chatbox::process_network_data(), ng::connect_engine::process_network_data(), gui2::dialogs::mp_lobby::process_network_data(), wesnothd::game::process_turn(), wesnothd::game::process_whiteboard(), gui2::dialogs::file_dialog::push_fileview_row(), game_events::wml_event_pump::raise(), gamemap::read(), gamemap::read_header(), wesnothd::game::record_data(), actions::undo_list::redo(), gui2::dialogs::mp_options_helper::remove_nodes_for_type(), gui2::tree_view_node::replace_children(), synced_context::run(), synced_context::run_and_store(), synced_context::run_and_throw(), synced_context::run_in_synced_context_if_not_already(), application_lua_kernel::thread::run_script(), ng::create_engine::select_campaign_difficulty(), gui2::dialogs::custom_tod::select_file(), playmp_controller::send_actions(), events::chat_handler::send_chat_room_message(), events::chat_handler::send_command(), wesnothd::game::send_data(), wesnothd::game::send_data_sides(), wesnothd::server::send_to_lobby(), wesnothd::server::send_to_player(), wesnothd::game::send_to_players(), mp::send_to_server(), events::chat_handler::send_whisper(), campaignd::server::serve_requests(), gui2::addon_list::set_addons(), gui2::toggle_panel::set_child_members(), play_controller::set_end_level_data(), gui2::styled_widget::set_members(), gui2::toggle_button::set_members(), gui2::window::show(), lua_gui2::show_gamestate_inspector(), gui2::dialogs::help_browser::show_topic(), ng::side_engine::side_engine(), font::span_color(), wesnothd::game::starting_pos(), t_string_base::t_string_base(), ai::engine_lua::to_config(), gui2::tree_view_node::tree_view_node(), t_string_base::walker::update(), gui2::player_list_helper::update_list(), campaignd::server::validate_addon(), wesnothd_connection::wait_and_receive_data(), game_events::WML_HANDLER_FUNCTION(), filesystem::write_file(), and write_hashlist().

◆ good

bool good

Definition at line 179 of file picture.cpp.

Referenced by unit_map::self_check().

◆ log_config

lg::log_domain log_config("config") ( "config"  )
static

◆ log_image

lg::log_domain log_image("image") ( "image"  )
static

◆ mime

std::string_view mime

Definition at line 176 of file picture.cpp.

◆ scheme

std::string_view scheme

Definition at line 175 of file picture.cpp.