Created
August 30, 2014 22:20
-
-
Save pokutuna/dd44e15fbfb72a786e3a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"image" | |
"image/color" | |
"image/png" | |
"io/ioutil" | |
"os" | |
) | |
func main() { | |
rect := image.Rectangle{image.Pt(0, 0), image.Pt(1, 1)} | |
img := image.NewRGBA(rect) | |
img.Set(0, 0, color.Black) | |
file, _ := ioutil.TempFile(os.TempDir(), "image_test") | |
defer file.Close() | |
png.Encode(file, img) | |
fmt.Println(png.Decode(file)) // => <nil> unexpected EOF | |
file.Seek(0, 0) | |
fmt.Println(png.Decode(file)) // => &{[0 0 0 255] 4 (0,0)-(1,1)} <nil> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment