Better struct name
This commit is contained in:
parent
508a61bd1c
commit
9eedcc1d2a
@ -257,8 +257,8 @@ func image_lines(left_path, right_path string, columns, margin_size int, ans []*
|
|||||||
}
|
}
|
||||||
text := fmt.Sprintf("Size: %s", human_readable(sz))
|
text := fmt.Sprintf("Size: %s", human_readable(sz))
|
||||||
res := image_collection.ResolutionOf(path)
|
res := image_collection.ResolutionOf(path)
|
||||||
if res.X > -1 {
|
if res.Width > -1 {
|
||||||
text = fmt.Sprintf("Dimensions: %dx%d %s", res.X, res.Y, text)
|
text = fmt.Sprintf("Dimensions: %dx%d %s", res.Width, res.Height, text)
|
||||||
}
|
}
|
||||||
text = place_in(text, available_cols)
|
text = place_in(text, available_cols)
|
||||||
return formatter(strings.Repeat(` `, margin_size) + text), err
|
return formatter(strings.Repeat(` `, margin_size) + text), err
|
||||||
|
|||||||
@ -4,7 +4,6 @@ package graphics
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"image"
|
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
@ -15,14 +14,16 @@ import (
|
|||||||
|
|
||||||
var _ = fmt.Print
|
var _ = fmt.Print
|
||||||
|
|
||||||
|
type Size struct{ Width, Height int }
|
||||||
|
|
||||||
type Image struct {
|
type Image struct {
|
||||||
src struct {
|
src struct {
|
||||||
path string
|
path string
|
||||||
data *images.ImageData
|
data *images.ImageData
|
||||||
size image.Point
|
size Size
|
||||||
loaded bool
|
loaded bool
|
||||||
}
|
}
|
||||||
renderings map[image.Point]*images.ImageData
|
renderings map[Size]*images.ImageData
|
||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,14 +34,14 @@ type ImageCollection struct {
|
|||||||
images map[string]*Image
|
images map[string]*Image
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *ImageCollection) ResolutionOf(key string) image.Point {
|
func (self *ImageCollection) ResolutionOf(key string) Size {
|
||||||
if !self.mutex.TryLock() {
|
if !self.mutex.TryLock() {
|
||||||
return image.Point{-1, -1}
|
return Size{-1, -1}
|
||||||
}
|
}
|
||||||
defer self.mutex.Unlock()
|
defer self.mutex.Unlock()
|
||||||
i := self.images[key]
|
i := self.images[key]
|
||||||
if i == nil {
|
if i == nil {
|
||||||
return image.Point{-2, -2}
|
return Size{-2, -2}
|
||||||
}
|
}
|
||||||
return i.src.size
|
return i.src.size
|
||||||
}
|
}
|
||||||
@ -68,7 +69,7 @@ func (self *ImageCollection) LoadAll() {
|
|||||||
if !img.src.loaded {
|
if !img.src.loaded {
|
||||||
img.src.data, img.err = images.OpenImageFromPath(img.src.path)
|
img.src.data, img.err = images.OpenImageFromPath(img.src.path)
|
||||||
if img.err == nil {
|
if img.err == nil {
|
||||||
img.src.size.X, img.src.size.Y = img.src.data.Width, img.src.data.Height
|
img.src.size.Width, img.src.size.Height = img.src.data.Width, img.src.data.Height
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user