aboutsummaryrefslogtreecommitdiff
path: root/pkg/static
diff options
context:
space:
mode:
authorAlexander Kiryukhin <a.kiryukhin@mail.ru>2020-08-17 13:42:24 +0300
committerAlexander Kiryukhin <a.kiryukhin@mail.ru>2020-08-17 13:42:41 +0300
commit4e63c622e464b6863dfec0b6c99f95833f46b12f (patch)
treef10247ecba81e44e2c77c0fb56ea01ea086d84b1 /pkg/static
parent3ff29e8a4ce10559a283a2f73213ea2570547b64 (diff)
Detached AsBytes method
Diffstat (limited to 'pkg/static')
-rw-r--r--pkg/static/map.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/pkg/static/map.go b/pkg/static/map.go
index 2597aaf..8de861f 100644
--- a/pkg/static/map.go
+++ b/pkg/static/map.go
@@ -26,7 +26,7 @@ const (
th = 256
)
-func GetMapImage(lat, lon float64, zoom, width, height int) ([]byte, error) {
+func GetMapImage(lat, lon float64, zoom, width, height int) (image.Image, error) {
x, y, dx, dy := getCoords(lat, lon, zoom)
dst := imaging.New(width, height, color.NRGBA{0, 255, 0, 255})
wg := sync.WaitGroup{}
@@ -57,13 +57,17 @@ func GetMapImage(lat, lon float64, zoom, width, height int) ([]byte, error) {
tx := cx + i*tw - di
ty := cy + j*th - dj
dst = imaging.Paste(dst, img, image.Pt(tx, ty))
- }(int(i), int(j))
+ }(i, j)
}
}
wg.Wait()
+ return dst, nil
+}
+
+func AsBytes(image image.Image) ([]byte,error) {
out := bytes.NewBuffer([]byte{})
- if err := imaging.Encode(out, dst, imaging.PNG); err != nil {
+ if err := imaging.Encode(out, image, imaging.PNG); err != nil {
return nil, err
}
return out.Bytes(), nil