...
Tawesoft Logo

Package ximage

import "tawesoft.co.uk/go/ximage"
Overview
Index
Subdirectories

Overview ▾

Package ximage implements Red, RG, and RGB images matching the core image interface.

Note that there are good reasons these image types aren't in the core image package. The native image types may have optimized fast-paths for many use cases.

This package is a tradeoff of these optimizations against lower memory usage. This package is intended to be used in computer graphics (e.g. OpenGL) where images are uploaded to the GPU in a specific format (such as GL_R, GL_RG, or GL_RGB) and we don't care too much about the performance of native Go image manipulation.

OpenGL® and the oval logo are trademarks or registered trademarks of Hewlett Packard Enterprise in the United States and/or other countries worldwide.

See also: ximage/xcolor (https://tawesoft.co.uk/go/ximage/xcolor)

Package Information

License: BSD-3-Clause (see LICENSE.txt)

Stable: yes

For more information, documentation, source code, examples, support, links, etc. please see https://www.tawesoft.co.uk/go and https://www.tawesoft.co.uk/go/ximage

type RG

RG is an in-memory image whose At method returns color.RG values.

type RG struct {
    // Pix holds the image's pixels, as Red values. The pixel at
    // (x, y) starts at Pix[(y-Rect.Min.Y)*Stride + (x-Rect.Min.X)*2].
    Pix []uint8
    // Stride is the Pix stride (in bytes) between vertically adjacent pixels.
    Stride int
    // Rect is the image's bounds.
    Rect image.Rectangle
}

func NewRG

func NewRG(r image.Rectangle) *RG

NewRG returns a new RG image with the given bounds.

func (*RG) At

func (p *RG) At(x, y int) color.Color

func (*RG) Bounds

func (p *RG) Bounds() image.Rectangle

func (*RG) ColorModel

func (p *RG) ColorModel() color.Model

func (*RG) Opaque

func (p *RG) Opaque() bool

Opaque scans the entire image and reports whether it is fully opaque.

func (*RG) PixOffset

func (p *RG) PixOffset(x, y int) int

PixOffset returns the index of the first element of Pix that corresponds to the pixel at (x, y).

func (*RG) RGAt

func (p *RG) RGAt(x, y int) xcolor.RG

func (*RG) Set

func (p *RG) Set(x, y int, c color.Color)

func (*RG) SetRG

func (p *RG) SetRG(x, y int, c xcolor.RG)

func (*RG) SubImage

func (p *RG) SubImage(r image.Rectangle) image.Image

SubImage returns an image representing the portion of the image p visible through r. The returned value shares pixels with the original image.

type RGB

RGB is an in-memory image whose At method returns color.RGB values.

type RGB struct {
    // Pix holds the image's pixels, as Red values. The pixel at
    // (x, y) starts at Pix[(y-Rect.Min.Y)*Stride + (x-Rect.Min.X)*2].
    Pix []uint8
    // Stride is the Pix stride (in bytes) between vertically adjacent pixels.
    Stride int
    // Rect is the image's bounds.
    Rect image.Rectangle
}

func NewRGB

func NewRGB(r image.Rectangle) *RGB

NewRGB returns a new RGB image with the given bounds.

func (*RGB) At

func (p *RGB) At(x, y int) color.Color

func (*RGB) Bounds

func (p *RGB) Bounds() image.Rectangle

func (*RGB) ColorModel

func (p *RGB) ColorModel() color.Model

func (*RGB) Opaque

func (p *RGB) Opaque() bool

Opaque scans the entire image and reports whether it is fully opaque.

func (*RGB) PixOffset

func (p *RGB) PixOffset(x, y int) int

PixOffset returns the index of the first element of Pix that corresponds to the pixel at (x, y).

func (*RGB) RGBAt

func (p *RGB) RGBAt(x, y int) xcolor.RGB

func (*RGB) Set

func (p *RGB) Set(x, y int, c color.Color)

func (*RGB) SetRGB

func (p *RGB) SetRGB(x, y int, c xcolor.RGB)

func (*RGB) SubImage

func (p *RGB) SubImage(r image.Rectangle) image.Image

SubImage returns an image representing the portion of the image p visible through r. The returned value shares pixels with the original image.

type Red

Red is an in-memory image whose At method returns color.Red values.

type Red struct {
    // Pix holds the image's pixels, as Red values. The pixel at
    // (x, y) starts at Pix[(y-Rect.Min.Y)*Stride + (x-Rect.Min.X)*1].
    Pix []uint8
    // Stride is the Pix stride (in bytes) between vertically adjacent pixels.
    Stride int
    // Rect is the image's bounds.
    Rect image.Rectangle
}

func NewRed

func NewRed(r image.Rectangle) *Red

NewRed returns a new Red image with the given bounds.

func (*Red) At

func (p *Red) At(x, y int) color.Color

func (*Red) Bounds

func (p *Red) Bounds() image.Rectangle

func (*Red) ColorModel

func (p *Red) ColorModel() color.Model

func (*Red) Opaque

func (p *Red) Opaque() bool

Opaque scans the entire image and reports whether it is fully opaque.

func (*Red) PixOffset

func (p *Red) PixOffset(x, y int) int

PixOffset returns the index of the first element of Pix that corresponds to the pixel at (x, y).

func (*Red) RedAt

func (p *Red) RedAt(x, y int) xcolor.Red

func (*Red) Set

func (p *Red) Set(x, y int, c color.Color)

func (*Red) SetRed

func (p *Red) SetRed(x, y int, c xcolor.Red)

func (*Red) SubImage

func (p *Red) SubImage(r image.Rectangle) image.Image

SubImage returns an image representing the portion of the image p visible through r. The returned value shares pixels with the original image.

Subdirectories

Name Synopsis
xcolor Package xcolor implements Red, RedGreen, and RGB color models matching the core image/color interface.