Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Address field to Tag struct, and Countable interface to ReadAtRea… #45

Open
wants to merge 2 commits into
base: go1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions tiff/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ type Tag struct {
// field.
ValOffset uint32

// Address hold byte offset of this tag header from the begining of the file.
Address uint64

order binary.ByteOrder
intVals []int64
floatVals []float64
Expand All @@ -116,6 +119,7 @@ type Tag struct {
func DecodeTag(r ReadAtReader, order binary.ByteOrder) (*Tag, error) {
t := new(Tag)
t.order = order
t.Address = uint64(r.Size()) - uint64(r.Len())

err := binary.Read(r, order, &t.Id)
if err != nil {
Expand Down
7 changes: 7 additions & 0 deletions tiff/tiff.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,17 @@ import (
"io/ioutil"
)

// Countable is used when count offset from the begining of bytes.
type Countable interface{
Len() int
Size() int64
}

// ReadAtReader is used when decoding Tiff tags and directories
type ReadAtReader interface {
io.Reader
io.ReaderAt
Countable
}

// Tiff provides access to a decoded tiff data structure.
Expand Down