The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
test_sdl_utils.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2012 - 2016 by Mark de Wever <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #ifndef TESTS_TEST_SDL_UTILS_HPP_INCLUDED
16 #define TESTS_TEST_SDL_UTILS_HPP_INCLUDED
17 
18 #include "sdl/utils.hpp"
19 
20 #include "utils/functional.hpp"
21 
22 typedef std::function<
23  void(const surface&, const double, const Uint32)>
25 
26 
27 inline void
29 {
30  for(Uint32 color = 0x00FF0000; color != 0x00000000; color >>= 8) {
31  for(int i = 0xf; i < 0x100; i += 0x10) {
32  const surface dst = blend_surface(src, i / 255., color);
33  if(functor) {
34  functor(dst, i, color);
35  }
36  }
37  }
38 }
39 
40 inline std::string
41 blend_get_filename(std::string root, const Uint8 amount, const Uint32 color)
42 {
43  // The name of the file is
44  // A the amount of blended [0..256) as hex.
45  // C the color to blend with as hex.
46  char filename[] = "AA_CCCCCCCC.png";
47  snprintf(filename, sizeof(filename), "%02X_%08X.png", amount, color);
48 
49  return root + filename;
50 }
51 
52 #endif
GLvoid **typedef void(GLAPIENTRY *PFNGLGETVERTEXATTRIBDVPROC)(GLuint
Definition: glew.h:1806
void blend_image(const surface &src, tblend_functor functor)
itor second functor(surf, f[1])
GLenum src
Definition: glew.h:2392
GLenum GLenum dst
Definition: glew.h:2392
surface blend_surface(const surface &surf, const double amount, const Uint32 color, const bool optimize)
Blends a surface with a color.
Definition: utils.cpp:1840
GLuint color
Definition: glew.h:5801
const std::string &parameters float amount
Definition: filter.cpp:132
size_t i
Definition: function.cpp:1057
std::string blend_get_filename(std::string root, const Uint8 amount, const Uint32 color)
GLsizei const GLcharARB ** string
Definition: glew.h:4503
std::function< void(const surface &, const double, const Uint32)> tblend_functor