The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Macros | Functions | Variables
filter.cpp File Reference
#include "wesmage/filter.hpp"
#include "serialization/string_utils.hpp"
#include "wesmage/exit.hpp"
#include "utils/functional.hpp"
#include <iostream>
Include dependency graph for filter.cpp:

Go to the source code of this file.

Classes

struct  tfilter
 Contains the definition of a filter. More...
 
struct  tregister_filter
 Helper structure to register a filter to the filters. More...
 

Macros

#define REGISTER(name, description)
 Register macro for a filter. More...
 

Functions

static void scale (surface &surf, const std::string &parameters)
 
 REGISTER (scale,"|Scales the size of an image.""|new_width""|unsigned""|The width in pixel of the image after scaling.""|new_height""|unsigned""|The height in pixel of the image after scaling.") static void brighten(surface &surf
 
 if (count!=1)
 
 REGISTER (brighten,"|Brightens an image.""|amount""|float""|The amount the image should be brightened. The value of the every ""color channel is multiplied by this value. Value less than zero ""are set to zero. The alpha channel is not modified.") static void blend(surface &surf
 
 REGISTER (blend,"|Blends an image with another color.""|amount""|float""|The amount every pixel needs to be blended with its original value. ""The formula is:\n""result = amount * color + (1 - amount) * original\n""The value needs to be in the range [0, 1].""|color""|unsigned""|The color to blend with. The value should be given as 32-bit ""hexadecimal value. The first fields should look like AARRGGBB, ""where AA is the alpha channel, RR is the red channel, GG is the ""green channel and BB is the blue channel. (Note the alpha channel ""is ignored.") void filter_apply(surface &surf
 
 if (f.size()!=2)
 
 if (itor==filters.end())
 
itor second functor (surf, f[1])
 
std::vector< tfilter_descriptionfilter_list ()
 Returns the list of available filters. More...
 

Variables

static std::map< std::string,
tfilter
filters
 The list of the available filters. More...
 
const std::string &parameters float amount
 
const int count = sscanf(parameters.c_str(), "%f", &amount)
 
 surf = brighten_image(surf, amount)
 
const std::stringparameters
 
unsigned color
 
const std::stringfilter
 
std::map< std::string, tfilter >
::iterator 
itor = filters.find(f[0])
 

Macro Definition Documentation

#define REGISTER (   name,
  description 
)
Value:
tregister_filter register_filter_##name(std::make_pair( \
#name \
, tfilter(#name, #name description, std::bind(name, _1, _2))));
Contains the definition of a filter.
Definition: filter.cpp:25
GLuint const GLchar * name
Definition: glew.h:1782
Helper structure to register a filter to the filters.
Definition: filter.cpp:80

Register macro for a filter.

Parameters
nameThe name of the filter.
descriptionA pipe-symbol separated list with the description. The name is automatically prefixed, so the item should start with a pipe-symbol. When the list is splitted in to a vector of string its contents should be compatible with the constructor of tfilter_description.

Definition at line 100 of file filter.cpp.

Function Documentation

std::vector<tfilter_description> filter_list ( )

Returns the list of available filters.

Definition at line 239 of file filter.cpp.

Referenced by print_help().

itor second functor ( surf  ,
f  [1] 
)
if ( count!  = 1)

Definition at line 135 of file filter.cpp.

if ( f.size()!  = 2)

Definition at line 191 of file filter.cpp.

if ( itor  = filters.end())

Definition at line 201 of file filter.cpp.

REGISTER ( scale  ,
"|Scales the size of an image.""|new_width""|unsigned""|The width in pixel of the image after scaling.""|new_height""|unsigned""|The height in pixel of the image after scaling."   
)
REGISTER ( brighten  ,
"|Brightens an image.""|amount""|float""|The amount the image should be brightened. The value of the every ""color channel is multiplied by this value. Value less than zero ""are set to zero. The alpha channel is not modified."   
)
REGISTER ( blend  ,
"|Blends an image with another color.""|amount""|float""|The amount every pixel needs to be blended with its original value. ""The formula is:\n""  result = amount * color + (1 - amount) * original\n" "The value needs to be in the range [0,
1]." "|color" "|unsigned" "|The color to blend with.The value should be given as 32-bit" "hexadecimal value.The first fields should look like  AARRGGBB,
" "where AA is the alpha  channel,
RR is the red  channel 
)
static void scale ( surface surf,
const std::string parameters 
)
static

Definition at line 106 of file filter.cpp.

References scale_surface().

Variable Documentation

const std::string& parameters float amount
unsigned color

Definition at line 157 of file filter.cpp.

const int count = sscanf(parameters.c_str(), "%f", &amount)

Definition at line 133 of file filter.cpp.

Initial value:
{
std::vector<std::string> f = utils::split(filter, ':', utils::STRIP_SPACES)
STRIP_SPACES : strips leading and trailing blank spaces.
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glew.h:3448
std::vector< std::string > split(std::string const &val, const char c, const int flags)
Splits a (comma-)separated string into a vector of pieces.
GLclampf f
Definition: glew.h:3024

Definition at line 188 of file filter.cpp.

std::map<std::string, tfilter> filters
static

The list of the available filters.

The map contains:

  • first The name of the filter.
  • second The filter itself.

Definition at line 77 of file filter.cpp.

Referenced by game_events::t_pump::filter_event().

std::map<std::string, tfilter>::iterator itor = filters.find(f[0])

Definition at line 199 of file filter.cpp.

Referenced by scoped_xy_unit::activate(), game_data::activate_scope_variable(), halo::halo_impl::add(), network::add_bandwidth_in(), network::add_bandwidth_out(), gui2::ttree_view_node::add_child(), editor::location_palette::add_item(), halo::halo_impl::effect::add_overlay_location(), gui::textbox::add_text_line(), gui::scrollpane::add_widget(), simple_wml::node::apply_diff(), config::apply_diff(), ai::readonly_context_impl::best_defensive_position(), gui2::implementation::tbuilder_instance::build(), terrain_builder::build_terrains(), gui2::ttree_view_node::calculate_best_size(), unit_drawer::calculate_energy_bar(), config::clear_diff_track(), unit::clear_status_caches(), composer::compose(), gui2::event::thandler::disconnect(), gui2::tnotifier< tfunctor >::disconnect_notifiee(), gui2::event::tdispatcher::tsignal_queue< tsignal_function >::disconnect_signal(), ai::ai_default_rca::get_villages_phase::dispatch_complex(), ai::ai_default_rca::get_villages_phase::dispatch_unit_simple(), ai::ai_default_rca::get_villages_phase::dispatch_village_simple(), ai::ai_default_rca::aspect_attacks_base::do_attack_analysis(), gui2::tcanvas::draw(), gui2::twindow::draw(), mp::wait::leader_preview_pane::draw_contents(), ai::ai_default_rca::get_villages_phase::dump_reachmap(), gui::textbox::erase_selection(), ai::ai_default_rca::leader_shares_keep_phase::execute(), gui2::event::tdispatcher::execute_hotkey(), wb::side_actions::execute_net_cmd(), gui2::execute_timer(), unit_animation::fill_initial_animations(), gui::menu::fill_items(), unit_type_data::find(), campaignd::server::fire(), gui2::event::implementation::fire_event(), ai::ai_default_rca::get_villages_phase::full_dispatch(), cave_map_generator::cave_map_generator_job::generate_chambers(), filesystem::get_binary_paths(), gui2::get_control(), gui2::ttree_view_node::get_current_size(), font::ttext::get_cursor_position(), config::get_diff(), tod_manager::get_illuminated_time_of_day(), gui2::tminimap::get_image(), map_labels::get_label(), network_worker_pool::get_received_data(), gamemap::get_terrain(), wb::side_actions::get_turn_num_of(), gui2::ttree_view_node::get_unfolded_size(), wb::suppose_dead::get_unit(), wb::move::get_unit(), utils::string_map_variable_set::get_variable_const(), ai::ai_default_rca::get_villages_phase::get_villages(), gui2::get_window_builder(), gui::drop_target::handle_drop(), handle_preprocess_command(), t_translation::has_wildcard(), gui::scrollpane::hide(), gui2::policy::select_action::tselect::init(), wesnothd::ban_manager::init_ban_help(), display::init_flags_for_side_internal(), gui2::ttree_view_node::init_grid(), mp::chat::init_textbox(), unit::invisible(), gui2::event::tdistributor::keyboard_remove_from_chain(), gui::menu::basic_sorter::less(), utf8::lowercase(), main(), wesnothd::make_change_diff(), wesnothd::make_delete_diff(), wb::side_actions::make_net_cmd_refresh(), font::make_text_ellipsis(), game_events::event_handler::matches_name(), events::mouse_handler::move_action(), ai::ai_default_rca::move_to_targets_phase::move_group(), halo::halo_impl::effect::on_location(), sound::play_music_config(), sound::play_new_music(), wb::side_actions::raw_turn_shift(), playturn_network_adapter::read(), gui2::tgui_definition::read(), input_stream::read_line(), gui2::register_window(), simple_wml::node::remove_child(), gui2::ttree_view::remove_node(), wesnothd::room::remove_player(), gui2::remove_timer(), ai::ai_default_rca::get_villages_phase::remove_village(), gui::scrollpane::remove_widget(), hotkey::remove_wml_hotkey(), halo::halo_impl::render(), game_board::replace_map(), image::reverse_image(), terrain_builder::rotate(), wb::side_actions::safe_erase(), display::scroll_to_tiles(), font::set_font_list(), gui::scrollpane::set_inner_location(), halo::halo_impl::set_location(), gui2::ttoggle_button::set_members(), gui2::tcontrol::set_members(), wb::highlighter::set_mouseover_hex(), show_story(), game_events::t_pump::show_wml_messages(), gui2::shrink_cache(), gui2::event::tdistributor::signal_handler_notify_removal(), utils::square_parenthetical_split(), sound::stop_bell(), sound::stop_sound(), sound::stop_UI_sound(), t_translation::terrain_matches(), gui2::timer_callback(), halo::halo_impl::unrender(), gui::scrollpane::update_content_size(), mp::chat::update_textbox(), gui::scrollpane::update_widget_positions(), unit_display::wml_animation_internal(), wesnothd::ban_manager::write(), t_translation::write_game_map(), t_translation::write_list(), metrics::~metrics(), gui2::iterator::policy::order::tbottom_up< visit_widget, visit_grid, visit_child >::~tbottom_up(), gui2::iterator::policy::order::ttop_down< visit_widget, visit_grid, visit_child >::~ttop_down(), and unit::~unit().

const std::string& parameters
surf = brighten_image(surf, amount)