func (h *Reader) ReadImage(ty image.TypeDesc, buf interface{}) error {
	if ty.BaseType != image.FLOAT {
		return errors.New("HDR: only supports float32 pixels")
	}
	pbuf := buf.([]float32)
	if pbuf == nil {
		return errors.New("HDR: pixel buffer not float32")
	}
	scanline := make([]byte, h.spec.Width*4)
	for j := 0; j < h.spec.Height; j++ {
		if err := readScanline(h.reader, scanline[j*h.spec.Width*4:j*h.spec.Width*4+h.spec.Width*4]); err != nil {
			return err
		}
		for i := 0; i < h.spec.Width; i++ {
			or := scanline[(i*4)+0]
			og := scanline[(i*4)+1]
			ob := scanline[(i*4)+2]
			oe := scanline[(i*4)+3]
			expo := uint(oe) - 128
			r := convertComponent(expo, or)
			g := convertComponent(expo, og)
			b := convertComponent(expo, ob)
			pbuf[j*h.spec.Width*3+(i*3)+0] = r
			pbuf[j*h.spec.Width*3+(i*3)+1] = g
			pbuf[j*h.spec.Width*3+(i*3)+2] = b
		}
	}
	return nil
}
ReadImage reads entire image into the given buf, translating into type ty (if possible).
package hdr
import (
	"bufio"
	"errors"
	"fmt"
	"github.com/jamiec7919/vermeer/image"
	"os"
)
type Reader struct {
	file   *os.File
	reader *bufio.Reader
	spec   image.Spec
}
func init() {
	open := func(filename string) (image.Reader, error) {
		r, err := Open(filename)
		if err == nil && r != nil {
			return r, err
		}
		return nil, err
	}
	image.RegisterReader(open)
}
func Open(filename string) (*Reader, error) {
	h := Reader{}
	file, err := os.Open(filename)
	if err != nil {
		return nil, err
	}
	h.file = file
	h.reader = bufio.NewReader(h.file)
	if err := h.readHeaders(); err != nil {
		return nil, err
	}
	return &h, nil
}
func (h *Reader) readHeaders() error {
	for {
		line, err := h.reader.ReadString('\n')
		if err != nil {
			return err
		}
		if len(line) == 1 {  
			break
		}
	}
	line, err := h.reader.ReadString('\n')
	if err != nil {
		return err
	}
	var xs, ys string
	var width, height int
	fmt.Sscanf(line, "%s %d %s %d", &ys, &height, &xs, &width)
	h.spec.Height = height
	h.spec.Width = width
	h.spec.X = 0  
	h.spec.Y = 0  
	h.spec.FullHeight = height
	h.spec.FullWidth = width
	h.spec.FullX = 0  
	h.spec.FullY = 0  
	h.spec.NChannels = 4
	h.spec.Format = []image.TypeDesc{image.TypeDesc{}, image.TypeDesc{}, image.TypeDesc{}, image.TypeDesc{}}
	h.spec.ChannelNames = []string{"R", "G", "B", "E"}
	h.spec.AlphaChannel = -1
	h.spec.ZChannel = -1
	return nil
}
func (h *Reader) Spec() (image.Spec, error) { return h.spec, nil }
func (h *Reader) Close() { h.file.Close() }