this module manages the cache of images. More...
Classes | |
class | adjust_alpha_modification |
Adjust Alpha (ADJUST_ALPHA) modification. More... | |
struct | background_modification |
Fill background with a color (BG). More... | |
class | bl_modification |
Gaussian-like blur (BL) modification. More... | |
class | blend_modification |
Color blending (BLEND) modification. More... | |
class | blit_modification |
Scale (BLIT) modification. More... | |
struct | brighten_modification |
Overlay with ToD brightening (BRIGHTEN). More... | |
class | bw_modification |
Black and white (BW) modification. More... | |
singleton | cache_type |
class | color_adjustment_resetter |
class | crop_modification |
Crop (CROP) modification. More... | |
class | cs_modification |
Color-shift (CS, R, G, B) modification. More... | |
struct | darken_modification |
Overlay with ToD darkening (DARKEN). More... | |
class | fl_modification |
Mirror (FL) modification. More... | |
class | gs_modification |
Grayscale (GS) modification. More... | |
class | light_modification |
LIGHT (L) modification. More... | |
class | locator |
struct | manager |
the image manager is responsible for setting up images, and destroying all images when the program exits. More... | |
class | mask_modification |
Mask (MASK) modification. More... | |
class | modification |
Base abstract class for an image-path modification. More... | |
class | modification_queue |
A modified priority queue used to order image modifications. More... | |
class | negative_modification |
Make an image negative (NEG) More... | |
class | o_modification |
Opacity (O) modification. More... | |
class | plot_alpha_modification |
Plot Alpha (Alpha) modification. More... | |
class | rc_modification |
Recolor (RC/TC/PAL) modification. More... | |
class | rotate_modification |
Rotate (ROTATE) modification. More... | |
class | scale_exact_modification |
Scale exact modification. More... | |
class | scale_into_modification |
Scale into (SCALE_INTO) modification. More... | |
class | scale_modification |
Scaling modifications base class. More... | |
struct | sepia_modification |
Give to the image a sepia tint (SEPIA) More... | |
class | swap_modification |
Channel swap (SWAP). More... | |
class | wipe_alpha_modification |
Wipe Alpha (Wipe_Alpha) modification. More... | |
class | xbrz_modification |
xBRZ scale (xBRZ) modification More... | |
Typedefs | |
typedef cache_type< surface > | image_cache |
typedef cache_type< bool > | bool_cache |
typedef std::map < t_translation::t_terrain, surface > | mini_terrain_cache_map |
typedef std::basic_string < signed char > | light_string |
light_string store colors info of central and adjacent hexes. More... | |
typedef std::map< light_string, surface > | lit_variants |
typedef cache_type< lit_variants > | lit_cache |
Enumerations | |
enum | TYPE { UNSCALED, SCALED_TO_ZOOM, HEXED, SCALED_TO_HEX, TOD_COLORED, BRIGHTENED } |
UNSCALED : image will be drawn "as is" without changing size, even in case of redraw SCALED_TO_ZOOM : image will be scaled taking zoom into account HEXED : the hex mask is applied on the image SCALED_TO_HEX : image will be scaled to fit into a hex, taking zoom into account TOD_COLORED : same as SCALED_TO_HEX but ToD coloring is also applied BRIGHTENED : same as TOD_COLORED but also brightened. More... | |
Functions | |
void | flush_cache () |
size_t | hash_value (const locator::value &val) |
static bool | localized_file_uptodate (const std::string &loc_file) |
static std::string | get_localized_path (const std::string &file, const std::string &suff="") |
static void | add_localized_overlay (const std::string &ovr_file, surface &orig_surf) |
static surface | load_image_file (const image::locator &loc) |
static surface | load_image_sub_file (const image::locator &loc) |
static signed char | col_to_uchar (int i) |
light_string | get_light_string (int op, int r, int g, int b) |
return light_string of one light operation(see above) More... | |
static surface | apply_light (surface surf, const light_string &ls) |
surface | load_from_disk (const locator &loc) |
void | set_pixel_format (SDL_PixelFormat *format) |
sets the pixel format used by the images. More... | |
void | set_color_adjustment (int r, int g, int b) |
will make all scaled images have these rgb values added to all their pixels. More... | |
void | set_team_colors (const std::vector< std::string > *colors=nullptr) |
set the team colors used by the TC image modification use a vector with one string for each team using nullptr will reset to default TC More... | |
const std::vector< std::string > & | get_team_colors () |
void | set_zoom (int zoom) |
sets the amount scaled images should be scaled. More... | |
template<scaling_function F> | |
static surface | scale_xbrz_helper (const surface &res, int w, int h) |
static scaling_function | select_algorithm (gui2::tadvanced_graphics_options::SCALING_ALGORITHM algo) |
static surface | get_hexed (const locator &i_locator) |
static surface | get_scaled_to_hex (const locator &i_locator) |
static surface | get_tod_colored (const locator &i_locator) |
static surface | get_scaled_to_zoom (const locator &i_locator) |
static surface | get_brightened (const locator &i_locator) |
static TYPE | simplify_type (const image::locator &i_locator, TYPE type) |
translate type to a simpler one when possible More... | |
surface | get_image (const locator &i_locator, TYPE type=UNSCALED) |
function to get the surface corresponding to an image. More... | |
surface | get_lighted_image (const image::locator &i_locator, const light_string &ls, TYPE type) |
function to get the surface corresponding to an image. More... | |
surface | get_hexmask () |
function to get the standard hex mask More... | |
bool | is_in_hex (const locator &i_locator) |
function to check if an image fit into an hex return false if the image has not the standard size. More... | |
bool | is_empty_hex (const locator &i_locator) |
function to check if an image is empty after hex cut should be only used on terrain image (cache the hex cut version) More... | |
surface | reverse_image (const surface &surf) |
function to reverse an image. More... | |
bool | exists (const locator &i_locator) |
returns true if the given image actually exists, without loading it. More... | |
static void | precache_file_existence_internal (const std::string &dir, const std::string &subdir) |
void | precache_file_existence (const std::string &subdir="") |
precache the existence of files in the subdir (ex: "terrain/") More... | |
bool | precached_file_exists (const std::string &file) |
bool | save_image (const locator &i_locator, const std::string &filename) |
bool | save_image (const surface &surf, const std::string &filename) |
bool | update_from_preferences () |
initialize any private data, e.g. algorithm choices from preferences More... | |
surface | getMinimap (int w, int h, const gamemap &map_, const team *vm=nullptr, const std::map< map_location, unsigned int > *reach_map=nullptr) |
function to create the minimap for a given map the surface returned must be freed by the user More... | |
Variables | |
mini_terrain_cache_map | mini_terrain_cache |
mini_terrain_cache_map | mini_fogged_terrain_cache |
mini_terrain_cache_map | mini_highlighted_terrain_cache |
static int | last_index_ = 0 |
static std::set< std::string > | fuzzy_localized_files |
static SDL_PixelFormat | last_pixel_format |
this module manages the cache of images.
With an image name, you can get the surface corresponding to that image.
typedef cache_type<bool> image::bool_cache |
typedef cache_type<surface> image::image_cache |
typedef std::basic_string<signed char> image::light_string |
typedef cache_type<lit_variants> image::lit_cache |
typedef std::map<light_string, surface> image::lit_variants |
typedef std::map<t_translation::t_terrain, surface> image::mini_terrain_cache_map |
enum image::TYPE |
UNSCALED : image will be drawn "as is" without changing size, even in case of redraw SCALED_TO_ZOOM : image will be scaled taking zoom into account HEXED : the hex mask is applied on the image SCALED_TO_HEX : image will be scaled to fit into a hex, taking zoom into account TOD_COLORED : same as SCALED_TO_HEX but ToD coloring is also applied BRIGHTENED : same as TOD_COLORED but also brightened.
Enumerator | |
---|---|
UNSCALED | |
SCALED_TO_ZOOM | |
HEXED | |
SCALED_TO_HEX | |
TOD_COLORED | |
BRIGHTENED |
|
static |
Definition at line 466 of file image.cpp.
References filesystem::load_RWops(), surface::null(), and sdl_blit().
Referenced by load_image_file().
Definition at line 583 of file image.cpp.
References adjust_surface_color(), blit_surface(), get_lighted_image(), HEXED, i, light_surface(), and make_neutral_surface().
Referenced by get_lighted_image().
|
static |
Definition at line 569 of file image.cpp.
Referenced by get_light_string().
bool image::exists | ( | const image::locator & | i_locator | ) |
returns true if the given image actually exists, without loading it.
Definition at line 1187 of file image.cpp.
References gui2::cache, filesystem::get_binary_file_location(), image::locator::get_filename(), and image::locator::get_type().
Referenced by persist_file_context::clear_var(), filesystem::create_directory_if_missing(), filesystem::create_directory_if_missing_recursive(), addon_info::display_icon(), filesystem::file_exists(), display::fill_images_list(), filesystem::get_exe_dir(), display::get_fog_shroud_images(), wesnothd::server::handle_login(), image_exists(), and ng::depcheck::MAKE_ENUM().
void image::flush_cache | ( | ) |
Definition at line 191 of file image.cpp.
Referenced by do_gameloop(), events::console_handler::do_refresh(), editor::editor_controller::refresh_image_cache(), set_pixel_format(), game_launcher::start_editor(), gui2::tadvanced_graphics_options::update_scale_case(), and image::manager::~manager().
|
static |
Definition at line 837 of file image.cpp.
References brighten_image(), ftofxp, get_image(), game_config::hex_brightening, and TOD_COLORED.
Referenced by get_image().
|
static |
Definition at line 795 of file image.cpp.
References image::locator::add_to_cache(), image::locator::get_filename(), get_hexmask(), get_image(), mask_surface(), and UNSCALED.
Referenced by get_image().
surface image::get_hexmask | ( | ) |
function to get the standard hex mask
Definition at line 1115 of file image.cpp.
References get_image(), game_config::images::terrain_mask, and UNSCALED.
Referenced by get_hexed(), is_empty_hex(), is_in_hex(), load_image_sub_file(), and editor::mouse_action::set_terrain_mouse_overlay().
surface image::get_image | ( | const image::locator & | i_locator, |
TYPE | type | ||
) |
function to get the surface corresponding to an image.
Definition at line 878 of file image.cpp.
References image::locator::add_to_cache(), BRIGHTENED, create_optimized_surface(), get_brightened(), get_hexed(), get_scaled_to_hex(), get_scaled_to_zoom(), get_tod_colored(), HEXED, image::locator::in_cache(), image::locator::is_void(), load_from_disk(), image::locator::locate_in_cache(), SCALED_TO_HEX, SCALED_TO_ZOOM, simplify_type(), TOD_COLORED, and UNSCALED.
Referenced by help::help_text_area::add_img_item(), gui2::timage::calculate_best_size(), ng::campaign::create_image_surface(), events::console_handler::do_layers(), draw_background(), unit_drawer::draw_bar(), display::draw_border(), mp::wait::leader_preview_pane::draw_contents(), gui::scrollbar::draw_contents(), dialogs::unit_preview_pane::draw_contents(), mp::ui::draw_contents(), editor::editor_display::draw_hex(), wb::attack::draw_hex(), wb::suppose_dead::draw_hex(), arrow::draw_hex(), game_display::draw_hex(), display::draw_hex(), editor::item_palette::draw_item(), editor::unit_palette::draw_item(), editor::terrain_palette::draw_item(), draw_label(), game_display::draw_movement_info(), draw_panel(), gui::multimenu::draw_row(), mp::gamebrowser::draw_row(), footsteps_images(), get_brightened(), get_cursor(), dialogs::units_list_preview_pane::get_details(), dialogs::unit_types_preview_pane::get_details(), display::get_flag(), display::get_fog_shroud_images(), get_hexed(), get_hexmask(), gui::menu::style::get_item_image(), get_lighted_image(), unit_frame::get_overlaped_hex(), storyscreen::floating_image::get_render_input(), get_scaled_to_hex(), get_scaled_to_zoom(), display::get_terrain_images(), get_tod_colored(), getMinimap(), gui::multimenu::hit_checkbox(), help::image_width(), game_launcher::init_video(), intf_get_image_size(), is_empty_hex(), is_in_hex(), gui::menu::imgsel_style::load_image(), load_image_file(), load_image_sub_file(), gui::button::load_images(), game_display::new_turn(), image::brighten_modification::operator()(), image::darken_modification::operator()(), storyscreen::part_ui::prepare_background(), unit_frame::redraw(), unit_drawer::redraw_unit(), display::refresh_report(), halo::halo_impl::effect::render(), storyscreen::part_ui::render_story_box_borders(), save_image(), gui::scrollbar::scrollbar(), editor::mouse_action_item::set_item_mouse_overlay(), editor::mouse_action_map_label::set_mouse_overlay(), editor::mouse_action_village::set_mouse_overlay(), editor::mouse_action_select::set_mouse_overlay(), editor::mouse_action_paste::set_mouse_overlay(), editor::mouse_action_starting_position::set_mouse_overlay(), editor::mouse_action::set_terrain_mouse_overlay(), editor::mouse_action_unit::set_unit_mouse_overlay(), about::show_about(), and gui::tristate_button::tristate_button().
light_string image::get_light_string | ( | int | op, |
int | r, | ||
int | g, | ||
int | b | ||
) |
return light_string of one light operation(see above)
Definition at line 573 of file image.cpp.
References col_to_uchar().
Referenced by display::draw_hex(), and display::get_terrain_images().
surface image::get_lighted_image | ( | const image::locator & | i_locator, |
const light_string & | ls, | ||
TYPE | type | ||
) |
function to get the surface corresponding to an image.
after applying the lightmap encoded in ls type should be HEXED or SCALED_TO_HEX
Definition at line 1063 of file image.cpp.
References image::locator::access_in_cache(), image::locator::add_to_cache(), apply_light(), create_optimized_surface(), get_image(), HEXED, image::locator::in_cache(), image::locator::is_void(), image::locator::locate_in_cache(), scale_surface(), SCALED_TO_HEX, and game_config::tile_size.
Referenced by apply_light(), display::draw_hex(), and display::get_terrain_images().
|
static |
Definition at line 430 of file image.cpp.
References _(), filesystem::base_name(), filesystem::directory_name(), filesystem::file_exists(), localized_file_uptodate(), and utils::split().
Referenced by load_image_file().
|
static |
Definition at line 805 of file image.cpp.
References get_image(), HEXED, and surface::null().
Referenced by get_image().
|
static |
Definition at line 823 of file image.cpp.
References surface::get(), get_image(), surface::null(), game_config::tile_size, and UNSCALED.
Referenced by get_image().
const std::vector< std::string > & image::get_team_colors | ( | ) |
|
static |
Definition at line 817 of file image.cpp.
References adjust_surface_color(), get_image(), and SCALED_TO_HEX.
Referenced by get_image().
surface image::getMinimap | ( | int | w, |
int | h, | ||
const gamemap & | map, | ||
const team * | vw, | ||
const std::map< map_location, unsigned int > * | reach_map | ||
) |
function to create the minimap for a given map the surface returned must be freed by the user
Definition at line 43 of file minimap.cpp.
References adjust_surface_color(), preferences::allied_color(), blit_surface(), gui2::cache, game_config::color_info(), create_color(), create_neutral_surface(), sdl::create_rect(), DBG_DP, preferences::enemy_color(), sdl::fill_rect(), gui2::event::find(), team::fogged(), resources::gameboard, get_image(), team::get_minimap_color(), terrain_type_data::get_terrain_info(), gamemap::h(), HEXED, i, terrain_type::id(), int(), int_to_color(), display::is_blindfolded(), terrain_type::is_combined(), team::is_enemy(), is_odd(), terrain_type::is_village(), make_neutral_surface(), mini_fogged_terrain_cache, mini_highlighted_terrain_cache, mini_terrain_cache, preferences::minimap_draw_terrain(), preferences::minimap_draw_villages(), terrain_type::minimap_image(), terrain_type::minimap_image_overlay(), preferences::minimap_movement_coding(), preferences::minimap_terrain_coding(), gamemap::on_board(), team::owns_village(), color_range::rep(), scale_surface_sharp(), resources::screen, sdl_blit(), team::shrouded(), surf, gamemap::tdata(), game_config::team_rgb_range, gui2::terrain, gamemap::total_height(), gamemap::total_width(), terrain_type_data::underlying_union_terrain(), preferences::unmoved_color(), display_context::village_owner(), t_translation::VOID_TERRAIN, and gamemap::w().
Referenced by ng::scenario::create_image_surface(), display::draw_minimap(), gui2::tminimap::get_image(), and mp::gamebrowser::populate_game_item_map_info().
size_t image::hash_value | ( | const locator::value & | val | ) |
Definition at line 374 of file image.cpp.
References image::locator::value::center_x_, image::locator::value::center_y_, image::locator::FILE, image::locator::value::filename_, image::locator::hash_value, image::locator::value::loc_, image::locator::value::modifications_, image::locator::SUB_FILE, image::locator::value::type_, map_location::x, and map_location::y.
bool image::is_empty_hex | ( | const locator & | i_locator | ) |
function to check if an image is empty after hex cut should be only used on terrain image (cache the hex cut version)
Definition at line 1146 of file image.cpp.
References image::locator::add_to_cache(), get_hexmask(), get_image(), HEXED, image::locator::in_cache(), image::locator::locate_in_cache(), and mask_surface().
Referenced by terrain_builder::tile::rebuild_cache().
bool image::is_in_hex | ( | const locator & | i_locator | ) |
function to check if an image fit into an hex return false if the image has not the standard size.
Definition at line 1121 of file image.cpp.
References image::locator::add_to_cache(), get_hexmask(), get_image(), image::locator::in_cache(), in_mask_surface(), image::locator::locate_in_cache(), and UNSCALED.
Referenced by unit_frame::get_overlaped_hex().
surface image::load_from_disk | ( | const locator & | loc | ) |
Definition at line 633 of file image.cpp.
References image::locator::FILE, image::locator::get_type(), load_image_file(), load_image_sub_file(), and image::locator::SUB_FILE.
Referenced by get_image().
|
static |
Definition at line 481 of file image.cpp.
References add_localized_overlay(), game_config::debug, ERR_DP, filesystem::get_binary_file_location(), image::locator::get_filename(), get_image(), get_localized_path(), filesystem::load_RWops(), game_config::images::missing, surface::null(), and UNSCALED.
Referenced by load_from_disk().
|
static |
Definition at line 516 of file image.cpp.
References image::locator::add_to_cache(), sdl::create_rect(), cut_surface(), image::modification::decode(), e, image::modification_queue::empty(), ERR_CFG, image::locator::get_center_x(), image::locator::get_center_y(), image::locator::get_filename(), get_hexmask(), get_image(), image::locator::get_loc(), image::locator::get_modifications(), mask_surface(), image::modification::texception::message, image::modification_queue::pop(), surf, game_config::tile_size, image::modification_queue::top(), UNSCALED, map_location::valid(), map_location::x, and map_location::y.
Referenced by load_from_disk().
|
static |
Definition at line 401 of file image.cpp.
References filesystem::get_binary_file_location(), game_config::path, filesystem::read_file(), utils::split(), and utils::strip().
Referenced by get_localized_path().
void image::precache_file_existence | ( | const std::string & | subdir | ) |
precache the existence of files in the subdir (ex: "terrain/")
Definition at line 1229 of file image.cpp.
References filesystem::get_binary_paths(), and precache_file_existence_internal().
Referenced by terrain_builder::terrain_builder().
|
static |
Definition at line 1203 of file image.cpp.
References d, filesystem::DONT_REORDER, filesystem::FILE_NAME_ONLY, filesystem::get_files_in_dir(), filesystem::is_directory(), and filesystem::NO_FILTER.
Referenced by precache_file_existence().
bool image::precached_file_exists | ( | const std::string & | file | ) |
Definition at line 1240 of file image.cpp.
Referenced by image_exists().
function to reverse an image.
The image MUST have originally been returned from an image:: function. Returned images have the same semantics as for get_image()
Definition at line 1165 of file image.cpp.
References flip_surface(), and itor.
Referenced by dialogs::unit_preview_pane::draw_contents(), halo::halo_impl::effect::render(), and display::render_image().
bool image::save_image | ( | const locator & | i_locator, |
const std::string & | filename | ||
) |
Definition at line 1249 of file image.cpp.
References get_image().
Referenced by create_image_base(), create_image_blend_functor(), main(), game_launcher::play_render_image_mode(), and display::screenshot().
bool image::save_image | ( | const surface & | surf, |
const std::string & | filename | ||
) |
Definition at line 1254 of file image.cpp.
References filesystem::ends_with(), surface::get(), LOG_DP, surface::null(), SDL_PNGFormatAlpha(), and SDL_SavePNG.
|
static |
Definition at line 758 of file image.cpp.
References surface::get(), and scale_surface_xbrz().
|
static |
Definition at line 765 of file image.cpp.
References scale_surface(), and scale_surface_nn().
Referenced by update_from_preferences().
will make all scaled images have these rgb values added to all their pixels.
i.e. add a certain color hint to images. useful for representing day/night. Invalidates all scaled images.
Definition at line 698 of file image.cpp.
References g.
Referenced by editor::editor_controller::execute_command(), image::color_adjustment_resetter::reset(), display::update_tod(), and gui2::tcustom_tod::update_tod_display().
void image::set_pixel_format | ( | SDL_PixelFormat * | format | ) |
sets the pixel format used by the images.
Is called every time the video mode changes. Invalidates all images.
Definition at line 666 of file image.cpp.
References flush_cache(), last_pixel_format, and LOG_DP.
Referenced by CVideo::init_window(), CVideo::make_fake(), CVideo::make_test_fake(), and CVideo::setMode().
void image::set_team_colors | ( | const std::vector< std::string > * | colors | ) |
set the team colors used by the TC image modification use a vector with one string for each team using nullptr will reset to default TC
Definition at line 722 of file image.cpp.
Referenced by do_gameloop(), and display::init_flags().
sets the amount scaled images should be scaled.
Invalidates all scaled images.
Definition at line 736 of file image.cpp.
References amount, and game_config::tile_size.
Referenced by display::bounds_check_position(), display::display(), and display::set_zoom().
|
static |
translate type to a simpler one when possible
Definition at line 844 of file image.cpp.
References BRIGHTENED, ftofxp, image::locator::get_loc(), game_config::hex_brightening, HEXED, SCALED_TO_HEX, SCALED_TO_ZOOM, game_config::tile_size, TOD_COLORED, UNSCALED, and map_location::valid().
Referenced by get_image().
bool image::update_from_preferences | ( | ) |
initialize any private data, e.g. algorithm choices from preferences
Definition at line 1274 of file image.cpp.
References preferences::get(), and select_algorithm().
Referenced by do_gameloop(), and gui2::tadvanced_graphics_options::post_show().
|
static |
|
static |
Definition at line 664 of file image.cpp.
Referenced by set_pixel_format().
mini_terrain_cache_map image::mini_fogged_terrain_cache |
Definition at line 186 of file image.cpp.
Referenced by getMinimap().
mini_terrain_cache_map image::mini_highlighted_terrain_cache |
Definition at line 187 of file image.cpp.
Referenced by getMinimap().
mini_terrain_cache_map image::mini_terrain_cache |
Definition at line 185 of file image.cpp.
Referenced by getMinimap().