Documentation ¶
Overview ¶
Go programming helpers for common graphics and imaging needs.
Index ¶
- func GammaToLinearSpace(f float64) float64
- func Index2D(x, y, ysize int) int
- func Index3D(x, y, z, xsize, ysize int) int
- func LinearToGammaSpace(f float64) float64
- func PreprocessImage(src image.Image, dst Picture, flipY, toBgra, toLinear bool)
- func SavePngImageFile(img image.Image, filePath string) error
- type Picture
- type Rgba32
- type Rgba64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GammaToLinearSpace ¶
Converts the given value from gamma to linear color space.
func Index2D ¶
If 2 dimensions are represented in a 1-dimensional linear array, this function provides a way to return a 1D index addressing the specified 2D coordinate.
func Index3D ¶
If 3 dimensions are represented in a 1-dimensional linear array, this function provides a way to return a 1D index addressing the specified 3D coordinate.
func LinearToGammaSpace ¶
Converts the given value from linear to gamma color space.
func PreprocessImage ¶
Processes the specified `Image` and writes the result to the specified `Picture`:
If `flipY` is `true`, all pixel rows are inverted (`dst` becomes `src` vertically mirrored).
If `toBgra` is `true`, all pixels' red and blue components are swapped.
If `toLinear` is `true`, all pixels are converted from gamma/sRGB to linear space -- only use this if you're certain that `src` is not already in linear space.
`dst` and `src` may point to the same `Image` object ONLY if `flipY` is `false`.
Types ¶
type Picture ¶
type Picture interface { image.Image // Set pixel at `x, y` to the specified `Color`. Set(int, int, color.Color) }
The "missing interface" from the `image` package: `Set(x, y, color)` is implemented by most (but not all) `image` types that also implement `Image`.
func CreateLike ¶
Creates and returns a `Picture` just like `src`:
If `copyPixels` is `true`, pixels in `src` are copied to `dst`, otherwise `dst` will be an empty/black `Picture` of the exact same dimensions, color format, stride/offset/etc as `src`.
The resulting `dst` will be of the same type as `src` if `src` is an `*image.Alpha`, `*image.Alpha16`, `*image.Gray`, `*image.Gray16`, `*image.NRGBA`, `*image.NRGBA16`, or `*image.RGBA64` --- otherwise, `dst` will be an `*image.RGBA`.
type Rgba32 ¶
type Rgba32 struct { // Red component R float32 // Green component G float32 // Blue component B float32 // Alpha component A float32 }
Describes a literal color using four 32-bit floating-point numbers in RGBA order.