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

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

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

Go to the source code of this file.

Classes

struct  cache_item< T >
 
struct  std::hash< image::locator::value >
 
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 signed char 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_image (const locator &i_locator, TYPE type=UNSCALED)
 [DEPRECATED] Caches and returns an image. 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")
 
mini_terrain_cache_map image::mini_terrain_cache
 
mini_terrain_cache_map image::mini_fogged_terrain_cache
 
mini_terrain_cache_map image::mini_highlighted_terrain_cache
 
static int image::last_index_ = 0
 

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)

◆ ERR_CFG

#define ERR_CFG   LOG_STREAM(err, log_config)

Definition at line 52 of file picture.cpp.

Referenced by image::load_image_sub_file().

◆ ERR_IMG

#define ERR_IMG   LOG_STREAM(err, log_image)

◆ LOG_IMG

#define LOG_IMG   LOG_STREAM(info, log_image)

Definition at line 48 of file picture.cpp.

Referenced by image::save_image().

◆ WRN_IMG

#define WRN_IMG   LOG_STREAM(warn, log_image)

Definition at line 47 of file picture.cpp.

Referenced by image::get_surface(), and image::load_image_file().

Variable Documentation

◆ base64

std::string_view base64

Definition at line 205 of file picture.cpp.

◆ data

std::string_view data

Definition at line 206 of file picture.cpp.

Referenced by gui2::dialogs::campaign_selection::add_campaign_to_tree(), gui2::dialogs::statistics_dialog::add_damage_row(), gui2::dialogs::statistics_dialog::add_hits_row(), gui2::multi_page::add_page(), gui2::dialogs::mp_staging::add_side_node(), gui2::dialogs::statistics_dialog::add_stat_row(), image::locator::add_to_cache(), wesnothd::server::adminmsg_handler(), BF_crypt(), BOOST_AUTO_TEST_CASE(), gui2::implementation::builder_window::build(), events::chat_command_handler::chat_command_handler(), replay_network_sender::commit_and_sync(), ng::connect_engine::connect_engine(), gui2::pane::create_item(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::create_item(), wesnothd::game::current_turn(), events::map_command_handler< chat_command_handler >::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(), 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(), progressive_pair< int >::does_not_change(), ng::depcheck::manager::does_require(), ai::engine_lua::engine_lua(), ai::default_recruitment::recruitment::execute(), gui2::chatbox::find_or_create_window(), game_events::wml_event_pump::fire(), mp::lobby_info::gamelist_initialized(), gui2::dialogs::mp_join_game::generate_side_list(), gui2::dialogs::generator_settings::generator_settings(), t_translation::ter_map::get(), ai::default_recruitment::recruitment::get_best_leader_from_ratio_scores(), progressive_pair< int >::get_current_element(), progressive_single< image::locator >::get_current_element(), events::cmd_arg_parser::get_data(), gui2::dialogs::preferences_dialog::get_friends_list_row_data(), gui2::generator_base::get_items_shown(), ng::depcheck::manager::get_modifications(), ng::depcheck::manager::get_required(), gui2::tree_view::get_root_node(), wesnothd_connection::handle_read(), wesnothd::server::handle_whisper(), game_events::wml_menu_item::hotkey_repeat(), impl_end_level_data_collect(), impl_end_level_data_get(), game_lua_kernel::impl_end_level_data_set(), game_lua_kernel::impl_scenario_get(), game_lua_kernel::impl_scenario_set(), ng::create_engine::init_all_levels(), ng::create_engine::init_generated_level_data(), intf_add_dialog_item(), intf_add_item_of_type(), game_lua_kernel::intf_fire_event(), intf_name_generator(), campaignd::is_text_markup_char(), image::locator::is_void(), campaignd::server::load_config(), preferences::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_join_game::network_handler(), gui2::dialogs::mp_lobby::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()(), config::all_children_iterator::arrow_helper::operator->(), config::const_all_children_iterator::arrow_helper::operator->(), gui2::tree_view_node::operator==(), filesystem::other_version_dir::other_version_dir(), gui2::canvas::parse_cfg(), 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::migrate_version_selection::pre_show(), gui2::dialogs::terrain_layers::pre_show(), gui2::dialogs::help_browser::pre_show(), gui2::dialogs::language_selection::pre_show(), gui2::dialogs::faction_select::pre_show(), gui2::dialogs::mp_change_control::pre_show(), gui2::dialogs::log_settings::pre_show(), gui2::dialogs::mp_create_game::pre_show(), gui2::dialogs::unit_attack::pre_show(), gui2::dialogs::addon_uninstall_list::pre_show(), gui2::dialogs::custom_tod::pre_show(), gui2::dialogs::depcheck_select_new::pre_show(), gui2::dialogs::theme_list::pre_show(), gui2::dialogs::game_stats::pre_show(), gui2::dialogs::campaign_difficulty::pre_show(), gui2::dialogs::campaign_selection::pre_show(), gui2::dialogs::simple_item_selector::pre_show(), gui2::dialogs::drop_down_menu::pre_show(), gui2::dialogs::wml_message_base::pre_show(), gui2::dialogs::file_dialog::pre_show(), ng::create_engine::prepare_for_other(), mp::lobby_info::process_gamelist(), gui2::chatbox::process_message(), progressive_pair< int >::progressive_pair(), progressive_single< image::locator >::progressive_single(), gui2::dialogs::file_dialog::push_fileview_row(), game_events::wml_event_pump::raise(), savegame::save_index_class::read_only(), actions::undo_list::redo(), gui2::dialogs::mp_options_helper::remove_nodes_for_type(), application_lua_kernel::thread::run_script(), gui2::policy::select_action::show::select(), ng::create_engine::select_campaign_difficulty(), gui2::dialogs::custom_tod::select_file(), events::chat_handler::send_chat_room_message(), events::chat_handler::send_command(), wesnothd::server::send_server_message(), events::chat_handler::send_whisper(), campaignd::server::serve_requests(), gui2::addon_list::set_addons(), play_controller::set_end_level_data(), gui2::chatbox::set_self_active(), gui2::window::show(), ng::side_engine::side_engine(), gui2::dialogs::campaign_selection::sort_campaigns(), wesnothd::game::starting_pos(), replay_recorder_base::swap(), replay_network_sender::sync_non_undoable(), t_string_base::t_string_base(), gamemap::tdata(), ai::engine_lua::to_config(), t_string_base::walker::update(), gui2::player_list_helper::update_list(), campaignd::server::validate_addon(), and game_events::WML_HANDLER_FUNCTION().

◆ good

bool good

Definition at line 207 of file picture.cpp.

Referenced by unit_map::self_check().

◆ log_config

lg::log_domain log_config("config")
static

◆ log_image

lg::log_domain log_image("image")
static

◆ mime

std::string_view mime

Definition at line 204 of file picture.cpp.

◆ scheme

std::string_view scheme

Definition at line 203 of file picture.cpp.