mirror of
https://github.com/simon987/fastimagehash-go.git
synced 2025-04-10 06:06:44 +00:00
bugfix
This commit is contained in:
parent
0b8019bc1e
commit
20d01e80d9
@ -11,9 +11,8 @@ for `fastimagehash-go` to compile.
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/simon987/fastimagehash-go"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
"github.com/simon987/fastimagehash-go" )
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
hash, ret := fastimagehash.PHashFile("/path/to/image.jpg", 8, 4)
|
hash, ret := fastimagehash.PHashFile("/path/to/image.jpg", 8, 4)
|
||||||
|
@ -78,27 +78,43 @@ type MultiHash struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func retHash(hash *C.uchar, hashSize int, ret C.int) (*Hash, Code) {
|
func retHash(hash *C.uchar, hashSize int, ret C.int) (*Hash, Code) {
|
||||||
goHash := C.GoBytes(unsafe.Pointer(hash), C.int(hashSize))
|
if ret == Ok {
|
||||||
C.free(unsafe.Pointer(hash))
|
goHash := C.GoBytes(unsafe.Pointer(hash), C.int(hashSize))
|
||||||
|
C.free(unsafe.Pointer(hash))
|
||||||
|
|
||||||
|
return &Hash{
|
||||||
|
Size: hashSize,
|
||||||
|
Bytes: goHash,
|
||||||
|
}, Code(ret)
|
||||||
|
}
|
||||||
|
|
||||||
return &Hash{
|
return &Hash{
|
||||||
Size: hashSize,
|
Size: hashSize,
|
||||||
Bytes: goHash,
|
Bytes: nil,
|
||||||
}, Code(ret)
|
}, Code(ret)
|
||||||
}
|
}
|
||||||
|
|
||||||
func retMultiHash(m *C.multi_hash_t, hashSize int, ret C.int) (*MultiHash, Code) {
|
func retMultiHash(m *C.multi_hash_t, hashSize int, ret C.int) (*MultiHash, Code) {
|
||||||
goPHash := C.GoBytes(unsafe.Pointer(m.phash), C.int(hashSize))
|
if ret == Ok {
|
||||||
goAHash := C.GoBytes(unsafe.Pointer(m.ahash), C.int(hashSize))
|
goPHash := C.GoBytes(unsafe.Pointer(m.phash), C.int(hashSize))
|
||||||
goDHash := C.GoBytes(unsafe.Pointer(m.dhash), C.int(hashSize))
|
goAHash := C.GoBytes(unsafe.Pointer(m.ahash), C.int(hashSize))
|
||||||
goWHash := C.GoBytes(unsafe.Pointer(m.whash), C.int(hashSize))
|
goDHash := C.GoBytes(unsafe.Pointer(m.dhash), C.int(hashSize))
|
||||||
C.multi_hash_destroy(m)
|
goWHash := C.GoBytes(unsafe.Pointer(m.whash), C.int(hashSize))
|
||||||
|
C.multi_hash_destroy(m)
|
||||||
|
|
||||||
|
return &MultiHash{
|
||||||
|
PHash: Hash{hashSize, goPHash},
|
||||||
|
AHash: Hash{hashSize, goAHash},
|
||||||
|
DHash: Hash{hashSize, goDHash},
|
||||||
|
WHash: Hash{hashSize, goWHash},
|
||||||
|
}, Code(ret)
|
||||||
|
}
|
||||||
|
|
||||||
return &MultiHash{
|
return &MultiHash{
|
||||||
PHash: Hash{hashSize, goPHash},
|
PHash: Hash{hashSize, nil},
|
||||||
AHash: Hash{hashSize, goAHash},
|
AHash: Hash{hashSize,nil },
|
||||||
DHash: Hash{hashSize, goDHash},
|
DHash: Hash{hashSize,nil },
|
||||||
WHash: Hash{hashSize, goWHash},
|
WHash: Hash{hashSize,nil },
|
||||||
}, Code(ret)
|
}, Code(ret)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user