// Converts a surface to the display format with alpha func (s *Surface) DisplayFormatAlpha() *Surface { s.mutex.RLock() p := C.SDL_DisplayFormatAlpha(s.cSurface) s.mutex.RUnlock() return wrap(p) }
// Converts a surface to the display format with alpha func DisplayFormatAlpha(src *Surface) *Surface { p := C.SDL_DisplayFormatAlpha((*C.SDL_Surface)(cast(src))) return (*Surface)(cast(p)) }
type imageKey struct { path string width int height int } func (me *imageKey) String() string { return me.path + strconv.Itoa(me.width) + strconv.Itoa(me.height) } //Resizes images from imageFiles and caches them. var images = newFlyweight( func(path key) interface{} { key := path.(*imageKey) tmp := C.IMG_Load(C.CString(key.path)) i := C.SDL_DisplayFormatAlpha(tmp) C.SDL_FreeSurface(tmp) if key.width != -1 && key.height != -1 { if (i != nil) && (int(i.w) != key.width || int(i.h) != key.height) { i = resize(i, key.width, key.height) } } return i }, func(path key, img interface{}) { i := img.(*C.SDL_Surface) C.SDL_FreeSurface(i) }) type Image struct { img *C.SDL_Surface
func (s *Surface) DisplayFormatAlpha() *Surface { return (*Surface)(C.SDL_DisplayFormatAlpha(s.Get())) }
// This function takes a surface and copies it to a new surface of the // pixel format and colors of the video framebuffer (if possible), // suitable for fast alpha blitting onto the display surface. // The new surface will always have an alpha channel. // // If you want to take advantage of hardware colorkey or alpha blit // acceleration, you should set the colorkey and alpha value before // calling this function. // // If the conversion fails or runs out of memory, it returns NULL func displayFormatAlpha(surface *C.SDL_Surface) *C.SDL_Surface { return C.SDL_DisplayFormatAlpha(surface) }