# File lib/rubygame/image.rb, line 118 def load_from_string( data, type=nil ) raw = FFI::Buffer.new(:char, data.length) raw.put_bytes(0, data) rw = SDL.RWFromMem( raw, data.length ) surf = if type SDL::Image.LoadTyped_RW(rw, 1, type) else SDL::Image.Load_RW(rw, 1) end if surf.pointer.null? raise( Rubygame::SDLError, "Couldn't load image from string: #{SDL.GetError()}" ) end return new(surf) end