|
@@ -23,13 +23,19 @@ func (bmp *Bitmap) toC() * C.ALLEGRO_BITMAP {
|
|
|
|
|
|
|
|
|
|
|
|
-func (self *Bitmap) Destroy() {
|
|
|
- if self.handle != nil {
|
|
|
- C.al_destroy_bitmap(self.handle)
|
|
|
+func (bmp *Bitmap) Destroy() {
|
|
|
+ if bmp.handle != nil {
|
|
|
+ C.al_destroy_bitmap(bmp.handle)
|
|
|
}
|
|
|
- self.handle = nil
|
|
|
+ bmp.handle = nil
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+func (bmp *Bitmap) Close() {
|
|
|
+ bmp.Destroy()
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
|
|
|
func wrapBitmapRaw(handle *C.ALLEGRO_BITMAP) *Bitmap {
|
|
|
if handle == nil {
|
|
@@ -40,11 +46,11 @@ func wrapBitmapRaw(handle *C.ALLEGRO_BITMAP) *Bitmap {
|
|
|
|
|
|
|
|
|
func wrapBitmap(handle *C.ALLEGRO_BITMAP) *Bitmap {
|
|
|
- self := wrapBitmapRaw(handle)
|
|
|
- if self != nil {
|
|
|
- runtime.SetFinalizer(self, func(me *Bitmap) { me.Destroy() })
|
|
|
+ bmp := wrapBitmapRaw(handle)
|
|
|
+ if bmp != nil {
|
|
|
+ runtime.SetFinalizer(bmp, func(me *Bitmap) { me.Destroy() })
|
|
|
}
|
|
|
- return self
|
|
|
+ return bmp
|
|
|
}
|
|
|
|
|
|
const (
|
|
@@ -75,23 +81,23 @@ func AddNewBitmapFlag(flags int) {
|
|
|
}
|
|
|
|
|
|
|
|
|
-func NewBitmapFormat(format int) int {
|
|
|
+func NewBitmapFormat() int {
|
|
|
return int(C.al_get_new_bitmap_format())
|
|
|
}
|
|
|
|
|
|
|
|
|
-func NewBitmapFlags(flags int) int {
|
|
|
+func NewBitmapFlags() int {
|
|
|
return int(C.al_get_new_bitmap_flags())
|
|
|
}
|
|
|
|
|
|
|
|
|
-func (self *Bitmap) Width() int {
|
|
|
- return int(C.al_get_bitmap_width(self.handle))
|
|
|
+func (bmp *Bitmap) Width() int {
|
|
|
+ return int(C.al_get_bitmap_width(bmp.handle))
|
|
|
}
|
|
|
|
|
|
|
|
|
-func (self *Bitmap) Height() int {
|
|
|
- return int(C.al_get_bitmap_height(self.handle))
|
|
|
+func (bmp *Bitmap) Height() int {
|
|
|
+ return int(C.al_get_bitmap_height(bmp.handle))
|
|
|
}
|
|
|
|
|
|
|
|
@@ -107,13 +113,13 @@ func (bmp *Bitmap) Heightf() float32 {
|
|
|
|
|
|
|
|
|
|
|
|
-func (self *Bitmap) Format() int {
|
|
|
- return int(C.al_get_bitmap_format(self.handle))
|
|
|
+func (bmp *Bitmap) Format() int {
|
|
|
+ return int(C.al_get_bitmap_format(bmp.handle))
|
|
|
}
|
|
|
|
|
|
|
|
|
-func (self *Bitmap) Flags() int {
|
|
|
- return int(C.al_get_bitmap_flags(self.handle))
|
|
|
+func (bmp *Bitmap) Flags() int {
|
|
|
+ return int(C.al_get_bitmap_flags(bmp.handle))
|
|
|
}
|
|
|
|
|
|
|
|
@@ -138,14 +144,14 @@ func PutBlendedPixel(x, y int, color Color) {
|
|
|
}
|
|
|
|
|
|
|
|
|
-func (self *Bitmap) GetPixel(x, y int) (color Color) {
|
|
|
- return wrapColor(C.al_get_pixel(self.handle, C.int(x), C.int(y)))
|
|
|
+func (bmp *Bitmap) Pixel(x, y int) (color Color) {
|
|
|
+ return wrapColor(C.al_get_pixel(bmp.handle, C.int(x), C.int(y)))
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
-func (self *Bitmap) ConvertMaskToAlpha(mask_color Color) {
|
|
|
- C.al_convert_mask_to_alpha(self.handle, mask_color.toC())
|
|
|
+func (bmp *Bitmap) ConvertMaskToAlpha(mask_color Color) {
|
|
|
+ C.al_convert_mask_to_alpha(bmp.handle, mask_color.toC())
|
|
|
}
|
|
|
|
|
|
|
|
@@ -168,29 +174,29 @@ func ClippingRectangle() (x, y, w, h int) {
|
|
|
|
|
|
|
|
|
|
|
|
-func (self *Bitmap) CreateSubBitmapRaw(x, y, w, h int) *Bitmap {
|
|
|
- return wrapBitmapRaw(C.al_create_sub_bitmap(self.handle,
|
|
|
+func (bmp *Bitmap) CreateSubBitmapRaw(x, y, w, h int) *Bitmap {
|
|
|
+ return wrapBitmapRaw(C.al_create_sub_bitmap(bmp.handle,
|
|
|
C.int(x), C.int(y), C.int(w), C.int(h)))
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-func (self *Bitmap) CreateSubBitmap(x, y, w, h int) *Bitmap {
|
|
|
- return wrapBitmap(C.al_create_sub_bitmap(self.handle,
|
|
|
+func (bmp *Bitmap) CreateSubBitmap(x, y, w, h int) *Bitmap {
|
|
|
+ return wrapBitmap(C.al_create_sub_bitmap(bmp.handle,
|
|
|
C.int(x), C.int(y), C.int(w), C.int(h)))
|
|
|
}
|
|
|
|
|
|
|
|
|
-func (self *Bitmap) IsSubBitmap() bool {
|
|
|
- return cb2b(C.al_is_sub_bitmap(self.handle))
|
|
|
+func (bmp *Bitmap) IsSubBitmap() bool {
|
|
|
+ return cb2b(C.al_is_sub_bitmap(bmp.handle))
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-func (self *Bitmap) Parent() *Bitmap {
|
|
|
- return wrapBitmapRaw(C.al_get_parent_bitmap(self.handle))
|
|
|
+func (bmp *Bitmap) Parent() *Bitmap {
|
|
|
+ return wrapBitmapRaw(C.al_get_parent_bitmap(bmp.handle))
|
|
|
}
|
|
|
|
|
|
|
|
@@ -209,19 +215,19 @@ func (bmp *Bitmap) Reparent(parent * Bitmap, x, y, w, h int) {
|
|
|
|
|
|
|
|
|
|
|
|
-func (self *Bitmap) CloneRaw() *Bitmap {
|
|
|
- return wrapBitmapRaw(C.al_clone_bitmap(self.handle))
|
|
|
+func (bmp *Bitmap) CloneRaw() *Bitmap {
|
|
|
+ return wrapBitmapRaw(C.al_clone_bitmap(bmp.handle))
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
-func (self *Bitmap) Clone() *Bitmap {
|
|
|
- return wrapBitmap(C.al_clone_bitmap(self.handle))
|
|
|
+func (bmp *Bitmap) Clone() *Bitmap {
|
|
|
+ return wrapBitmap(C.al_clone_bitmap(bmp.handle))
|
|
|
}
|
|
|
|
|
|
|
|
|
-func (self *Bitmap) Convert() {
|
|
|
- C.al_convert_bitmap(self.handle)
|
|
|
+func (bmp *Bitmap) Convert() {
|
|
|
+ C.al_convert_bitmap(bmp.handle)
|
|
|
}
|
|
|
|
|
|
|