mirror of
https://github.com/xiaoqidun/ofdgo.git
synced 2026-10-29 08:46:55 +08:00
1 parent
0e423c9713
commit
7bdb03f7bd
12 files changed
+319
-68
No files matched your search
+1
-10
@@ -15,12 +15,10 @@
|
||||
package ofdgo
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
"image"
|
||||
"io"
|
||||
"math"
|
||||
)
|
||||
|
||||
@@ -127,14 +125,7 @@ func (e *Editor) addImagePage(ctx context.Context, data []byte, options ImagePag
|
||||
var decoded image.Image
|
||||
checksum := sha256.Sum256(data)
|
||||
if !verified[checksum] {
|
||||
if format == "bmp" || format == "tiff" {
|
||||
decoded, _, err = decodeImageDataContext(ctx, data)
|
||||
} else {
|
||||
decoded, _, err = image.Decode(imageInput{ReadCloser: io.NopCloser(bytes.NewReader(data)), context: ctx})
|
||||
}
|
||||
if cancelErr := ctx.Err(); cancelErr != nil {
|
||||
return 0, cancelErr
|
||||
}
|
||||
decoded, _, err = decodeImagePixelsContext(ctx, data)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user