Exemple #1
0
// Maps a pixel value into the RGB components for a given pixel format
func getRGB(format *C.SDL_PixelFormat, pixel uint32) (byte, byte, byte) {
	var r, b, g uint8
	pr := cbyteptr(&r)
	pb := cbyteptr(&b)
	pg := cbyteptr(&g)
	C.SDL_GetRGB(C.Uint32(pixel), format, pr, pg, pb)
	return r, g, b
}
Exemple #2
0
// GetRGB gets the RGB components from a pixel of the specified format.
// GetRGB (https://wiki.libsdl.org/SDL_GetRGB)
func GetRGB(pixel uint32, format *PixelFormat) (r, g, b uint8) {
	C.SDL_GetRGB(C.Uint32(pixel), (*C.SDL_PixelFormat)(unsafe.Pointer(format)),
		(*C.Uint8)(&r), (*C.Uint8)(&g), (*C.Uint8)(&b))
	return
}
Exemple #3
0
// Gets RGB values from a pixel in the specified pixel format.
func GetRGB(color uint32, format *PixelFormat, r, g, b *uint8) {
	C.SDL_GetRGB(C.Uint32(color), (*C.SDL_PixelFormat)(cast(format)), (*C.Uint8)(r), (*C.Uint8)(g), (*C.Uint8)(b))
}
Exemple #4
0
func (p *PixelFormat) GetRGB(pix uint32) (r, g, b uint8) {
	var cr, cg, cb C.Uint8
	C.SDL_GetRGB(C.Uint32(pix), p.c(), &cr, &cg, &cb)

	return uint8(cr), uint8(cg), uint8(cb)
}