gosu 0.7.28 → 0.7.29
Sign up to get free protection for your applications and to get access to all the features.
- data/Gosu/Version.hpp +2 -2
- data/GosuImpl/RubyGosu.swg +18 -7
- data/GosuImpl/RubyGosu_wrap.cxx +20 -9
- metadata +4 -4
data/Gosu/Version.hpp
CHANGED
data/GosuImpl/RubyGosu.swg
CHANGED
@@ -235,20 +235,31 @@ namespace Gosu
|
|
235
235
|
return loadImageFile(Gosu::utf8ToWstring(filename));
|
236
236
|
}
|
237
237
|
|
238
|
-
// Otherwise, try to call .to_blob on it.
|
239
|
-
// (Works with RMagick).
|
238
|
+
// Otherwise, try to call .to_blob on it (works with RMagick, TexPlay etc).
|
240
239
|
VALUE conversion = rb_str_new2("to_blob { self.format = 'RGBA'; self.depth = 8 }");
|
241
240
|
VALUE blob = rb_obj_instance_eval(1, &conversion, val);
|
242
241
|
rb_check_safe_obj(blob);
|
243
242
|
unsigned width = NUM2UINT(rb_funcall(val, rb_intern("columns"), 0));
|
244
243
|
unsigned height = NUM2UINT(rb_funcall(val, rb_intern("rows"), 0));
|
245
|
-
|
246
|
-
if (width * height * 4 != RSTRING_LEN(blob))
|
247
|
-
throw std::logic_error("Blob length mismatch!");
|
244
|
+
|
248
245
|
Bitmap result;
|
249
246
|
result.resize(width, height);
|
250
|
-
|
251
|
-
|
247
|
+
if (width * height * 4 == RSTRING_LEN(blob))
|
248
|
+
{
|
249
|
+
// 32 bit per pixel, assume R8G8B8A8
|
250
|
+
std::memcpy(result.data(),
|
251
|
+
reinterpret_cast<const boost::uint32_t*>(RSTRING_PTR(blob)), width * height * 4);
|
252
|
+
}
|
253
|
+
else if (width * height * 4 * sizeof(float) == RSTRING_LEN(blob))
|
254
|
+
{
|
255
|
+
// 32 bit per channel, assume float/float/float/float
|
256
|
+
const float* in = reinterpret_cast<const float*>(RSTRING_PTR(blob));
|
257
|
+
Gosu::Color::Channel* out = reinterpret_cast<Gosu::Color::Channel*>(result.data());
|
258
|
+
for (int i = width * height * 4; i > 0; --i)
|
259
|
+
*(out++) = *(in++) * 255;
|
260
|
+
}
|
261
|
+
else
|
262
|
+
throw std::logic_error("Blob length mismatch!");
|
252
263
|
return result;
|
253
264
|
}
|
254
265
|
}
|
data/GosuImpl/RubyGosu_wrap.cxx
CHANGED
@@ -2296,20 +2296,31 @@ namespace Gosu
|
|
2296
2296
|
return loadImageFile(Gosu::utf8ToWstring(filename));
|
2297
2297
|
}
|
2298
2298
|
|
2299
|
-
// Otherwise, try to call .to_blob on it.
|
2300
|
-
// (Works with RMagick).
|
2299
|
+
// Otherwise, try to call .to_blob on it (works with RMagick, TexPlay etc).
|
2301
2300
|
VALUE conversion = rb_str_new2("to_blob { self.format = 'RGBA'; self.depth = 8 }");
|
2302
2301
|
VALUE blob = rb_obj_instance_eval(1, &conversion, val);
|
2303
2302
|
rb_check_safe_obj(blob);
|
2304
2303
|
unsigned width = NUM2UINT(rb_funcall(val, rb_intern("columns"), 0));
|
2305
2304
|
unsigned height = NUM2UINT(rb_funcall(val, rb_intern("rows"), 0));
|
2306
|
-
|
2307
|
-
if (width * height * 4 != RSTRING_LEN(blob))
|
2308
|
-
throw std::logic_error("Blob length mismatch!");
|
2305
|
+
|
2309
2306
|
Bitmap result;
|
2310
2307
|
result.resize(width, height);
|
2311
|
-
|
2312
|
-
|
2308
|
+
if (width * height * 4 == RSTRING_LEN(blob))
|
2309
|
+
{
|
2310
|
+
// 32 bit per pixel, assume R8G8B8A8
|
2311
|
+
std::memcpy(result.data(),
|
2312
|
+
reinterpret_cast<const boost::uint32_t*>(RSTRING_PTR(blob)), width * height * 4);
|
2313
|
+
}
|
2314
|
+
else if (width * height * 4 * sizeof(float) == RSTRING_LEN(blob))
|
2315
|
+
{
|
2316
|
+
// 32 bit per channel, assume float/float/float/float
|
2317
|
+
const float* in = reinterpret_cast<const float*>(RSTRING_PTR(blob));
|
2318
|
+
Gosu::Color::Channel* out = reinterpret_cast<Gosu::Color::Channel*>(result.data());
|
2319
|
+
for (int i = width * height * 4; i > 0; --i)
|
2320
|
+
*(out++) = *(in++) * 255;
|
2321
|
+
}
|
2322
|
+
else
|
2323
|
+
throw std::logic_error("Blob length mismatch!");
|
2313
2324
|
return result;
|
2314
2325
|
}
|
2315
2326
|
}
|
@@ -11041,8 +11052,8 @@ SWIGEXPORT void Init_gosu(void) {
|
|
11041
11052
|
SWIG_RubyInitializeTrackings();
|
11042
11053
|
rb_define_const(mGosu, "MAJOR_VERSION", SWIG_From_int(static_cast< int >(0)));
|
11043
11054
|
rb_define_const(mGosu, "MINOR_VERSION", SWIG_From_int(static_cast< int >(7)));
|
11044
|
-
rb_define_const(mGosu, "POINT_VERSION", SWIG_From_int(static_cast< int >(
|
11045
|
-
rb_define_const(mGosu, "VERSION", SWIG_FromCharPtr("0.7.
|
11055
|
+
rb_define_const(mGosu, "POINT_VERSION", SWIG_From_int(static_cast< int >(29)));
|
11056
|
+
rb_define_const(mGosu, "VERSION", SWIG_FromCharPtr("0.7.29"));
|
11046
11057
|
rb_define_module_function(mGosu, "milliseconds", VALUEFUNC(_wrap_milliseconds), -1);
|
11047
11058
|
rb_define_module_function(mGosu, "random", VALUEFUNC(_wrap_random), -1);
|
11048
11059
|
rb_define_module_function(mGosu, "degrees_to_radians", VALUEFUNC(_wrap_degrees_to_radians), -1);
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gosu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 57
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 7
|
9
|
-
-
|
10
|
-
version: 0.7.
|
9
|
+
- 29
|
10
|
+
version: 0.7.29
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Julian Raschke
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-03-
|
19
|
+
date: 2011-03-30 00:00:00 +08:00
|
20
20
|
default_executable:
|
21
21
|
dependencies: []
|
22
22
|
|