mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2025-06-28 14:16:24 +02:00
Moved image saving to common.
This commit is contained in:
@ -1,24 +0,0 @@
|
||||
// Copyright 2014 by Sascha L. Teichmann
|
||||
// Use of this source code is governed by the MIT license
|
||||
// that can be found in the LICENSE file.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"image"
|
||||
"image/png"
|
||||
"os"
|
||||
)
|
||||
|
||||
func SaveAsPNG(path string, img image.Image) (err error) {
|
||||
var file *os.File
|
||||
if file, err = os.Create(path); err != nil {
|
||||
return
|
||||
}
|
||||
writer := bufio.NewWriter(file)
|
||||
err = png.Encode(writer, img)
|
||||
writer.Flush()
|
||||
file.Close()
|
||||
return
|
||||
}
|
@ -111,7 +111,7 @@ func main() {
|
||||
colors.Colors, color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff})
|
||||
}
|
||||
|
||||
if err = SaveAsPNG(outfile, image); err != nil {
|
||||
if err = common.SaveAsPNG(outfile, image); err != nil {
|
||||
log.Fatalf("writing image failed: %s", err)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user