Esempio n. 1
0
func CreateRGBSurfaceFrom(pixels unsafe.Pointer, width, height, depth, pitch int, Rmask, Gmask, Bmask, Amask uint32) *Surface {
	return (*Surface)(unsafe.Pointer(C.SDL_CreateRGBSurfaceFrom(pixels,
		C.int(width),
		C.int(height),
		C.int(depth),
		C.int(pitch),
		C.Uint32(Rmask),
		C.Uint32(Gmask),
		C.Uint32(Bmask),
		C.Uint32(Amask))))
}
Esempio n. 2
0
// Creates a Surface from existing pixel data. It expects pix to be a slice, array, or pointer.
func CreateRGBSurfaceFrom(pix interface{}, w, h, d, p int, rm, gm, bm, am uint32) *Surface {
	var ptr unsafe.Pointer
	switch v := reflect.ValueOf(pix); v.Kind() {
	case reflect.Ptr, reflect.UnsafePointer, reflect.Slice:
		ptr = unsafe.Pointer(v.Pointer())
	default:
		panic("Don't know how to handle type: " + v.Kind().String())
	}

	s := C.SDL_CreateRGBSurfaceFrom(ptr, C.int(w), C.int(h), C.int(d), C.int(p), C.Uint32(rm), C.Uint32(gm), C.Uint32(bm), C.Uint32(am))

	return (*Surface)(cast(s))
}
Esempio n. 3
0
func CreateRGBSurfaceFrom(pixels unsafe.Pointer, width, height, depth, pitch int32,
	Rmask, Gmask, Bmask, Amask uint32) *Surface {
	_width := (C.int)(width)
	_height := (C.int)(height)
	_depth := (C.int)(depth)
	_pitch := (C.int)(pitch)
	_Rmask := (C.Uint32)(Rmask)
	_Gmask := (C.Uint32)(Gmask)
	_Bmask := (C.Uint32)(Bmask)
	_Amask := (C.Uint32)(Amask)
	return (*Surface)(unsafe.Pointer(C.SDL_CreateRGBSurfaceFrom(pixels, _width, _height,
		_depth, _pitch, _Rmask, _Gmask, _Bmask, _Amask)))
}
Esempio n. 4
0
// Creates a Surface from existing pixel data. It expects pixels to be a slice, pointer or unsafe.Pointer.
func CreateRGBSurfaceFrom(pixels interface{}, width, height, bpp, pitch int, Rmask, Gmask, Bmask, Amask uint32) *Surface {
	var ptr unsafe.Pointer
	switch v := reflect.ValueOf(pixels); v.Kind() {
	case reflect.Ptr, reflect.UnsafePointer, reflect.Slice:
		ptr = unsafe.Pointer(v.Pointer())
	default:
		panic("Don't know how to handle type: " + v.Kind().String())
	}

	p := C.SDL_CreateRGBSurfaceFrom(ptr, C.int(width), C.int(height), C.int(bpp), C.int(pitch),
		C.Uint32(Rmask), C.Uint32(Gmask), C.Uint32(Bmask), C.Uint32(Amask))

	s := wrapSurface(p)
	s.gcPixels = pixels
	return s
}
Esempio n. 5
0
// CreateRGBSurfaceFrom (https://wiki.libsdl.org/SDL_CreateRGBSurfaceFrom)
func CreateRGBSurfaceFrom(pixels unsafe.Pointer, width, height, depth, pitch int, Rmask, Gmask, Bmask, Amask uint32) (*Surface, error) {
	surface := (*Surface)(unsafe.Pointer(C.SDL_CreateRGBSurfaceFrom(
		pixels,
		C.int(width),
		C.int(height),
		C.int(depth),
		C.int(pitch),
		C.Uint32(Rmask),
		C.Uint32(Gmask),
		C.Uint32(Bmask),
		C.Uint32(Amask))))
	if surface == nil {
		return nil, GetError()
	}
	return surface, nil
}
Esempio n. 6
0
func CreateRGBSurfaceFrom(pix uintptr, w, h, d, p int, rm, gm, bm, am uint32) (*Surface, error) {
	s := C.SDL_CreateRGBSurfaceFrom(
		unsafe.Pointer(pix),
		C.int(w),
		C.int(h),
		C.int(d),
		C.int(p),
		C.Uint32(rm),
		C.Uint32(gm),
		C.Uint32(bm),
		C.Uint32(am),
	)
	if s == nil {
		return nil, getError()
	}

	return (*Surface)(unsafe.Pointer(s)), nil
}