def get_at( *args )
x,y = case args.length
when 1; args[0].to_ary.collect { |n| n.round }
when 2; [args[0].round, args[1].round]
else
raise( ArgumentError,
"wrong number of arguments (#{args.length} for 1)" )
end
if( x < 0 or x >= @struct.w or y < 0 or y >= @struct.h)
raise( IndexError, "point [%d,%d] is out of bounds for %dx%d Surface"%\
[x, y, @struct.w, @struct.h] )
end
SDL.LockSurface(@struct)
bpp = @struct.format.BytesPerPixel
ptr = @struct.pixels + (y * @struct.pitch + x * bpp)
pixel =
case bpp
when 1
ptr.get_uint8(0)
when 2
ptr.get_uint16(0)
when 3
if( FFI::Platform::BYTE_ORDER == FFI::Platform::BIG_ENDIAN )
(ptr.get_uint8(0) << 16)|(ptr.get_uint8(1) << 8)|ptr.get_uint8(2)
else
ptr.get_uint8(0)|(ptr.get_uint8(1) << 8)|(ptr.get_uint8(2) << 16)
end
when 4
ptr.get_uint32(0)
end
SDL.UnlockSurface(@struct)
return SDL::GetRGBA(pixel, @struct.format)
end