mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2024-11-08 11:10:27 +01:00
25 lines
445 B
Go
25 lines
445 B
Go
|
// 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
|
||
|
}
|