hdrimage

package
v0.0.0-...-1c48c43 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2017 License: MIT Imports: 6 Imported by: 4

Documentation

Overview

Package hdrimage provides a float32 image implementation with a built-in divisor (for easy averaging of images), which conforms to Go's image.Image interface (by conversion to sRGB)

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Image

type Image struct {
	Pixels        [][]hdrcolour.Colour
	Width, Height int
	Divisor       int
}

Image is a stuct which will display images via its 2D colour array, wich represents the screen

func Add

func Add(a *Image, b *Image) *Image

Add returns a new image which is the sum of the given ones

func Decode

func Decode(reader io.Reader) (*Image, error)

Decode reads data in the simple traytor_hdr format and produces an image.

func FromSRGB

func FromSRGB(im image.Image) *Image

FromSRGB constructs an Image from an sRGB image

func New

func New(width, height int) *Image

New will set the screen to the given width and height

func (*Image) Add

func (im *Image) Add(other *Image)

Add adds another image to this one

Example
im1 := New(2, 2)
for j := 0; j < im1.Height; j++ {
	for i := 0; i < im1.Width; i++ {
		im1.Pixels[i][j].SetColour(4, 5, 6)
	}
}
im2 := New(2, 2)
for j := 0; j < im2.Height; j++ {
	for i := 0; i < im2.Width; i++ {
		im2.Pixels[i][j].SetColour(1, 2, 3)
	}
}
im1.Add(im2)
fmt.Printf("%s\n", im1)
Output:

{5, 7, 9}, {5, 7, 9}
{5, 7, 9}, {5, 7, 9}

func (*Image) At

func (im *Image) At(x, y int) color.Color

At returns the sRGB Colour of the pixel at [x][y (scaled by the divisor)]

Example
im := New(2, 2)
for j := 0; j < im.Height; j++ {
	for i := 0; i < im.Width; i++ {
		im.Pixels[i][j].SetColour(float32(i), float32(j), 0)
	}
}
fmt.Printf("%s\n", im.At(0, 0))
fmt.Printf("%s\n", im.At(1, 0))
fmt.Printf("%s\n", im.At(0, 1))
fmt.Printf("%s\n", im.At(1, 1))
Output:

[0, 0, 0]
[65535, 0, 0]
[0, 65535, 0]
[65535, 65535, 0]

func (*Image) AtHDR

func (im *Image) AtHDR(x, y int) *hdrcolour.Colour

AtHDR returns the Colour of the pixel at [x][y] (scaled by the divisor)

func (*Image) Bounds

func (im *Image) Bounds() image.Rectangle

Bounds returns a rectangle as big as the image

Example
im := New(640, 480)

bounds := im.Bounds()
fmt.Printf("%s\n", bounds)
Output:

(0,0)-(640,480)

func (*Image) ColorModel

func (im *Image) ColorModel() color.Model

ColorModel returns the image's color model (as used by Go's image interface)

Example
im := New(640, 480)
if im.ColorModel() == color.RGBAModel {
	fmt.Printf("Model is RGBA\n")
}
Output:

Model is RGBA

func (*Image) Encode

func (im *Image) Encode(writer io.Writer) error

Encode writes data in the simple traytor_hdr format into a writer

func (*Image) String

func (im *Image) String() string

String returns a string which is the representaton of image: {r, g, b}, ... {r, g, b}\n ...\n {r, g, b},...{r, g, b}

Example
i := New(2, 2)
fmt.Printf("%s\n", i)
Output:

{0, 0, 0}, {0, 0, 0}
{0, 0, 0}, {0, 0, 0}

Jump to

Keyboard shortcuts

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