bitmap_io.go 1.1 KB

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