Moved image saving to common.

This commit is contained in:
Sascha L. Teichmann
2014-09-14 00:31:28 +02:00
parent 5319e113bf
commit 9106d71363
2 changed files with 2 additions and 2 deletions

24
common/image.go Normal file
View File

@ -0,0 +1,24 @@
// 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 common
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
}