always read images as NRGBA
This commit is contained in:
parent
997fbe0d2a
commit
5f55530e3e
5
main.go
5
main.go
|
@ -64,11 +64,10 @@ func taskFromFlags(stop chan bool, wg *sync.WaitGroup) {
|
|||
|
||||
var img *image.NRGBA
|
||||
if *imgPath != "" {
|
||||
imgTmp, err := render.ReadImage(*imgPath)
|
||||
if err != nil {
|
||||
var err error
|
||||
if img, err = render.ReadImage(*imgPath); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
img = render.ImgToNRGBA(imgTmp)
|
||||
}
|
||||
|
||||
r.SetTask(img, image.Pt(*x, *y), *address, *connections)
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
"golang.org/x/image/draw"
|
||||
)
|
||||
|
||||
func ReadImage(path string) (image.Image, error) {
|
||||
func ReadImage(path string) (*image.NRGBA, error) {
|
||||
reader, err := os.Open(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -20,7 +20,7 @@ func ReadImage(path string) (image.Image, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return img, nil
|
||||
return imgToNRGBA(img), nil
|
||||
}
|
||||
|
||||
func WriteImage(path string, img image.Image) error {
|
||||
|
@ -35,7 +35,7 @@ func WriteImage(path string, img image.Image) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func ImgToNRGBA(img image.Image) *image.NRGBA {
|
||||
func imgToNRGBA(img image.Image) *image.NRGBA {
|
||||
b := img.Bounds()
|
||||
r := image.NewNRGBA(b)
|
||||
for x := b.Min.X; x < b.Max.X; x++ {
|
||||
|
|
|
@ -123,7 +123,7 @@ func RunREPL(f Fluter) {
|
|||
if img, err := render.ReadImage(path); err != nil {
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
t.Img = render.ImgToNRGBA(img)
|
||||
t.Img = img
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue