RosettaCodeData/Task/Bitmap-Read-a-PPM-file/Go/bitmap-read-a-ppm-file-2.go
Ingy döt Net 518da4a923 B
2013-04-10 16:19:29 -07:00

28 lines
631 B
Go

package main
// Files required to build supporting package raster are found in:
// * This task (immediately above)
// * Bitmap
// * Grayscale image
// * Write a PPM file
import (
"raster"
"fmt"
)
func main() {
// (A file with this name is output by the Go solution to the task
// "Bitmap/Read an image through a pipe," but of course any 8-bit
// P6 PPM file should work.)
b, err := raster.ReadPpmFile("pipein.ppm")
if err != nil {
fmt.Println(err)
return
}
b = b.Grmap().Bitmap()
err = b.WritePpmFile("grayscale.ppm")
if err != nil {
fmt.Println(err)
}
}