Guest User

Untitled

a guest
Jun 23rd, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. // Try to treat as filename first.
  2. if (rb_respond_to(val, rb_intern("to_str")))
  3. {
  4. const char* filename = STR2CSTR(rb_funcall(val, rb_intern("to_str"), 0));
  5. return quickLoadBitmap(Gosu::utf8ToWstring(filename));
  6. }
  7.  
  8. // Otherwise, try to call .to_blob on it.
  9. // (Works with RMagick).
  10. VALUE conversion = rb_str_new2("to_blob { self.format = 'RGBA'; self.depth = 8 }");
  11. VALUE blob = rb_obj_instance_eval(1, &conversion, val);
  12. Check_SafeStr(blob);
  13. unsigned width = NUM2UINT(rb_funcall(val, rb_intern("columns"), 0));
  14. unsigned height = NUM2UINT(rb_funcall(val, rb_intern("rows"), 0));
Add Comment
Please, Sign In to add comment