fix: copy screenshot buffer for OCR recognizing

This commit is contained in:
lilong.129 2023-04-18 19:59:52 +08:00
parent 865c8c6786
commit b6cf074bb5
3 changed files with 9 additions and 3 deletions

View File

@ -1,6 +1,6 @@
# Release History
## v4.3.3 (2023-04-16)
## v4.3.3 (2023-04-18)
**go version**

View File

@ -1 +1 @@
v4.3.3.2304161855
v4.3.3.2304181958

View File

@ -286,7 +286,13 @@ func (dExt *DriverExt) TakeScreenShot(fileName ...string) (raw *bytes.Buffer, er
// saveScreenShot saves image file with file name
func (dExt *DriverExt) saveScreenShot(raw *bytes.Buffer, fileName string) (string, error) {
img, format, err := image.Decode(raw)
// notice: screenshot data is a stream, so we need to copy it to a new buffer
copiedBuffer := &bytes.Buffer{}
if _, err := copiedBuffer.Write(raw.Bytes()); err != nil {
log.Error().Err(err).Msg("copy screenshot buffer failed")
}
img, format, err := image.Decode(copiedBuffer)
if err != nil {
return "", errors.Wrap(err, "decode screenshot image failed")
}