Ejemplo n.º 1
0
// render image of quantity
func render(w http.ResponseWriter, r *http.Request) {
	url := strings.ToLower(r.URL.Path[len("/render/"):])
	h, ok := engine.Quant(url)
	if !ok {
		http.Error(w, "render: unknown quantity: "+url, http.StatusNotFound)
		return
	} else {
		cuda.LockThread()                               // TODO: for bootstrapping only, use dedicated thread
		img := draw.Image(h.Download(), "auto", "auto") // TODO: not very concurrent
		jpeg.Encode(w, img, &jpeg.Options{Quality: 100})
	}
}
Ejemplo n.º 2
0
func dumpJPEG(out io.Writer, f *data.Slice) error {
	img := draw.Image(f, *flag_min, *flag_max)
	buf := bufio.NewWriter(out)
	defer buf.Flush()
	return jpeg.Encode(buf, img, &jpeg.Options{Quality: 100})
}
Ejemplo n.º 3
0
func dumpPNG(out io.Writer, f *data.Slice) error {
	img := draw.Image(f, *flag_min, *flag_max)
	buf := bufio.NewWriter(out)
	defer buf.Flush()
	return png.Encode(buf, img)
}