func NewImage(path string) (*Image, error) { f, ferr := os.Open(path) if ferr != nil { fmt.Fprintf(os.Stderr, "%v\n", ferr) return nil, fmt.Errorf("Could not open image %v", ferr) } defer f.Close() imConf, _, err := image.DecodeConfig(f) if err != nil { return nil, fmt.Errorf("Could not decode image", err) } im := Image{} im.Path = path pathArr := strings.Split(path, "/") im.Url = "/inc/" + pathArr[len(pathArr)-1] fmt.Println(im.Url) size := geom.Rect{} size.Min = geom.Coord{X: 0, Y: 0} size.Max = geom.Coord{X: float64(imConf.Width), Y: float64(imConf.Height)} im.Size = size return &im, nil }
func (self *Image) ConstructCells(number int, max geom.Coord) (err error) { size := geom.Rect{} size.Min = geom.Coord{X: 0, Y: 0} size.Max = max self.CellNumber = number self.CellSize = size return }