bitmap_io.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // albitmap
  2. package al
  3. /*
  4. #include <stdlib.h>
  5. #include <allegro5/allegro.h>
  6. #include "helpers.h"
  7. */
  8. import "C"
  9. const KEEP_BITMAP_FORMAT = C.ALLEGRO_KEEP_BITMAP_FORMAT
  10. const NO_PREMULTIPLIED_ALPHA = C.ALLEGRO_NO_PREMULTIPLIED_ALPHA
  11. const KEEP_INDEX = C.ALLEGRO_KEEP_INDEX
  12. func LoadBitmap(name string) * Bitmap {
  13. cname := cstr(name)
  14. defer cstrFree(cname)
  15. return wrapBitmap(C.al_load_bitmap(cname))
  16. }
  17. func (bmp * Bitmap) Save(name string) bool {
  18. cname := cstr(name)
  19. defer cstrFree(cname)
  20. return bool(C.al_save_bitmap(cname, bmp.toC()))
  21. }
  22. func (file * File) LoadBitmap(ident string) * Bitmap {
  23. var cident *C.char = nil
  24. if ident != "" {
  25. cident = cstr(ident)
  26. defer cstrFree(cident)
  27. }
  28. return wrapBitmap(C.al_load_bitmap_f(file.toC(), cident))
  29. }
  30. func (file * File) SaveBitmap(ident string, bmp * Bitmap) bool {
  31. var cident *C.char = nil
  32. if ident != "" {
  33. cident = cstr(ident)
  34. defer cstrFree(cident)
  35. }
  36. return bool(C.al_save_bitmap_f(file.toC(), cident, bmp.toC()))
  37. }