mirror of
https://github.com/gen2brain/cam2ip.git
synced 2025-12-13 02:48:31 +00:00
Update timestamp
This commit is contained in:
@@ -144,7 +144,7 @@ func (c *Camera) Read() (img image.Image, err error) {
|
||||
}
|
||||
|
||||
if c.opts.Timestamp {
|
||||
img, err = im.Timestamp(img, c.opts.TimeFormat)
|
||||
img = im.Timestamp(img, c.opts.TimeFormat)
|
||||
}
|
||||
|
||||
return
|
||||
|
||||
@@ -74,7 +74,7 @@ func (c *Camera) Read() (img image.Image, err error) {
|
||||
}
|
||||
|
||||
if c.opts.Timestamp {
|
||||
img, err = im.Timestamp(img, c.opts.TimeFormat)
|
||||
img = im.Timestamp(img, c.opts.TimeFormat)
|
||||
}
|
||||
|
||||
return
|
||||
|
||||
@@ -186,7 +186,7 @@ func (c *Camera) Read() (img image.Image, err error) {
|
||||
}
|
||||
|
||||
if c.opts.Timestamp {
|
||||
img, err = im.Timestamp(img, c.opts.TimeFormat)
|
||||
img = im.Timestamp(img, c.opts.TimeFormat)
|
||||
}
|
||||
|
||||
return
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package image
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"image"
|
||||
"image/color"
|
||||
"image/draw"
|
||||
@@ -35,13 +34,15 @@ func Flip(img image.Image, dir string) image.Image {
|
||||
return img
|
||||
}
|
||||
|
||||
func Timestamp(img image.Image, format string) (image.Image, error) {
|
||||
func Timestamp(img image.Image, format string) image.Image {
|
||||
dimg, ok := img.(draw.Image)
|
||||
if !ok {
|
||||
return img, fmt.Errorf("camera: %T is not a drawable image type", img)
|
||||
b := img.Bounds()
|
||||
dimg = image.NewRGBA(image.Rect(0, 0, b.Dx(), b.Dy()))
|
||||
draw.Draw(dimg, b, img, b.Min, draw.Src)
|
||||
}
|
||||
|
||||
pixfont.DrawString(dimg, 10, 10, time.Now().Format(format), color.White)
|
||||
|
||||
return dimg, nil
|
||||
return dimg
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user