exr

package
v0.0.0-...-6f71fe9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2024 License: Apache-2.0, MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Extension = "exr"
)
View Source
const (
	SupportedVersion = 2
)

Variables

View Source
var (
	MagicSequence = [4]byte{0x76, 0x2F, 0x31, 0x01}
)

Functions

func AppendNullTerminatedString

func AppendNullTerminatedString[T ~string](b []byte, s T) []byte

func ChunkCount

func ChunkCount(dataWindow Box2i, compression Compression) int

func Read

func Read(in io.Reader, data any) error

func ReadAttributeName

func ReadAttributeName(in io.Reader, target *AttributeName) error

func ReadAttributeType

func ReadAttributeType(in io.Reader, target *AttributeType) error

func ReadBox2i

func ReadBox2i(in io.Reader, target *Box2i) error

func ReadChannelList

func ReadChannelList(in io.Reader, target *ChannelList) error

func ReadCompression

func ReadCompression(in io.Reader, target *Compression) error

func ReadHeader

func ReadHeader(in io.Reader, target *Header) error

func ReadLineOrder

func ReadLineOrder(in io.Reader, target *LineOrder) error

func ReadMagic

func ReadMagic(in io.Reader, target *Magic) error

func ReadNullTerminatedString

func ReadNullTerminatedString[T ~string](in io.Reader, target *T) error

func ReadOffsets

func ReadOffsets(in io.Reader, chunkCount int) error

func ReadScanLineBlock

func ReadScanLineBlock(in io.Reader, dataWindow Box2i, compression Compression, decompressor Decompressor, dataChannels []PixelData) error

func ReadVersion

func ReadVersion(in io.Reader, target *Version) error

func Write

func Write(w io.Writer, data any) error

func WriteAttribute

func WriteAttribute(w io.Writer, n AttributeName, t AttributeType, a any) error

func WriteAttributeBytes

func WriteAttributeBytes(w io.Writer, n AttributeName, t AttributeType, s int32, b []byte) error

func WriteAttributeHeader

func WriteAttributeHeader(w io.Writer, n AttributeName, t AttributeType, s int32) error

WriteAttributeHeader writes an attribute minus its data. It's used for when the size is known but the data is not available as a single []byte

func WriteMagic

func WriteMagic(w io.Writer) error

func WriteNullTerminatedString

func WriteNullTerminatedString[T ~string](w io.Writer, s T) error

Types

type AttributeName

type AttributeName string
const (
	AttributeNameChannels           AttributeName = "channels"
	AttributeNameCompression        AttributeName = "compression"
	AttributeNameDataWindow         AttributeName = "dataWindow"
	AttributeNameDisplayWindow      AttributeName = "displayWindow"
	AttributeNameLineOrder          AttributeName = "lineOrder"
	AttributeNamePixelAspectRatio   AttributeName = "pixelAspectRatio"
	AttributeNameScreenWindowCenter AttributeName = "screenWindowCenter"
	AttributeNameScreenWindowWidth  AttributeName = "screenWindowWidth"
)

type AttributeType

type AttributeType string
const (
	AttributeTypeChannelList AttributeType = "chlist"
	AttributeTypeCompression AttributeType = "compression"
	AttributeTypeBox2i       AttributeType = "box2i"
	AttributeTypeLineOrder   AttributeType = "lineOrder"
	AttributeTypeFloat       AttributeType = "float"
	AttributeTypeV2f         AttributeType = "v2f"
)

type Box2i

type Box2i struct {
	XMin int32
	YMin int32
	XMax int32
	YMax int32
}

func Box2iFromRect

func Box2iFromRect(r image.Rectangle) Box2i

func (Box2i) Bytes

func (b Box2i) Bytes() []byte

func (Box2i) Contains

func (b Box2i) Contains(other Box2i) bool

func (Box2i) Height

func (b Box2i) Height() int32

func (Box2i) Width

func (b Box2i) Width() int32

type BytesAttribute

type BytesAttribute interface {
	Bytes() []byte
}

type Channel

type Channel struct {
	Name      string
	PixelType PixelType
	Linear    bool
	XSampling int32
	YSampling int32
}

type ChannelList

type ChannelList []Channel

func (ChannelList) Bytes

func (l ChannelList) Bytes() []byte

type Compression

type Compression uint8
const (
	CompressionNone  Compression = 0
	CompressionRLE   Compression = 1
	CompressionZIPS  Compression = 2
	CompressionZIP   Compression = 3
	CompressionPIZ   Compression = 4
	CompressionPXR24 Compression = 5
	CompressionB44   Compression = 6
	CompressionB44A  Compression = 7
)

func (Compression) Bytes

func (c Compression) Bytes() []byte

func (Compression) LineCount

func (c Compression) LineCount() int

func (Compression) String

func (c Compression) String() string

type Compressor

type Compressor interface {
	Compress(src []byte) ([]byte, error)
}

func NewNopCompressor

func NewNopCompressor() Compressor

func NewZipCompressor

func NewZipCompressor() Compressor

type Decompressor

type Decompressor interface {
	Decompress(src *bytes.Buffer) (*bytes.Buffer, error)
}

func NewNopDecompressor

func NewNopDecompressor() Decompressor

func NewZipDecompressor

func NewZipDecompressor() Decompressor

type Flag

type Flag int32
const (
	FlagSingleTile Flag = 1 << 8  // one at 9-th bit in version
	FlagLongName   Flag = 1 << 9  // one at 10-th bit in version
	FlagNonImage   Flag = 1 << 10 // one at 11-th bit in version
	FlagMultipart  Flag = 1 << 11 // one at 12-th bit in version
)
type Header struct {
	Channels      ChannelList
	Compression   Compression
	DataWindow    Box2i
	DisplayWindow Box2i
	LineOrder     LineOrder
}

type LineOrder

type LineOrder uint8
const (
	LineOrderIncreasingY LineOrder = 0
	LineOrderDecreasingY LineOrder = 1
	LineOrderRandomY     LineOrder = 2
)

func (LineOrder) Bytes

func (o LineOrder) Bytes() []byte

func (LineOrder) String

func (o LineOrder) String() string

type Magic

type Magic [4]byte

func (Magic) IsCorrect

func (m Magic) IsCorrect() bool

type PixelData

type PixelData interface {
	LineSize() int32
	ReadLine(in io.Reader, y int32) error
	WriteLine(w io.Writer, y int32) error
	Float32(x, y int) float32
	Set(x, y int, v float32)
}

func NewFloat16PixelData

func NewFloat16PixelData(window Box2i, xSampling, ySampling int32) PixelData

func NewFloat32PixelData

func NewFloat32PixelData(window Box2i, xSampling, ySampling int32) PixelData

func NewNopPixelData

func NewNopPixelData(value float32) PixelData

func NewUint32PixelData

func NewUint32PixelData(window Box2i, xSampling, ySampling int32) PixelData

type PixelType

type PixelType int32
const (
	PixelTypeUint  PixelType = 0
	PixelTypeHalf  PixelType = 1
	PixelTypeFloat PixelType = 2
)

func (PixelType) String

func (t PixelType) String() string

type V2F

type V2F struct {
	X, Y float32
}

func (V2F) Bytes

func (v V2F) Bytes() []byte

type Version

type Version int32

func (Version) HasFlag

func (v Version) HasFlag(flag Flag) bool

func (Version) Number

func (v Version) Number() int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL