Added New{Memory,Video}Bitmap functions to create memory/video bitmap directly.
Added new bitmap flags to New{Memory,Bitmap,}Bitmap methods.
This commit is contained in:
parent
5f12bfe3ef
commit
499dff7a96
@ -51,8 +51,17 @@ type Rotation struct {
|
||||
Center bool
|
||||
}
|
||||
|
||||
// NewBitmap creates a new bitmap of given width and height
|
||||
func NewBitmap(width, height int) (*Bitmap, error) {
|
||||
func newBitmap(width, height int, mut func(m FlagMutation), flags []NewBitmapFlag) (*Bitmap, error) {
|
||||
var newBmpFlags = CaptureNewBitmapFlags()
|
||||
defer newBmpFlags.Revert()
|
||||
newBmpFlags.Mutate(func(m FlagMutation) {
|
||||
if nil != mut {
|
||||
mut(m)
|
||||
}
|
||||
for _, f := range flags {
|
||||
m.Set(f)
|
||||
}
|
||||
})
|
||||
b := C.al_create_bitmap(C.int(width), C.int(height))
|
||||
if nil == b {
|
||||
return nil, errors.New("error creating bitmap")
|
||||
@ -60,6 +69,27 @@ func NewBitmap(width, height int) (*Bitmap, error) {
|
||||
return &Bitmap{b, width, height}, nil
|
||||
}
|
||||
|
||||
// NewBitmap creates a new bitmap of given width and height and optional flags
|
||||
func NewBitmap(width, height int, flags ...NewBitmapFlag) (*Bitmap, error) {
|
||||
return newBitmap(width, height, nil, flags)
|
||||
}
|
||||
|
||||
// NewVideoBitmap creates a new video bitmap of given width and height and optional flags
|
||||
func NewVideoBitmap(width, height int, flags ...NewBitmapFlag) (*Bitmap, error) {
|
||||
return newBitmap(width, height, func(m FlagMutation) {
|
||||
m.Unset(NewBitmapFlagMemoryBitmap)
|
||||
m.Set(NewBitmapFlagVideoBitmap)
|
||||
}, flags)
|
||||
}
|
||||
|
||||
// NewMemoryBitmap creates a new video bitmap of given width and height and optional flags
|
||||
func NewMemoryBitmap(width, height int, flags ...NewBitmapFlag) (*Bitmap, error) {
|
||||
return newBitmap(width, height, func(m FlagMutation) {
|
||||
m.Unset(NewBitmapFlagVideoBitmap)
|
||||
m.Set(NewBitmapFlagMemoryBitmap)
|
||||
}, flags)
|
||||
}
|
||||
|
||||
// NewBitmapFromImage creates a new bitmap starting from a Go native image (image.Image)
|
||||
func NewBitmapFromImage(im image.Image, video bool) (*Bitmap, error) {
|
||||
var newBmpFlags = CaptureNewBitmapFlags()
|
||||
|
Loading…
Reference in New Issue
Block a user