September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -1,59 +0,0 @@
|
|||
package main
|
||||
|
||||
// Files required to build supporting package raster are found in:
|
||||
// * Bitmap
|
||||
// * Write a PPM file
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os/exec"
|
||||
"raster"
|
||||
)
|
||||
|
||||
func main() {
|
||||
b := raster.NewBitmap(400, 300)
|
||||
// a little extravagant, this draws a design of dots and lines
|
||||
b.FillRgb(0xc08040)
|
||||
for i := 0; i < 2000; i++ {
|
||||
b.SetPxRgb(rand.Intn(400), rand.Intn(300), 0x804020)
|
||||
}
|
||||
for x := 0; x < 400; x++ {
|
||||
for y := 240; y < 245; y++ {
|
||||
b.SetPxRgb(x, y, 0x804020)
|
||||
}
|
||||
for y := 260; y < 265; y++ {
|
||||
b.SetPxRgb(x, y, 0x804020)
|
||||
}
|
||||
}
|
||||
for y := 0; y < 300; y++ {
|
||||
for x := 80; x < 85; x++ {
|
||||
b.SetPxRgb(x, y, 0x804020)
|
||||
}
|
||||
for x := 95; x < 100; x++ {
|
||||
b.SetPxRgb(x, y, 0x804020)
|
||||
}
|
||||
}
|
||||
|
||||
// pipe logic
|
||||
c := exec.Command("cjpeg", "-outfile", "pipeout.jpg")
|
||||
pipe, err := c.StdinPipe()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
err = c.Start()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
err = b.WritePpmTo(pipe)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
err = pipe.Close()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
let print_jpeg ~img ?(quality=96) () =
|
||||
let cmd = Printf.sprintf "cjpeg -quality %d" quality in
|
||||
(*
|
||||
let cmd = Printf.sprintf "ppmtojpeg -quality %d" quality in
|
||||
let cmd = Printf.sprintf "convert ppm:- -quality %d jpg:-" quality in
|
||||
*)
|
||||
let ic, oc = Unix.open_process cmd in
|
||||
output_ppm ~img ~oc;
|
||||
try
|
||||
while true do
|
||||
let c = input_char ic in
|
||||
print_char c
|
||||
done
|
||||
with End_of_file -> ()
|
||||
;;
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
img:=PPM.readPPMFile("fractal.ppm");
|
||||
p:=System.popen(0'|convert ppm:- jpg:"fractal.jpg"|,"w");
|
||||
img.write(p); p.close();
|
||||
Loading…
Add table
Add a link
Reference in a new issue