mirror of
https://github.com/gen2brain/cam2ip.git
synced 2025-12-15 11:58:33 +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 {
|
if c.opts.Timestamp {
|
||||||
img, err = im.Timestamp(img, c.opts.TimeFormat)
|
img = im.Timestamp(img, c.opts.TimeFormat)
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ func (c *Camera) Read() (img image.Image, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if c.opts.Timestamp {
|
if c.opts.Timestamp {
|
||||||
img, err = im.Timestamp(img, c.opts.TimeFormat)
|
img = im.Timestamp(img, c.opts.TimeFormat)
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ func (c *Camera) Read() (img image.Image, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if c.opts.Timestamp {
|
if c.opts.Timestamp {
|
||||||
img, err = im.Timestamp(img, c.opts.TimeFormat)
|
img = im.Timestamp(img, c.opts.TimeFormat)
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package image
|
package image
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"image"
|
"image"
|
||||||
"image/color"
|
"image/color"
|
||||||
"image/draw"
|
"image/draw"
|
||||||
@@ -35,13 +34,15 @@ func Flip(img image.Image, dir string) image.Image {
|
|||||||
return img
|
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)
|
dimg, ok := img.(draw.Image)
|
||||||
if !ok {
|
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)
|
pixfont.DrawString(dimg, 10, 10, time.Now().Format(format), color.White)
|
||||||
|
|
||||||
return dimg, nil
|
return dimg
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user