gosu 0.14.0 → 0.14.3.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gosu/Graphics.hpp +4 -1
- data/Gosu/Version.hpp +1 -1
- data/Gosu/Window.hpp +1 -1
- data/rdoc/gosu.rb +4 -2
- data/src/Audio.cpp +36 -38
- data/src/Bitmap.cpp +167 -153
- data/src/DirectoriesWin.cpp +68 -68
- data/src/Graphics.cpp +3 -2
- data/src/InputUIKit.cpp +2 -1
- data/src/MarkupParser.cpp +5 -4
- data/src/OffScreenTarget.cpp +2 -2
- data/src/OffScreenTarget.hpp +1 -1
- data/src/Resolution.cpp +3 -2
- data/src/RubyGosu.cxx +36 -6
- data/src/SndFile.hpp +8 -9
- data/src/TextBuilder.cpp +3 -3
- data/src/TrueTypeFont.cpp +6 -4
- data/src/TrueTypeFont.hpp +15 -20
- data/src/TrueTypeFontUnix.cpp +15 -7
- data/src/TrueTypeFontWin.cpp +8 -3
- data/src/Utility.cpp +2 -1
- data/src/WinMain.cpp +64 -64
- data/src/WinUtility.cpp +1 -1
- data/src/Window.cpp +8 -0
- data/src/stb_image.h +7 -4
- data/src/stb_image_write.h +34 -25
- data/src/stb_truetype.h +272 -8
- data/src/stb_vorbis.c +31 -32
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72db8840a17208ca69cb3fe332ab3acb532bba3951b38d117bfb9077f7e541c2
|
4
|
+
data.tar.gz: 3a9766f8ca34f70d833756024c1e9716db63b5efbec441f47a55bfe83ae127bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d498e4bcb3497f40a240ebd3fe1541b5ba9a000353645d80c3157b44cfa4871d257710f2815f46aabb3d01cd68bd5a7fe37d6da5b62d32ea59439dc85c11a748
|
7
|
+
data.tar.gz: 3c572470779e3814b3885c16cbeaf05de2754c53dbda66103a08431b7e1f11c25fc925dbdd95e48ed35170f3751928e0995da14e53e0e25eb822a440560a7c14
|
data/Gosu/Graphics.hpp
CHANGED
@@ -60,7 +60,10 @@ namespace Gosu
|
|
60
60
|
const std::function<void ()>& f);
|
61
61
|
|
62
62
|
//! Renders everything drawn in f onto a new Image of size (width, height).
|
63
|
-
|
63
|
+
//! \param image_flags Pass Gosu::IF_RETRO if you do not want the resulting image to use
|
64
|
+
//! interpolation when it is scaled or rotated.
|
65
|
+
static Gosu::Image render(int width, int height, const std::function<void ()>& f,
|
66
|
+
unsigned image_flags = 0);
|
64
67
|
|
65
68
|
//! Records a macro and returns it as an Image.
|
66
69
|
static Gosu::Image record(int width, int height, const std::function<void ()>& f);
|
data/Gosu/Version.hpp
CHANGED
data/Gosu/Window.hpp
CHANGED
@@ -94,7 +94,7 @@ namespace Gosu
|
|
94
94
|
|
95
95
|
//! Called before update when the user presses a button while the window has the focus.
|
96
96
|
//! By default, this will toggle fullscreen mode if the user presses Alt+Enter (Windows,
|
97
|
-
//! Linux)
|
97
|
+
//! Linux), cmd+F (macOS), or F11 (on all operating systems).
|
98
98
|
//! To support these shortcuts in your application, make sure to call Window::button_down
|
99
99
|
//! in your implementation.
|
100
100
|
virtual void button_down(Gosu::Button);
|
data/rdoc/gosu.rb
CHANGED
@@ -852,8 +852,8 @@ module Gosu
|
|
852
852
|
##
|
853
853
|
# This method is called before {#update} if a button is pressed while the window has focus.
|
854
854
|
#
|
855
|
-
# By default, this
|
856
|
-
# Linux)
|
855
|
+
# By default, this will toggle fullscreen mode if the user presses Alt+Enter (Windows,
|
856
|
+
# Linux), cmd+F (macOS), or F11 (on all operating systems).
|
857
857
|
# To support these shortcuts in your application, make sure to call super in your
|
858
858
|
# implementation.
|
859
859
|
#
|
@@ -1080,6 +1080,8 @@ module Gosu
|
|
1080
1080
|
# @return [Gosu::Image] the rendered drawing operations.
|
1081
1081
|
# @param width [Integer] the width of the recorded image.
|
1082
1082
|
# @param height [Integer] the height of the recorded image.
|
1083
|
+
# @param [Hash] options
|
1084
|
+
# @option options [true, false] :retro (false) if true, the resulting image will not be interpolated when it is scaled up or down.
|
1083
1085
|
# @yield rendering code.
|
1084
1086
|
#
|
1085
1087
|
# @see Window#record
|
data/src/Audio.cpp
CHANGED
@@ -12,11 +12,9 @@
|
|
12
12
|
#ifdef GOSU_IS_MAC
|
13
13
|
#import <Foundation/Foundation.h>
|
14
14
|
#include "AudioToolboxFile.hpp"
|
15
|
-
#define WAVE_FILE AudioToolboxFile
|
16
15
|
#else
|
17
16
|
#include "MPEGFile.hpp"
|
18
17
|
#include "SndFile.hpp"
|
19
|
-
#define WAVE_FILE SndFile
|
20
18
|
#endif
|
21
19
|
|
22
20
|
#ifdef GOSU_IS_IPHONE
|
@@ -47,7 +45,7 @@ struct Gosu::Sample::SampleData
|
|
47
45
|
{
|
48
46
|
ALuint buffer;
|
49
47
|
|
50
|
-
SampleData(AudioFile
|
48
|
+
SampleData(AudioFile&& audio_file)
|
51
49
|
{
|
52
50
|
al_initialize();
|
53
51
|
alGenBuffers(1, &buffer);
|
@@ -74,37 +72,41 @@ Gosu::Sample::Sample(const string& filename)
|
|
74
72
|
{
|
75
73
|
if (is_ogg_file(filename)) {
|
76
74
|
File file(filename);
|
77
|
-
|
78
|
-
|
75
|
+
data.reset(new SampleData(OggFile(file.front_reader())));
|
76
|
+
return;
|
79
77
|
}
|
80
|
-
|
81
|
-
|
82
|
-
|
78
|
+
|
79
|
+
#ifdef GOSU_IS_MAC
|
80
|
+
File file(filename);
|
81
|
+
data.reset(new SampleData(AudioToolboxFile(file.front_reader())));
|
82
|
+
#else
|
83
|
+
try {
|
84
|
+
data.reset(new SampleData(SndFile(filename)));
|
83
85
|
}
|
86
|
+
catch (const runtime_error& ex) {
|
87
|
+
File file(filename);
|
88
|
+
data.reset(new SampleData(MPEGFile(file.front_reader())));
|
89
|
+
}
|
90
|
+
#endif
|
84
91
|
}
|
85
92
|
|
86
93
|
Gosu::Sample::Sample(Gosu::Reader reader)
|
87
94
|
{
|
88
95
|
if (is_ogg_file(reader)) {
|
89
|
-
|
90
|
-
data.reset(new SampleData(ogg_file));
|
96
|
+
data.reset(new SampleData(OggFile(reader)));
|
91
97
|
return;
|
92
98
|
}
|
93
99
|
|
100
|
+
#ifdef GOSU_IS_MAC
|
101
|
+
data.reset(new SampleData(AudioToolboxFile(reader)));
|
102
|
+
#else
|
94
103
|
try {
|
95
|
-
|
96
|
-
data.reset(new SampleData(audio_file));
|
104
|
+
data.reset(new SampleData(SndFile(reader)));
|
97
105
|
}
|
98
106
|
catch (const runtime_error& ex) {
|
99
|
-
|
100
|
-
if (string(ex.what()).find("unknown format") != string::npos) {
|
101
|
-
MPEGFile mpeg_file(reader);
|
102
|
-
data.reset(new SampleData(mpeg_file));
|
103
|
-
return;
|
104
|
-
}
|
105
|
-
#endif
|
106
|
-
throw ex;
|
107
|
+
data.reset(new SampleData(MPEGFile(reader)));
|
107
108
|
}
|
109
|
+
#endif
|
108
110
|
}
|
109
111
|
|
110
112
|
Gosu::Channel Gosu::Sample::play(double volume, double speed, bool looping) const
|
@@ -252,19 +254,17 @@ public:
|
|
252
254
|
file.reset(new OggFile(source_file.front_reader()));
|
253
255
|
}
|
254
256
|
else {
|
257
|
+
#ifdef GOSU_IS_MAC
|
258
|
+
file.reset(new AudioToolboxFile(filename));
|
259
|
+
#else
|
255
260
|
try {
|
256
|
-
file.reset(new
|
261
|
+
file.reset(new SndFile(filename));
|
257
262
|
}
|
258
263
|
catch (const runtime_error& ex) {
|
259
|
-
|
260
|
-
|
261
|
-
File source_file(filename);
|
262
|
-
file.reset(new MPEGFile(source_file.front_reader()));
|
263
|
-
}
|
264
|
-
else
|
265
|
-
#endif
|
266
|
-
throw ex;
|
264
|
+
File source_file(filename);
|
265
|
+
file.reset(new MPEGFile(source_file.front_reader()));
|
267
266
|
}
|
267
|
+
#endif
|
268
268
|
}
|
269
269
|
|
270
270
|
al_initialize();
|
@@ -277,18 +277,16 @@ public:
|
|
277
277
|
file.reset(new OggFile(reader));
|
278
278
|
}
|
279
279
|
else {
|
280
|
+
#ifdef GOSU_IS_MAC
|
281
|
+
file.reset(new AudioToolboxFile(reader));
|
282
|
+
#else
|
280
283
|
try {
|
281
|
-
file.reset(new
|
284
|
+
file.reset(new SndFile(reader));
|
282
285
|
}
|
283
286
|
catch (const runtime_error& ex) {
|
284
|
-
|
285
|
-
if (string(ex.what()).find("unknown format") != string::npos) {
|
286
|
-
file.reset(new MPEGFile(reader));
|
287
|
-
}
|
288
|
-
else
|
289
|
-
#endif
|
290
|
-
throw ex;
|
287
|
+
file.reset(new MPEGFile(reader));
|
291
288
|
}
|
289
|
+
#endif
|
292
290
|
}
|
293
291
|
|
294
292
|
al_initialize();
|
@@ -401,8 +399,8 @@ Gosu::Song::Song(const string& filename)
|
|
401
399
|
has_extension(filename, ".aac") ||
|
402
400
|
has_extension(filename, ".m4a")) {
|
403
401
|
data.reset(new ModuleData(filename));
|
402
|
+
return;
|
404
403
|
}
|
405
|
-
else
|
406
404
|
#endif
|
407
405
|
data.reset(new StreamData(filename));
|
408
406
|
}
|
data/src/Bitmap.cpp
CHANGED
@@ -1,24 +1,24 @@
|
|
1
|
-
#include <Gosu/Bitmap.hpp>
|
2
|
-
#include <cassert>
|
3
|
-
#include <algorithm>
|
1
|
+
#include <Gosu/Bitmap.hpp>
|
2
|
+
#include <cassert>
|
3
|
+
#include <algorithm>
|
4
4
|
#include <vector>
|
5
|
-
using namespace std;
|
6
|
-
|
7
|
-
void Gosu::Bitmap::swap(Bitmap& other)
|
8
|
-
{
|
9
|
-
std::swap(pixels, other.pixels);
|
10
|
-
std::swap(w, other.w);
|
11
|
-
std::swap(h, other.h);
|
12
|
-
}
|
13
|
-
|
14
|
-
void Gosu::Bitmap::resize(unsigned width, unsigned height, Color c)
|
15
|
-
{
|
16
|
-
if (width == w && height == h) return;
|
17
|
-
|
18
|
-
Bitmap temp(width, height, c);
|
19
|
-
temp.insert(*this, 0, 0);
|
20
|
-
swap(temp);
|
21
|
-
}
|
5
|
+
using namespace std;
|
6
|
+
|
7
|
+
void Gosu::Bitmap::swap(Bitmap& other)
|
8
|
+
{
|
9
|
+
std::swap(pixels, other.pixels);
|
10
|
+
std::swap(w, other.w);
|
11
|
+
std::swap(h, other.h);
|
12
|
+
}
|
13
|
+
|
14
|
+
void Gosu::Bitmap::resize(unsigned width, unsigned height, Color c)
|
15
|
+
{
|
16
|
+
if (width == w && height == h) return;
|
17
|
+
|
18
|
+
Bitmap temp(width, height, c);
|
19
|
+
temp.insert(*this, 0, 0);
|
20
|
+
swap(temp);
|
21
|
+
}
|
22
22
|
|
23
23
|
void Gosu::Bitmap::blend_pixel(unsigned x, unsigned y, Color c)
|
24
24
|
{
|
@@ -39,146 +39,160 @@ void Gosu::Bitmap::blend_pixel(unsigned x, unsigned y, Color c)
|
|
39
39
|
|
40
40
|
set_pixel(x, y, out);
|
41
41
|
}
|
42
|
-
|
43
|
-
void Gosu::Bitmap::insert(const Bitmap& source, int x, int y)
|
44
|
-
{
|
45
|
-
insert(source, x, y, 0, 0, source.width(), source.height());
|
46
|
-
}
|
47
|
-
|
48
|
-
void Gosu::Bitmap::insert(const Bitmap& source, int x, int y, unsigned src_x, unsigned src_y,
|
49
|
-
unsigned src_width, unsigned src_height)
|
50
|
-
{
|
51
|
-
// TODO: This should use memcpy if possible (x == 0 && src_width == this->width())
|
52
|
-
|
53
|
-
if (x < 0) {
|
54
|
-
unsigned clip_left = -x;
|
55
|
-
|
56
|
-
if (clip_left >= src_width) return;
|
57
|
-
|
58
|
-
src_x += clip_left;
|
59
|
-
src_width -= clip_left;
|
60
|
-
x = 0;
|
61
|
-
}
|
62
|
-
|
63
|
-
if (y < 0) {
|
64
|
-
unsigned clip_top = -y;
|
65
|
-
|
66
|
-
if (clip_top >= src_height) return;
|
67
|
-
|
68
|
-
src_y += clip_top;
|
69
|
-
src_height -= clip_top;
|
70
|
-
y = 0;
|
71
|
-
}
|
72
|
-
|
73
|
-
if (x + src_width > w) {
|
74
|
-
if (static_cast<unsigned>(x) >= w) return;
|
75
|
-
|
76
|
-
src_width = w - x;
|
77
|
-
}
|
78
|
-
|
79
|
-
if (y + src_height > h) {
|
80
|
-
if (static_cast<unsigned>(y) >= h) return;
|
81
|
-
|
82
|
-
src_height = h - y;
|
83
|
-
}
|
84
|
-
|
85
|
-
for (unsigned rel_y = 0; rel_y < src_height; ++rel_y) {
|
86
|
-
for (unsigned rel_x = 0; rel_x < src_width; ++rel_x) {
|
42
|
+
|
43
|
+
void Gosu::Bitmap::insert(const Bitmap& source, int x, int y)
|
44
|
+
{
|
45
|
+
insert(source, x, y, 0, 0, source.width(), source.height());
|
46
|
+
}
|
47
|
+
|
48
|
+
void Gosu::Bitmap::insert(const Bitmap& source, int x, int y, unsigned src_x, unsigned src_y,
|
49
|
+
unsigned src_width, unsigned src_height)
|
50
|
+
{
|
51
|
+
// TODO: This should use memcpy if possible (x == 0 && src_width == this->width())
|
52
|
+
|
53
|
+
if (x < 0) {
|
54
|
+
unsigned clip_left = -x;
|
55
|
+
|
56
|
+
if (clip_left >= src_width) return;
|
57
|
+
|
58
|
+
src_x += clip_left;
|
59
|
+
src_width -= clip_left;
|
60
|
+
x = 0;
|
61
|
+
}
|
62
|
+
|
63
|
+
if (y < 0) {
|
64
|
+
unsigned clip_top = -y;
|
65
|
+
|
66
|
+
if (clip_top >= src_height) return;
|
67
|
+
|
68
|
+
src_y += clip_top;
|
69
|
+
src_height -= clip_top;
|
70
|
+
y = 0;
|
71
|
+
}
|
72
|
+
|
73
|
+
if (x + src_width > w) {
|
74
|
+
if (static_cast<unsigned>(x) >= w) return;
|
75
|
+
|
76
|
+
src_width = w - x;
|
77
|
+
}
|
78
|
+
|
79
|
+
if (y + src_height > h) {
|
80
|
+
if (static_cast<unsigned>(y) >= h) return;
|
81
|
+
|
82
|
+
src_height = h - y;
|
83
|
+
}
|
84
|
+
|
85
|
+
for (unsigned rel_y = 0; rel_y < src_height; ++rel_y) {
|
86
|
+
for (unsigned rel_x = 0; rel_x < src_width; ++rel_x) {
|
87
87
|
set_pixel(x + rel_x, y + rel_y, source.get_pixel(src_x + rel_x, src_y + rel_y));
|
88
88
|
}
|
89
|
-
}
|
90
|
-
}
|
91
|
-
|
92
|
-
void Gosu::apply_color_key(Bitmap& bitmap, Color key)
|
93
|
-
{
|
94
|
-
vector<Color> surrounding_colors;
|
95
|
-
surrounding_colors.reserve(4);
|
96
|
-
|
97
|
-
for (unsigned y = 0; y < bitmap.height(); ++y)
|
98
|
-
for (unsigned x = 0; x < bitmap.width(); ++x)
|
99
|
-
if (bitmap.get_pixel(x, y) == key) {
|
100
|
-
surrounding_colors.clear();
|
101
|
-
if (x > 0 && bitmap.get_pixel(x - 1, y) != key)
|
102
|
-
surrounding_colors.push_back(bitmap.get_pixel(x - 1, y));
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
if (y
|
108
|
-
surrounding_colors.push_back(bitmap.get_pixel(x, y
|
109
|
-
|
110
|
-
if (
|
111
|
-
bitmap.
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
89
|
+
}
|
90
|
+
}
|
91
|
+
|
92
|
+
void Gosu::apply_color_key(Bitmap& bitmap, Color key)
|
93
|
+
{
|
94
|
+
vector<Color> surrounding_colors;
|
95
|
+
surrounding_colors.reserve(4);
|
96
|
+
|
97
|
+
for (unsigned y = 0; y < bitmap.height(); ++y) {
|
98
|
+
for (unsigned x = 0; x < bitmap.width(); ++x) {
|
99
|
+
if (bitmap.get_pixel(x, y) == key) {
|
100
|
+
surrounding_colors.clear();
|
101
|
+
if (x > 0 && bitmap.get_pixel(x - 1, y) != key) {
|
102
|
+
surrounding_colors.push_back(bitmap.get_pixel(x - 1, y));
|
103
|
+
}
|
104
|
+
if (x < bitmap.width() - 1 && bitmap.get_pixel(x + 1, y) != key) {
|
105
|
+
surrounding_colors.push_back(bitmap.get_pixel(x + 1, y));
|
106
|
+
}
|
107
|
+
if (y > 0 && bitmap.get_pixel(x, y - 1) != key) {
|
108
|
+
surrounding_colors.push_back(bitmap.get_pixel(x, y - 1));
|
109
|
+
}
|
110
|
+
if (y < bitmap.height() - 1 && bitmap.get_pixel(x, y + 1) != key) {
|
111
|
+
surrounding_colors.push_back(bitmap.get_pixel(x, y + 1));
|
112
|
+
}
|
113
|
+
|
114
|
+
if (surrounding_colors.empty()) {
|
115
|
+
bitmap.set_pixel(x, y, Color::NONE);
|
116
|
+
continue;
|
117
|
+
}
|
118
|
+
|
119
|
+
unsigned red = 0, green = 0, blue = 0;
|
120
|
+
for (auto& color : surrounding_colors) {
|
121
|
+
red += color.red();
|
122
|
+
green += color.green();
|
123
|
+
blue += color.blue();
|
124
|
+
}
|
121
125
|
bitmap.set_pixel(x, y, Color(0,
|
122
|
-
red / surrounding_colors.size(),
|
126
|
+
red / surrounding_colors.size(),
|
123
127
|
green / surrounding_colors.size(),
|
124
|
-
blue / surrounding_colors.size()));
|
125
|
-
}
|
126
|
-
}
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
128
|
+
blue / surrounding_colors.size()));
|
129
|
+
}
|
130
|
+
}
|
131
|
+
}
|
132
|
+
}
|
133
|
+
|
134
|
+
void Gosu::unapply_color_key(Bitmap& bitmap, Color color)
|
135
|
+
{
|
136
|
+
Color* p = bitmap.data();
|
137
|
+
for (int i = bitmap.width() * bitmap.height(); i > 0; --i, ++p) {
|
138
|
+
if (p->alpha() == 0) {
|
133
139
|
*p = color;
|
134
|
-
}
|
135
|
-
else {
|
140
|
+
}
|
141
|
+
else {
|
136
142
|
p->set_alpha(255);
|
137
143
|
}
|
138
|
-
}
|
139
|
-
}
|
140
|
-
|
141
|
-
void Gosu::apply_border_flags(Bitmap& dest, const Bitmap& source, unsigned src_x, unsigned src_y,
|
142
|
-
unsigned src_width, unsigned src_height, unsigned image_flags)
|
143
|
-
{
|
144
|
-
// Backward compatibility: This used to be 'bool tileable'.
|
145
|
-
if (image_flags == 1) image_flags = IF_TILEABLE;
|
146
|
-
|
147
|
-
dest.resize(src_width + 2, src_height + 2);
|
148
|
-
|
149
|
-
// The borders are made "harder" by duplicating the original bitmap's
|
150
|
-
// borders.
|
151
|
-
|
152
|
-
// Top.
|
153
|
-
if (image_flags & IF_TILEABLE_TOP)
|
154
|
-
dest.insert(source, 1, 0, src_x, src_y, src_width, 1);
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
144
|
+
}
|
145
|
+
}
|
146
|
+
|
147
|
+
void Gosu::apply_border_flags(Bitmap& dest, const Bitmap& source, unsigned src_x, unsigned src_y,
|
148
|
+
unsigned src_width, unsigned src_height, unsigned image_flags)
|
149
|
+
{
|
150
|
+
// Backward compatibility: This used to be 'bool tileable'.
|
151
|
+
if (image_flags == 1) image_flags = IF_TILEABLE;
|
152
|
+
|
153
|
+
dest.resize(src_width + 2, src_height + 2);
|
154
|
+
|
155
|
+
// The borders are made "harder" by duplicating the original bitmap's
|
156
|
+
// borders.
|
157
|
+
|
158
|
+
// Top.
|
159
|
+
if (image_flags & IF_TILEABLE_TOP) {
|
160
|
+
dest.insert(source, 1, 0, src_x, src_y, src_width, 1);
|
161
|
+
}
|
162
|
+
// Bottom.
|
163
|
+
if (image_flags & IF_TILEABLE_BOTTOM) {
|
164
|
+
dest.insert(source, 1, dest.height() - 1, src_x, src_y + src_height - 1, src_width, 1);
|
165
|
+
}
|
166
|
+
// Left.
|
167
|
+
if (image_flags & IF_TILEABLE_LEFT) {
|
168
|
+
dest.insert(source, 0, 1, src_x, src_y, 1, src_height);
|
169
|
+
}
|
170
|
+
// Right.
|
171
|
+
if (image_flags & IF_TILEABLE_RIGHT) {
|
172
|
+
dest.insert(source, dest.width() - 1, 1, src_x + src_width - 1, src_y, 1, src_height);
|
173
|
+
}
|
174
|
+
|
175
|
+
// Top left.
|
176
|
+
if ((image_flags & IF_TILEABLE_TOP) && (image_flags & IF_TILEABLE_LEFT)) {
|
167
177
|
dest.set_pixel(0, 0,
|
168
|
-
source.get_pixel(src_x, src_y));
|
169
|
-
|
170
|
-
|
178
|
+
source.get_pixel(src_x, src_y));
|
179
|
+
}
|
180
|
+
// Top right.
|
181
|
+
if ((image_flags & IF_TILEABLE_TOP) && (image_flags & IF_TILEABLE_RIGHT)) {
|
171
182
|
dest.set_pixel(dest.width() - 1, 0,
|
172
|
-
source.get_pixel(src_x + src_width - 1, src_y));
|
173
|
-
|
174
|
-
|
183
|
+
source.get_pixel(src_x + src_width - 1, src_y));
|
184
|
+
}
|
185
|
+
// Bottom left.
|
186
|
+
if ((image_flags & IF_TILEABLE_BOTTOM) && (image_flags & IF_TILEABLE_LEFT)) {
|
175
187
|
dest.set_pixel(0, dest.height() - 1,
|
176
|
-
source.get_pixel(src_x, src_y + src_height - 1));
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
188
|
+
source.get_pixel(src_x, src_y + src_height - 1));
|
189
|
+
}
|
190
|
+
// Bottom right.
|
191
|
+
if ((image_flags & IF_TILEABLE_BOTTOM) && (image_flags & IF_TILEABLE_RIGHT)) {
|
192
|
+
dest.set_pixel(dest.width() - 1, dest.height() - 1,
|
193
|
+
source.get_pixel(src_x + src_width - 1, src_y + src_height - 1));
|
194
|
+
}
|
195
|
+
|
196
|
+
// Now put the final image into the prepared borders.
|
197
|
+
dest.insert(source, 1, 1, src_x, src_y, src_width, src_height);
|
198
|
+
}
|