exr

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2022 License: MIT Imports: 6 Imported by: 2

Documentation

Overview

Package exr contains an implementation of an OpenEXR image decoder.

Index

Constants

This section is empty.

Variables

View Source
var (
	// RGBAModel returns the color.Model for RGBAColor colors.
	RGBAModel color.Model = color.ModelFunc(rgbaModel)
)

Functions

func Decode

func Decode(in io.Reader) (image.Image, error)

Decode reads an EXR image from in and returns it as an image.Image. The type of the Image is RGBAImage.

Only a limited set of EXR image types are supported at the moment. The main restrictions are as follows, though others apply as well:

  • They have to be single-part scan line images.
  • They have to use no compression or zip compression.

func DecodeConfig

func DecodeConfig(in io.Reader) (image.Config, error)

DecodeConfig returns the color model and dimensions of an EXR image without decoding the entire image.

This function supports all version 2 EXR images.

Types

type RGBAColor

type RGBAColor struct {

	// R holds the amount of red in this color.
	R float32

	// G holds the amount of green in this color.
	G float32

	// B holds the amount of blue in this color.
	B float32

	// A holds the amount of alpha in this color.
	A float32
}

RGBAColor represents a linear EXR color that implements the color.Color interface and is composed of R, G, B, and A components.

func (RGBAColor) RGBA

func (c RGBAColor) RGBA() (r, g, b, a uint32)

RGBA returns the alpha-premultiplied red, green, blue and alpha values for the color. Each value ranges within [0, 0xffff], but is represented by a uint32 so that multiplying by a blend factor up to 0xffff will not overflow.

An alpha-premultiplied color component c has been scaled by alpha (a), so has valid values 0 <= c <= a.

Reinhard tone mapping and gamma correction are performed to convert the color into sRGB space.

type RGBAImage

type RGBAImage struct {
	// contains filtered or unexported fields
}

RGBAImage represents an EXR image that consists of R, G, B, and A components.

Even if the original image that is loaded does not contain all of the components, default ones will be assigned.

func (*RGBAImage) At

func (i *RGBAImage) At(x, y int) color.Color

At returns the color of the pixel at (x, y). At(Bounds().Min.X, Bounds().Min.Y) returns the upper-left pixel of the grid. At(Bounds().Max.X-1, Bounds().Max.Y-1) returns the lower-right one.

The returned color is of type RGBAColor which can be used to acquire the linear (float) components of the color.

func (*RGBAImage) Bounds

func (i *RGBAImage) Bounds() image.Rectangle

Bounds returns the domain for which At can return non-zero color. The bounds do not necessarily contain the point (0, 0).

func (*RGBAImage) ColorModel

func (i *RGBAImage) ColorModel() color.Model

ColorModel returns the RGBAImage's color model.

Directories

Path Synopsis
internal
exr

Jump to

Keyboard shortcuts

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