image2d

package
v0.0.0-...-23eb0d9 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package image2d provides classes for creating and storing 2d images.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Image2D

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

Image2D stores the dimensions, data format and it's pixel data. It can be used to manipulate single pixels and is used to upload it's data to a texture.

func Make

func Make(width, height, channels int) (Image2D, error)

Make constructs a white image of the specified width and height and number of channels.

func MakeFromData

func MakeFromData(width, height, channels int, data []uint8) (Image2D, error)

MakeFromData constructs an image of the specified width and height and the specified data.

func MakeFromFrameBuffer

func MakeFromFrameBuffer(width, height, channels int) (Image2D, error)

MakeFromFrameBuffer grabs the data from the frame buffer and copies it into an image.

func MakeFromPath

func MakeFromPath(path string) (Image2D, error)

MakeFromPath constructs the image data from the specified path. If there is no image at the specified path an error is returned instead.

func MakeFromPathFixedChannels

func MakeFromPathFixedChannels(path string, channels int) (Image2D, error)

MakeFromPathFixedChannels constructs the image data from the specified path. the second parameter fixes the number of channels of the output image to the specified number. If there is no image at the specified path an error is returned instead.

func (*Image2D) ConvertToPowerOfTwo

func (img *Image2D) ConvertToPowerOfTwo()

ConvertToPowerOfTwo subsamples an image to be quadratic and be a power of two.

func (*Image2D) FlipX

func (img *Image2D) FlipX()

FlipX changes the order of the columns by swapping the first column of a row with the last column of the same row, the second column of this row with the second last column of this row etc.

func (*Image2D) FlipY

func (img *Image2D) FlipY()

FlipY changes the order of the rows by swapping the first row with the last row, the second row with the second last row etc.

func (*Image2D) GetA

func (img *Image2D) GetA(x, y int) uint8

GetA returns the alpha value of the pixel at (x,y).

func (*Image2D) GetB

func (img *Image2D) GetB(x, y int) uint8

GetB returns the blue value of the pixel at (x,y).

func (*Image2D) GetByteDepth

func (img *Image2D) GetByteDepth() int

GetByteDepth returns the number of bytes a channel consists of.

func (*Image2D) GetChannels

func (img *Image2D) GetChannels() int

GetChannels return the number of the channels of the image.

func (*Image2D) GetData

func (img *Image2D) GetData() []uint8

GetData returns a copy of the image's data

func (*Image2D) GetDataPointer

func (img *Image2D) GetDataPointer() unsafe.Pointer

GetDataPointer returns an pointer to the beginning of the image data.

func (*Image2D) GetG

func (img *Image2D) GetG(x, y int) uint8

GetG returns the green value of the pixel at (x,y).

func (*Image2D) GetHeight

func (img *Image2D) GetHeight() int

GetHeight returns the height of the image.

func (*Image2D) GetPixelType

func (img *Image2D) GetPixelType() uint32

GetPixelType gets the data type of the pixel data.

func (*Image2D) GetR

func (img *Image2D) GetR(x, y int) uint8

GetR returns the red value of the pixel at (x,y).

func (*Image2D) GetRGB

func (img *Image2D) GetRGB(x, y int) (uint8, uint8, uint8)

GetRGB returns the RGB values of the pixel at (x,y).

func (*Image2D) GetRGBA

func (img *Image2D) GetRGBA(x, y int) (uint8, uint8, uint8, uint8)

GetRGBA returns the RGBA value of the pixel at (x,y).

func (*Image2D) GetWidth

func (img *Image2D) GetWidth() int

GetWidth returns the width of the image.

func (*Image2D) IsPowerOfTwo

func (img *Image2D) IsPowerOfTwo() bool

IsPowerOfTwo returns true if width and height are both powers or two

func (*Image2D) IsQuadratic

func (img *Image2D) IsQuadratic() bool

IsQuadratic returns true if width equals height.

func (*Image2D) SaveToPath

func (img *Image2D) SaveToPath(path string) error

SaveToPath saves the image at the specified path in the png format. The specified image path has to have the fileextension .png. An error is thrown if the path is not valid or any of the specified directories don't exist.

func (*Image2D) SetA

func (img *Image2D) SetA(x, y int, a uint8)

SetA sets the alpha value of the pixel at (x,y).

func (*Image2D) SetB

func (img *Image2D) SetB(x, y int, b uint8)

SetB sets the blue value of the pixel at (x,y).

func (*Image2D) SetG

func (img *Image2D) SetG(x, y int, g uint8)

SetG sets the green value of the pixel at (x,y).

func (*Image2D) SetR

func (img *Image2D) SetR(x, y int, r uint8)

SetR sets the red value of the pixel at (x,y).

func (*Image2D) SetRGB

func (img *Image2D) SetRGB(x, y int, r, g, b uint8)

SetRGB sets the RGB values of the pixel at (x,y).

func (*Image2D) SetRGBA

func (img *Image2D) SetRGBA(x, y int, r, g, b, a uint8)

SetRGBA sets the RGBA values of the pixel at (x,y).

func (Image2D) String

func (img Image2D) String() string

Jump to

Keyboard shortcuts

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