gosu 0.7.33 → 0.7.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. data/Gosu/Async.hpp +10 -8
  2. data/Gosu/Audio.hpp +6 -4
  3. data/Gosu/AutoLink.hpp +0 -0
  4. data/Gosu/Bitmap.hpp +4 -5
  5. data/Gosu/ButtonsX.hpp +1 -1
  6. data/Gosu/Color.hpp +8 -8
  7. data/Gosu/Font.hpp +2 -2
  8. data/Gosu/Graphics.hpp +4 -6
  9. data/Gosu/IO.hpp +11 -4
  10. data/Gosu/Image.hpp +9 -7
  11. data/Gosu/ImageData.hpp +10 -4
  12. data/Gosu/Input.hpp +4 -5
  13. data/Gosu/Sockets.hpp +10 -12
  14. data/Gosu/TR1.hpp +44 -0
  15. data/Gosu/TextInput.hpp +2 -2
  16. data/Gosu/Version.hpp +2 -2
  17. data/Gosu/WinUtility.hpp +5 -6
  18. data/Gosu/Window.hpp +5 -6
  19. data/GosuImpl/Async.cpp +4 -3
  20. data/GosuImpl/Audio/ALChannelManagement.hpp +23 -11
  21. data/GosuImpl/Audio/AudioFile.hpp +11 -3
  22. data/GosuImpl/Audio/AudioOpenAL.cpp +613 -0
  23. data/GosuImpl/Audio/AudioOpenAL.mm +1 -605
  24. data/GosuImpl/Audio/AudioSDL.cpp +12 -14
  25. data/GosuImpl/Audio/AudioToolboxFile.hpp +0 -1
  26. data/GosuImpl/Audio/OggFile.hpp +2 -0
  27. data/GosuImpl/Audio/SndFile.hpp +158 -0
  28. data/GosuImpl/DirectoriesWin.cpp +18 -18
  29. data/GosuImpl/Graphics/BitmapApple.mm +17 -19
  30. data/GosuImpl/Graphics/BitmapBMP.cpp +7 -2
  31. data/GosuImpl/Graphics/BitmapFreeImage.cpp +11 -12
  32. data/GosuImpl/Graphics/BitmapGDIplus.cpp +35 -31
  33. data/GosuImpl/Graphics/BitmapUtils.cpp +1 -1
  34. data/GosuImpl/Graphics/BlockAllocator.cpp +7 -8
  35. data/GosuImpl/Graphics/BlockAllocator.hpp +3 -4
  36. data/GosuImpl/Graphics/Common.hpp +3 -2
  37. data/GosuImpl/Graphics/DrawOp.hpp +2 -3
  38. data/GosuImpl/Graphics/DrawOpQueue.hpp +28 -20
  39. data/GosuImpl/Graphics/Font.cpp +13 -13
  40. data/GosuImpl/Graphics/FormattedString.hpp +93 -86
  41. data/GosuImpl/Graphics/Graphics.cpp +16 -14
  42. data/GosuImpl/Graphics/Image.cpp +7 -3
  43. data/GosuImpl/Graphics/LargeImageData.hpp +4 -5
  44. data/GosuImpl/Graphics/Macro.hpp +11 -11
  45. data/GosuImpl/Graphics/RenderState.hpp +5 -4
  46. data/GosuImpl/Graphics/TexChunk.cpp +3 -3
  47. data/GosuImpl/Graphics/TexChunk.hpp +4 -4
  48. data/GosuImpl/Graphics/Text.cpp +29 -30
  49. data/GosuImpl/Graphics/TextMac.cpp +9 -7
  50. data/GosuImpl/Graphics/TextTTFWin.cpp +3 -1
  51. data/GosuImpl/Graphics/TextTouch.mm +0 -1
  52. data/GosuImpl/Graphics/TextUnix.cpp +12 -4
  53. data/GosuImpl/Graphics/TextWin.cpp +4 -2
  54. data/GosuImpl/Graphics/Texture.cpp +7 -6
  55. data/GosuImpl/Graphics/Texture.hpp +3 -4
  56. data/GosuImpl/InputMac.mm +12 -15
  57. data/GosuImpl/InputTouch.mm +3 -3
  58. data/GosuImpl/InputWin.cpp +149 -159
  59. data/GosuImpl/InputX.cpp +0 -0
  60. data/GosuImpl/MacUtility.hpp +9 -4
  61. data/GosuImpl/RubyGosu.swg +38 -43
  62. data/GosuImpl/RubyGosu_wrap.cxx +89 -96
  63. data/GosuImpl/Sockets/CommSocket.cpp +5 -5
  64. data/GosuImpl/Sockets/Sockets.hpp +4 -4
  65. data/GosuImpl/TimingApple.cpp +2 -3
  66. data/GosuImpl/Utility.cpp +18 -0
  67. data/GosuImpl/WinMain.cpp +0 -1
  68. data/GosuImpl/WinUtility.cpp +2 -2
  69. data/GosuImpl/WindowMac.mm +20 -17
  70. data/GosuImpl/WindowTouch.mm +8 -7
  71. data/GosuImpl/WindowWin.cpp +12 -7
  72. data/GosuImpl/WindowX.cpp +67 -18
  73. data/lib/gosu.rb +14 -12
  74. data/linux/extconf.rb +11 -6
  75. metadata +8 -7
  76. data/GosuImpl/Audio/AudioAudiere.cpp +0 -448
  77. data/GosuImpl/RubyGosu_DllMain.cxx +0 -31
@@ -3,13 +3,13 @@
3
3
 
4
4
  #include <Gosu/Color.hpp>
5
5
  #include <Gosu/Utility.hpp>
6
- #include <boost/cstdint.hpp>
7
- #include <boost/foreach.hpp>
8
- #include <boost/variant.hpp>
6
+ #include <Gosu/TR1.hpp>
7
+ #include <cassert>
8
+ #include <cwchar>
9
+ #include <cwctype>
9
10
  #include <stdexcept>
10
11
  #include <utility>
11
12
  #include <vector>
12
- #include <cwchar>
13
13
 
14
14
  namespace Gosu
15
15
  {
@@ -28,10 +28,11 @@ namespace Gosu
28
28
  }
29
29
  };
30
30
 
31
- typedef std::pair<std::wstring, unsigned> SimpleImpl;
32
- typedef std::vector<FormattedChar> FancyImpl;
33
-
34
- boost::variant<SimpleImpl, FancyImpl> impl;
31
+ // If characters.empty(), use these for the whole string.
32
+ std::wstring simpleString;
33
+ unsigned simpleFlags;
34
+ // If not characters.empty(), ignore above fields and use this.
35
+ std::vector<FormattedChar> characters;
35
36
 
36
37
  static unsigned flags(int b, int u, int i)
37
38
  {
@@ -47,210 +48,217 @@ namespace Gosu
47
48
  {
48
49
  }
49
50
 
50
- explicit FormattedString(const std::wstring& html, unsigned baseFlags)
51
+ explicit FormattedString(const wchar_t* html, unsigned baseFlags)
51
52
  {
52
- if (html.find_first_of(L"<&") == std::wstring::npos)
53
+ // Remove \r characters if existent. Avoid a copy if we don't need one.
54
+ std::wstring unixified;
55
+ if (std::wcschr(html, L'\r')) {
56
+ unixified.resize(std::wcslen(html));
57
+ unsigned pos = 0;
58
+ while (*html)
59
+ {
60
+ if (*html != '\r')
61
+ unixified[pos++] = *html;
62
+ ++html;
63
+ }
64
+ unixified.resize(pos);
65
+ html = unixified.c_str();
66
+ }
67
+
68
+ std::size_t len = std::wcslen(html);
69
+
70
+ // Just skip all this if there are entities or formatting tags in the string.
71
+ if (std::wcscspn(html, L"<&") == len)
53
72
  {
54
- impl = SimpleImpl(html, baseFlags);
73
+ simpleString = html;
74
+ simpleFlags = baseFlags;
55
75
  return;
56
76
  }
57
77
 
58
- FancyImpl chars;
59
-
60
78
  unsigned pos = 0;
61
79
  int b = (baseFlags & ffBold) ? 1 : 0,
62
80
  u = (baseFlags & ffUnderline) ? 1 : 0,
63
81
  i = (baseFlags & ffItalic) ? 1 : 0;
64
82
  std::vector<Gosu::Color> c;
65
83
  c.push_back(0xffffffff);
66
- while (pos < html.length())
84
+ while (pos < len)
67
85
  {
68
- // TODO: range checking for the color ops so .at() doesn't crash valid strings
69
-
70
- if (html.substr(pos, 3) == L"<b>")
86
+ if (!std::wcsncmp(html + pos, L"<b>", 3))
71
87
  {
72
88
  b += 1;
73
89
  pos += 3;
74
90
  continue;
75
91
  }
76
- if (html.substr(pos, 4) == L"</b>")
92
+ if (!std::wcsncmp(html + pos, L"</b>", 4))
77
93
  {
78
94
  b -= 1;
79
95
  pos += 4;
80
96
  continue;
81
97
  }
82
- if (html.substr(pos, 3) == L"<u>")
98
+ if (!std::wcsncmp(html + pos, L"<u>", 3))
83
99
  {
84
100
  u += 1;
85
101
  pos += 3;
86
102
  continue;
87
103
  }
88
- if (html.substr(pos, 4) == L"</u>")
104
+ if (!std::wcsncmp(html + pos, L"</u>", 4))
89
105
  {
90
106
  u -= 1;
91
107
  pos += 4;
92
108
  continue;
93
109
  }
94
- if (html.substr(pos, 3) == L"<i>")
110
+ if (!std::wcsncmp(html + pos, L"<i>", 3))
95
111
  {
96
112
  i += 1;
97
113
  pos += 3;
98
114
  continue;
99
115
  }
100
- if (html.substr(pos, 4) == L"</i>")
116
+ if (!std::wcsncmp(html + pos, L"</i>", 4))
101
117
  {
102
118
  i -= 1;
103
119
  pos += 4;
104
120
  continue;
105
121
  }
106
- if (html.length() >= pos + 10 &&
107
- html.substr(pos, 3) == L"<c=" &&
108
- html.at(pos + 9) == L'>')
122
+ if (!std::wcsncmp(html + pos, L"<c=", 3) &&
123
+ len >= pos + 10 && html[pos + 9] == L'>')
109
124
  {
110
125
  using namespace std;
111
- boost::uint32_t rgb =
112
- std::wcstoul(html.c_str() + pos + 3, 0, 16);
126
+ unsigned rgb = wcstoul(html + pos + 3, 0, 16);
113
127
  c.push_back(0xff000000 | rgb);
114
128
  pos += 10;
115
129
  continue;
116
130
  }
117
- if (html.length() >= pos + 12 &&
118
- html.substr(pos, 3) == L"<c=" &&
119
- html.at(pos + 11) == L'>')
131
+ if (!std::wcsncmp(html + pos, L"<c=", 3) &&
132
+ len >= pos + 12 && html[pos + 11] == L'>')
120
133
  {
121
134
  using namespace std;
122
- boost::uint32_t argb =
123
- std::wcstoul(html.c_str() + pos + 3, 0, 16);
135
+ unsigned argb = wcstoul(html + pos + 3, 0, 16);
124
136
  c.push_back(argb);
125
137
  pos += 12;
126
138
  continue;
127
139
  }
128
- if (html.substr(pos, 4) == L"</c>")
140
+ if (!std::wcsncmp(html + pos, L"</c>", 4))
129
141
  {
130
- c.pop_back();
142
+ if (c.size() > 1)
143
+ c.pop_back();
131
144
  pos += 4;
132
145
  continue;
133
146
  }
134
- if (html.substr(pos, 4) == L"&lt;")
147
+ if (!std::wcsncmp(html + pos, L"&lt;", 4))
135
148
  {
136
149
  FormattedChar fc = { L'<', c.back(), flags(b,u,i) };
137
- chars.push_back(fc);
150
+ characters.push_back(fc);
138
151
  pos += 4;
139
152
  continue;
140
153
  }
141
- if (html.substr(pos, 4) == L"&gt;")
154
+ if (!std::wcsncmp(html + pos, L"&gt;", 4))
142
155
  {
143
156
  FormattedChar fc = { L'>', c.back(), flags(b,u,i) };
144
- chars.push_back(fc);
157
+ characters.push_back(fc);
145
158
  pos += 4;
146
159
  continue;
147
160
  }
148
- if (html.substr(pos, 5) == L"&amp;")
161
+ if (!std::wcsncmp(html + pos, L"&amp;", 5))
149
162
  {
150
163
  FormattedChar fc = { L'&', c.back(), flags(b,u,i) };
151
- chars.push_back(fc);
164
+ characters.push_back(fc);
152
165
  pos += 5;
153
166
  continue;
154
167
  }
155
- if (html[pos] == L'&' && pos < html.length() - 1)
168
+ if (html[pos] == L'&' && html[pos + 1])
156
169
  {
157
170
  int endOfEntity = pos + 1;
158
171
  while (html[endOfEntity] != L';')
159
172
  {
160
- using namespace std; // never know where the wchar_t stuff is ...
173
+ // Never know where the wchar_t stuff is...what a mess!
174
+ using namespace std;
175
+ using namespace std::tr1;
161
176
  if (!iswalnum(static_cast<wint_t>(html[endOfEntity])))
162
177
  goto normalCharacter;
163
178
  endOfEntity += 1;
164
- if (endOfEntity >= html.size())
179
+ if (endOfEntity >= len)
165
180
  goto normalCharacter;
166
181
  }
167
- FormattedChar fc = { 0, c.back(), 0, std::wstring(html.begin() + pos + 1, html.begin() + endOfEntity) };
182
+ FormattedChar fc = { 0, c.back(), 0, std::wstring(html + pos + 1, html + endOfEntity) };
168
183
  if (!isEntity(fc.entity))
169
184
  goto normalCharacter;
170
- chars.push_back(fc);
185
+ characters.push_back(fc);
171
186
  pos = endOfEntity + 1;
172
187
  continue;
173
188
  }
174
189
 
175
190
  normalCharacter:
176
191
  FormattedChar fc = { html[pos], c.back(), flags(b,u,i) };
177
- chars.push_back(fc);
192
+ characters.push_back(fc);
178
193
  pos += 1;
179
194
  }
180
-
181
- impl = chars;
182
195
  }
183
196
 
184
197
  std::wstring unformat() const
185
198
  {
186
- if (const SimpleImpl* simpl = boost::get<SimpleImpl>(&impl))
187
- return simpl->first;
199
+ if (characters.empty())
200
+ return simpleString;
188
201
 
189
- const FancyImpl& chars = boost::get<FancyImpl>(impl);
190
- std::wstring result(length(), L' ');
191
- for (int i = 0; i < chars.size(); ++i)
192
- result[i] = chars[i].wc;
202
+ std::wstring result(characters.size(), 0);
203
+ for (int i = 0; i < characters.size(); ++i)
204
+ result[i] = characters[i].wc;
193
205
  return result;
194
206
  }
195
207
 
196
208
  const wchar_t* entityAt(unsigned index) const
197
209
  {
198
- if (impl.which() == 0)
210
+ if (characters.empty())
199
211
  return 0;
200
212
 
201
- const FancyImpl& chars = boost::get<FancyImpl>(impl);
202
- if (chars[index].wc != 0 || chars[index].entity.empty())
213
+ assert (index <= characters.size());
214
+
215
+ if (characters[index].wc != 0 || characters[index].entity.empty())
203
216
  return 0;
204
- return chars[index].entity.c_str();
217
+ return characters[index].entity.c_str();
205
218
  }
206
219
 
207
220
  wchar_t charAt(unsigned index) const
208
221
  {
209
- if (const SimpleImpl* simpl = boost::get<SimpleImpl>(&impl))
210
- return simpl->first[index];
211
-
212
- const FancyImpl& chars = boost::get<FancyImpl>(impl);
213
- return chars[index].wc;
222
+ if (characters.empty())
223
+ return simpleString[index];
224
+ else
225
+ return characters[index].wc;
214
226
  }
215
227
 
216
228
  unsigned flagsAt(unsigned index) const
217
229
  {
218
- if (const SimpleImpl* simpl = boost::get<SimpleImpl>(&impl))
219
- return simpl->second;
220
-
221
- const FancyImpl& chars = boost::get<FancyImpl>(impl);
222
- return chars[index].flags;
230
+ if (characters.empty())
231
+ return simpleFlags;
232
+ else
233
+ return characters[index].flags;
223
234
  }
224
235
 
225
236
  Gosu::Color colorAt(unsigned index) const
226
237
  {
227
- if (impl.which() == 0)
238
+ if (characters.empty())
228
239
  return Color::WHITE;
229
-
230
- const FancyImpl& chars = boost::get<FancyImpl>(impl);
231
- return chars[index].color;
240
+ else
241
+ return characters[index].color;
232
242
  }
233
243
 
234
244
  unsigned length() const
235
245
  {
236
- if (const SimpleImpl* simpl = boost::get<SimpleImpl>(&impl))
237
- return simpl->first.size();
238
-
239
- const FancyImpl& chars = boost::get<FancyImpl>(impl);
240
- return chars.size();
246
+ if (unsigned len = characters.size())
247
+ return len;
248
+ else
249
+ return simpleString.length();
241
250
  }
242
251
 
243
252
  FormattedString range(unsigned begin, unsigned end) const
244
253
  {
245
254
  FormattedString result;
246
-
247
- if (const SimpleImpl* simpl = boost::get<SimpleImpl>(&impl))
248
- result.impl = SimpleImpl(std::wstring(simpl->first.begin() + begin, simpl->first.begin() + end), simpl->second);
249
- else
255
+ if (characters.empty())
250
256
  {
251
- const FancyImpl& chars = boost::get<FancyImpl>(impl);
252
- result.impl = FancyImpl(chars.begin() + begin, chars.begin() + end);
257
+ result.simpleString.assign(simpleString.begin() + begin, simpleString.begin() + end);
258
+ result.simpleFlags = simpleFlags;
253
259
  }
260
+ else
261
+ result.characters.assign(characters.begin() + begin, characters.begin() + end);
254
262
  return result;
255
263
  }
256
264
 
@@ -270,14 +278,13 @@ namespace Gosu
270
278
 
271
279
  std::vector<FormattedString> splitParts() const
272
280
  {
273
- if (impl.which() == 0)
281
+ if (characters.empty())
274
282
  return std::vector<FormattedString>(1, *this);
275
283
 
276
- const FancyImpl& chars = boost::get<FancyImpl>(impl);
277
284
  std::vector<FormattedString> result;
278
285
  unsigned begin = 0;
279
286
  for (unsigned cur = 1; cur < length(); ++cur)
280
- if (!chars[begin].sameStyleAs(chars[cur]))
287
+ if (!characters[begin].sameStyleAs(characters[cur]))
281
288
  {
282
289
  result.push_back(range(begin, cur));
283
290
  begin = cur;
@@ -8,9 +8,8 @@
8
8
  #include <Gosu/Bitmap.hpp>
9
9
  #include <Gosu/Image.hpp>
10
10
  #include <Gosu/Platform.hpp>
11
- #include <boost/foreach.hpp>
12
11
  #if 0
13
- #include <boost/thread.hpp>
12
+ #include <thread>
14
13
  #endif
15
14
  #include <cmath>
16
15
  #include <algorithm>
@@ -27,13 +26,13 @@ struct Gosu::Graphics::Impl
27
26
  unsigned physWidth, physHeight;
28
27
  bool fullscreen;
29
28
  DrawOpQueueStack queues;
30
- typedef std::vector<boost::shared_ptr<Texture> > Textures;
29
+ typedef std::vector<std::tr1::shared_ptr<Texture> > Textures;
31
30
  Textures textures;
32
31
  Transforms currentTransforms;
33
32
  Transforms absoluteTransforms;
34
33
 
35
34
  #if 0
36
- boost::mutex texMutex;
35
+ std::mutex texMutex;
37
36
  #endif
38
37
 
39
38
  #ifdef GOSU_IS_IPHONE
@@ -219,7 +218,7 @@ void Gosu::Graphics::endGL()
219
218
  }
220
219
 
221
220
  #ifdef GOSU_IS_IPHONE
222
- void Gosu::Graphics::scheduleGL(const boost::function<void()>& functor, Gosu::ZPos z)
221
+ void Gosu::Graphics::scheduleGL(const std::tr1::function<void()>& functor, Gosu::ZPos z)
223
222
  {
224
223
  throw std::logic_error("Custom OpenGL is unsupported on the iPhone");
225
224
  }
@@ -229,9 +228,9 @@ namespace
229
228
  struct RunGLFunctor
230
229
  {
231
230
  Gosu::Graphics& graphics;
232
- boost::function<void()> functor;
231
+ std::tr1::function<void()> functor;
233
232
 
234
- RunGLFunctor(Gosu::Graphics& graphics, const boost::function<void()>& functor)
233
+ RunGLFunctor(Gosu::Graphics& graphics, const std::tr1::function<void()>& functor)
235
234
  : graphics(graphics), functor(functor)
236
235
  {
237
236
  }
@@ -251,7 +250,7 @@ namespace
251
250
  };
252
251
  }
253
252
 
254
- void Gosu::Graphics::scheduleGL(const boost::function<void()>& functor, Gosu::ZPos z)
253
+ void Gosu::Graphics::scheduleGL(const std::tr1::function<void()>& functor, Gosu::ZPos z)
255
254
  {
256
255
  pimpl->queues.back().scheduleGL(RunGLFunctor(*this, functor), z);
257
256
  }
@@ -328,8 +327,11 @@ void Gosu::Graphics::popTransform()
328
327
  {
329
328
  pimpl->currentTransforms.pop_back();
330
329
  Transform result = scale(1);
331
- BOOST_REVERSE_FOREACH (const Transform& tf, pimpl->currentTransforms)
332
- result = multiply(result, tf);
330
+
331
+ for (Transforms::reverse_iterator it = pimpl->currentTransforms.rbegin(),
332
+ end = pimpl->currentTransforms.rend(); it != end; ++it)
333
+ result = multiply(result, *it);
334
+
333
335
  ensureBackOfList(pimpl->absoluteTransforms, result);
334
336
  }
335
337
 
@@ -407,7 +409,7 @@ std::auto_ptr<Gosu::ImageData> Gosu::Graphics::createImage(
407
409
  (srcWidth & (srcWidth - 1)) == 0 &&
408
410
  srcWidth >= 64)
409
411
  {
410
- boost::shared_ptr<Texture> texture(new Texture(srcWidth));
412
+ std::tr1::shared_ptr<Texture> texture(new Texture(srcWidth));
411
413
  std::auto_ptr<ImageData> data;
412
414
 
413
415
  // Use the source bitmap directly if the source area completely covers
@@ -444,13 +446,13 @@ std::auto_ptr<Gosu::ImageData> Gosu::Graphics::createImage(
444
446
  applyBorderFlags(bmp, src, srcX, srcY, srcWidth, srcHeight, borderFlags);
445
447
 
446
448
  #if 0
447
- boost::mutex::scoped_lock lock(pimpl->texMutex);
449
+ std::mutex::scoped_lock lock(pimpl->texMutex);
448
450
  #endif
449
451
 
450
452
  // Try to put the bitmap into one of the already allocated textures.
451
453
  for (Impl::Textures::iterator i = pimpl->textures.begin(); i != pimpl->textures.end(); ++i)
452
454
  {
453
- boost::shared_ptr<Texture> texture(*i);
455
+ std::tr1::shared_ptr<Texture> texture(*i);
454
456
 
455
457
  std::auto_ptr<ImageData> data;
456
458
  data = texture->tryAlloc(*this, pimpl->absoluteTransforms, pimpl->queues, texture, bmp, 1);
@@ -460,7 +462,7 @@ std::auto_ptr<Gosu::ImageData> Gosu::Graphics::createImage(
460
462
 
461
463
  // All textures are full: Create a new one.
462
464
 
463
- boost::shared_ptr<Texture> texture;
465
+ std::tr1::shared_ptr<Texture> texture;
464
466
  texture.reset(new Texture(maxSize));
465
467
  pimpl->textures.push_back(texture);
466
468
 
@@ -8,7 +8,9 @@
8
8
  Gosu::Image::Image(Graphics& graphics, const std::wstring& filename, bool tileable)
9
9
  {
10
10
  // Forward.
11
- Image(graphics, loadImageFile(filename), tileable).data.swap(data);
11
+ Bitmap bmp;
12
+ loadImageFile(bmp, filename);
13
+ Image(graphics, bmp, tileable).data.swap(data);
12
14
  }
13
15
 
14
16
  Gosu::Image::Image(Graphics& graphics, const std::wstring& filename,
@@ -16,7 +18,9 @@ Gosu::Image::Image(Graphics& graphics, const std::wstring& filename,
16
18
  bool tileable)
17
19
  {
18
20
  // Forward.
19
- Image(graphics, loadImageFile(filename), srcX, srcY, srcWidth, srcHeight, tileable).data.swap(data);
21
+ Bitmap bmp;
22
+ loadImageFile(bmp, filename);
23
+ Image(graphics, bmp, srcX, srcY, srcWidth, srcHeight, tileable).data.swap(data);
20
24
  }
21
25
 
22
26
  Gosu::Image::Image(Graphics& graphics, const Bitmap& source, bool tileable)
@@ -29,7 +33,7 @@ Gosu::Image::Image(Graphics& graphics, const Bitmap& source,
29
33
  unsigned srcX, unsigned srcY, unsigned srcWidth, unsigned srcHeight,
30
34
  bool tileable)
31
35
  : data(graphics.createImage(source, srcX, srcY, srcWidth, srcHeight,
32
- tileable ? Gosu::bfTileable : Gosu::bfSmooth))
36
+ tileable ? Gosu::bfTileable : Gosu::bfSmooth).release())
33
37
  {
34
38
  }
35
39