image

package
v2.6.1 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

This package contains functions for Pi/2 step rotation of points in a 2-dimensional space.

Index

Constants

View Source
const (
	// BIT_FORMAT_SHORT_5_5_5_1 has 5 bits R, 5 bits G, 5 bits B, 1 bit alpha
	BitFormatShort5551 = iota
	// BIT_FORMAT_INT_8_8_8_8_REV has 8 bits R, 8 bits G, 8 bits B, 8 bit alpha
	BitFormatInt8888Rev
	// BIT_FORMAT_SHORT_5_6_5 has 5 bits R, 6 bits G, 5 bits
	BitFormatShort565
)
View Source
const (
	// skips image interpolation
	ScaleNot = iota
	// nearest neighbour interpolation
	ScaleNearestNeighbour
	// bilinear interpolation
	ScaleBilinear
)

Variables

View Source
var Angles = [4]Rotate{
	Angle0:   {Call: Rotate0, IsEven: false},
	Angle90:  {Call: Rotate90, IsEven: true},
	Angle180: {Call: Rotate180, IsEven: false},
	Angle270: {Call: Rotate270, IsEven: true},
}

A helper to choose appropriate rotation by its angle

Functions

func DrawRgbaImage

func DrawRgbaImage(pixFormat Format, rotationFn Rotate, scaleType int, flipV bool, w, h, packedW, bpp int, data []byte, dest *image.RGBA)

func ExampleRotate

func ExampleRotate(data []uint8, w int, h int, angle Angle) []uint8

[1 2 3 4 5 6 7 8 9] [7 4 1 8 5 2 9 6 3]

func Resize

func Resize(scaleType int, src *image.RGBA, out *image.RGBA)

func Rgb565

func Rgb565(data []byte, index int) color.RGBA

func Rgba8888

func Rgba8888(data []byte, index int) color.RGBA

func Rotate0

func Rotate0(x, y, _, _ int) (int, int)

0° or the original orientation

Example:
1 2 3    1 2 3
4 5 6 -> 4 5 6
7 8 9    7 8 9

func Rotate180

func Rotate180(x, y, w, h int) (int, int)

180° CCW

Example:
1 2 3    9 8 7
4 5 6 -> 6 5 4
7 8 9    3 2 1

func Rotate270

func Rotate270(x, y, _, h int) (int, int)

270° CCW or 90° CW

Example:
1 2 3    7 4 1
4 5 6 -> 8 5 2
7 8 9    9 6 3

func Rotate90

func Rotate90(x, y, w, _ int) (int, int)

90° CCW or 270° CW

Example:
1 2 3    3 6 9
4 5 6 -> 2 5 8
7 8 9    1 4 7

Types

type Angle

type Angle uint
const (
	Angle0 Angle = iota
	Angle90
	Angle180
	Angle270
)

type Format

type Format func(data []byte, index int) color.RGBA

type Rotate

type Rotate struct {
	Call   func(x, y, w, h int) (int, int)
	IsEven bool
}

An interface for rotation of a given point with the coordinates x, y in the matrix of w x h. Returns a pair of new coordinates x, y in the resulting matrix. Be aware that w / h values are 0 index-based and it's meant to be used with h corresponded to matrix height and y coordinate, and with w to x coordinate.

func GetRotation

func GetRotation(angle Angle) Rotate

Jump to

Keyboard shortcuts

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