mirror of https://github.com/liamg/aminal.git
23 lines
337 B
Go
23 lines
337 B
Go
package util
|
|
|
|
import (
|
|
"errors"
|
|
"image"
|
|
)
|
|
|
|
func CreateImage(rect image.Rectangle) (img *image.RGBA, e error) {
|
|
img = nil
|
|
e = errors.New("Cannot create image.RGBA")
|
|
|
|
defer func() {
|
|
err := recover()
|
|
if err == nil {
|
|
e = nil
|
|
}
|
|
}()
|
|
// image.NewRGBA may panic if rect is too large.
|
|
img = image.NewRGBA(rect)
|
|
|
|
return img, e
|
|
}
|