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

feat: add (e IFDEntry) PutData to metadata module in @observerly/iris #225

Merged
merged 1 commit into from
Oct 17, 2024
Merged
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
24 changes: 24 additions & 0 deletions pkg/ifd/entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ package metadata

/*****************************************************************************************************************/

import "encoding/binary"

/*****************************************************************************************************************/

// An IFDEntry is a single entry in an Image File Directory.
// A value of type DataTypeRational is composed of two 32-bit values,
// thus data contains two uints (numerator and denominator) for a single number.
Expand All @@ -20,3 +24,23 @@ type IFDEntry struct {
}

/*****************************************************************************************************************/

func (e IFDEntry) PutData(p []byte) {
enc := binary.LittleEndian

for _, d := range e.Data {
switch e.DataType {
case DataTypeByte, DataTypeASCII:
p[0] = byte(d)
p = p[1:]
case DataTypeShort:
enc.PutUint16(p, uint16(d))
p = p[2:]
case DataTypeLong, DataTypeRational:
enc.PutUint32(p, uint32(d))
p = p[4:]
}
}
}

/*****************************************************************************************************************/
Loading