Bitmap/Read an image through a pipe: Difference between revisions
Content added Content deleted
(Added Mathematica) |
(→{{header|Go}}: Integrate with flood fill task. (The previous rev was still working fine)) |
||
Line 105: | Line 105: | ||
=={{header|Go}}== |
=={{header|Go}}== |
||
This example uses convert to convert the test image for the flood fill task. It reads through the pipe as required for this task, then writes as a .ppm file convenient for the flood fill task. |
|||
{{works with|Go weekly.2011-12-14}} |
|||
Using djpeg: |
|||
<lang go>package main |
<lang go>package main |
||
Line 115: | Line 114: | ||
import ( |
import ( |
||
" |
"log" |
||
"os/exec" |
"os/exec" |
||
"raster" |
"raster" |
||
Line 121: | Line 120: | ||
func main() { |
func main() { |
||
c := exec.Command("convert", "Unfilledcirc.png", "-depth", "8", "ppm:-") |
|||
// (A file with this name is output by the Go solution to the task |
|||
// "Bitmap/PPM conversion through a pipe," but of course any handy |
|||
// jpeg should work.) |
|||
c := exec.Command("djpeg", "pipeout.jpg") |
|||
pipe, err := c.StdoutPipe() |
pipe, err := c.StdoutPipe() |
||
if err != nil { |
if err != nil { |
||
log.Fatal(err) |
|||
return |
|||
} |
} |
||
err = c.Start() |
if err = c.Start(); err != nil { |
||
log.Fatal(err) |
|||
fmt.Println(err) |
|||
return |
|||
} |
} |
||
b, err := raster.ReadPpmFrom(pipe) |
b, err := raster.ReadPpmFrom(pipe) |
||
if err != nil { |
if err != nil { |
||
log.Fatal(err) |
|||
return |
|||
} |
} |
||
err = b.WritePpmFile(" |
if err = b.WritePpmFile("Unfilledcirc.ppm"); err != nil { |
||
log.Fatal(err) |
|||
fmt.Println(err) |
|||
} |
} |
||
}</lang> |
}</lang> |