image

Imports

Imports #

"image/color"
"bufio"
"errors"
"io"
"sync"
"sync/atomic"
"image/color"
"math/bits"
"strconv"
"image/color"
"image/color"

Constants & Variables

Black var #

Black is an opaque black uniform image.

var Black = *ast.CallExpr

ErrFormat var #

ErrFormat indicates that decoding encountered an unknown format.

var ErrFormat = *ast.CallExpr

Opaque var #

Opaque is a fully opaque uniform image.

var Opaque = *ast.CallExpr

Transparent var #

Transparent is a fully transparent uniform image.

var Transparent = *ast.CallExpr

White var #

White is an opaque white uniform image.

var White = *ast.CallExpr

YCbCrSubsampleRatio410 const #

const YCbCrSubsampleRatio410

YCbCrSubsampleRatio411 const #

const YCbCrSubsampleRatio411

YCbCrSubsampleRatio420 const #

const YCbCrSubsampleRatio420

YCbCrSubsampleRatio422 const #

const YCbCrSubsampleRatio422

YCbCrSubsampleRatio440 const #

const YCbCrSubsampleRatio440

YCbCrSubsampleRatio444 const #

const YCbCrSubsampleRatio444 YCbCrSubsampleRatio = iota

ZP var #

ZP is the zero [Point]. Deprecated: Use a literal [image.Point] instead.

var ZP Point

ZR var #

ZR is the zero [Rectangle]. Deprecated: Use a literal [image.Rectangle] instead.

var ZR Rectangle

atomicFormats var #

Formats is the list of registered formats.

var atomicFormats atomic.Value

formatsMu var #

Formats is the list of registered formats.

var formatsMu sync.Mutex

Type Aliases

YCbCrSubsampleRatio type #

YCbCrSubsampleRatio is the chroma subsample ratio used in a YCbCr image.

type YCbCrSubsampleRatio int

Interfaces

Image interface #

Image is a finite rectangular grid of [color.Color] values taken from a color model.

type Image interface {
ColorModel() color.Model
Bounds() Rectangle
At(x int, y int) color.Color
}

PalettedImage interface #

PalettedImage is an image whose colors may come from a limited palette. If m is a PalettedImage and m.ColorModel() returns a [color.Palette] p, then m.At(x, y) should be equivalent to p[m.ColorIndexAt(x, y)]. If m's color model is not a color.Palette, then ColorIndexAt's behavior is undefined.

type PalettedImage interface {
ColorIndexAt(x int, y int) uint8
Image
}

RGBA64Image interface #

RGBA64Image is an [Image] whose pixels can be converted directly to a color.RGBA64.

type RGBA64Image interface {
RGBA64At(x int, y int) color.RGBA64
Image
}

reader interface #

A reader is an io.Reader that can also peek ahead.

type reader interface {
io.Reader
Peek(int) ([]byte, error)
}

Structs

Alpha struct #

Alpha is an in-memory image whose At method returns [color.Alpha] values.

type Alpha struct {
Pix []uint8
Stride int
Rect Rectangle
}

Alpha16 struct #

Alpha16 is an in-memory image whose At method returns [color.Alpha16] values.

type Alpha16 struct {
Pix []uint8
Stride int
Rect Rectangle
}

CMYK struct #

CMYK is an in-memory image whose At method returns [color.CMYK] values.

type CMYK struct {
Pix []uint8
Stride int
Rect Rectangle
}

Config struct #

Config holds an image's color model and dimensions.

type Config struct {
ColorModel color.Model
Width int
Height int
}

Gray struct #

Gray is an in-memory image whose At method returns [color.Gray] values.

type Gray struct {
Pix []uint8
Stride int
Rect Rectangle
}

Gray16 struct #

Gray16 is an in-memory image whose At method returns [color.Gray16] values.

type Gray16 struct {
Pix []uint8
Stride int
Rect Rectangle
}

NRGBA struct #

NRGBA is an in-memory image whose At method returns [color.NRGBA] values.

type NRGBA struct {
Pix []uint8
Stride int
Rect Rectangle
}

NRGBA64 struct #

NRGBA64 is an in-memory image whose At method returns [color.NRGBA64] values.

type NRGBA64 struct {
Pix []uint8
Stride int
Rect Rectangle
}

NYCbCrA struct #

NYCbCrA is an in-memory image of non-alpha-premultiplied Y'CbCr-with-alpha colors. A and AStride are analogous to the Y and YStride fields of the embedded YCbCr.

type NYCbCrA struct {
YCbCr
A []uint8
AStride int
}

Paletted struct #

Paletted is an in-memory image of uint8 indices into a given palette.

type Paletted struct {
Pix []uint8
Stride int
Rect Rectangle
Palette color.Palette
}

Point struct #

A Point is an X, Y coordinate pair. The axes increase right and down.

type Point struct {
X int
Y int
}

RGBA struct #

RGBA is an in-memory image whose At method returns [color.RGBA] values.

type RGBA struct {
Pix []uint8
Stride int
Rect Rectangle
}

RGBA64 struct #

RGBA64 is an in-memory image whose At method returns [color.RGBA64] values.

type RGBA64 struct {
Pix []uint8
Stride int
Rect Rectangle
}

Rectangle struct #

A Rectangle contains the points with Min.X <= X < Max.X, Min.Y <= Y < Max.Y. It is well-formed if Min.X <= Max.X and likewise for Y. Points are always well-formed. A rectangle's methods always return well-formed outputs for well-formed inputs. A Rectangle is also an [Image] whose bounds are the rectangle itself. At returns color.Opaque for points in the rectangle and color.Transparent otherwise.

type Rectangle struct {
Min Point
Max Point
}

Uniform struct #

Uniform is an infinite-sized [Image] of uniform color. It implements the [color.Color], [color.Model], and [Image] interfaces.

type Uniform struct {
C color.Color
}

YCbCr struct #

YCbCr is an in-memory image of Y'CbCr colors. There is one Y sample per pixel, but each Cb and Cr sample can span one or more pixels. YStride is the Y slice index delta between vertically adjacent pixels. CStride is the Cb and Cr slice index delta between vertically adjacent pixels that map to separate chroma samples. It is not an absolute requirement, but YStride and len(Y) are typically multiples of 8, and: For 4:4:4, CStride == YStride/1 && len(Cb) == len(Cr) == len(Y)/1. For 4:2:2, CStride == YStride/2 && len(Cb) == len(Cr) == len(Y)/2. For 4:2:0, CStride == YStride/2 && len(Cb) == len(Cr) == len(Y)/4. For 4:4:0, CStride == YStride/1 && len(Cb) == len(Cr) == len(Y)/2. For 4:1:1, CStride == YStride/4 && len(Cb) == len(Cr) == len(Y)/4. For 4:1:0, CStride == YStride/4 && len(Cb) == len(Cr) == len(Y)/8.

type YCbCr struct {
Y []uint8
Cb []uint8
Cr []uint8
YStride int
CStride int
SubsampleRatio YCbCrSubsampleRatio
Rect Rectangle
}

format struct #

A format holds an image format's name, magic header and how to decode it.

type format struct {
name string
magic string
decode func(io.Reader) (Image, error)
decodeConfig func(io.Reader) (Config, error)
}

Functions

AOffset method #

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

func (p *NYCbCrA) AOffset(x int, y int) int

Add method #

Add returns the vector p+q.

func (p Point) Add(q Point) Point

Add method #

Add returns the rectangle r translated by p.

func (r Rectangle) Add(p Point) Rectangle

Alpha16At method #

func (p *Alpha16) Alpha16At(x int, y int) color.Alpha16

AlphaAt method #

func (p *Alpha) AlphaAt(x int, y int) color.Alpha

At method #

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

At method #

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

At method #

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

At method #

At implements the [Image] interface.

func (r Rectangle) At(x int, y int) color.Color

At method #

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

At method #

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

At method #

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

At method #

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

At method #

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

At method #

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

At method #

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

At method #

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

At method #

func (c *Uniform) At(x int, y int) color.Color

At method #

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

Bounds method #

func (p *Alpha16) Bounds() Rectangle

Bounds method #

func (p *CMYK) Bounds() Rectangle

Bounds method #

func (p *RGBA) Bounds() Rectangle

Bounds method #

func (p *Alpha) Bounds() Rectangle

Bounds method #

func (p *Paletted) Bounds() Rectangle

Bounds method #

func (p *YCbCr) Bounds() Rectangle

Bounds method #

Bounds implements the [Image] interface.

func (r Rectangle) Bounds() Rectangle

Bounds method #

func (p *NRGBA64) Bounds() Rectangle

Bounds method #

func (p *NRGBA) Bounds() Rectangle

Bounds method #

func (p *Gray16) Bounds() Rectangle

Bounds method #

func (p *RGBA64) Bounds() Rectangle

Bounds method #

func (p *Gray) Bounds() Rectangle

Bounds method #

func (c *Uniform) Bounds() Rectangle

CMYKAt method #

func (p *CMYK) CMYKAt(x int, y int) color.CMYK

COffset method #

COffset returns the index of the first element of Cb or Cr that corresponds to the pixel at (x, y).

func (p *YCbCr) COffset(x int, y int) int

Canon method #

Canon returns the canonical version of r. The returned rectangle has minimum and maximum coordinates swapped if necessary so that it is well-formed.

func (r Rectangle) Canon() Rectangle

ColorIndexAt method #

func (p *Paletted) ColorIndexAt(x int, y int) uint8

ColorModel method #

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

ColorModel method #

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

ColorModel method #

func (c *Uniform) ColorModel() color.Model

ColorModel method #

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

ColorModel method #

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

ColorModel method #

ColorModel implements the [Image] interface.

func (r Rectangle) ColorModel() color.Model

ColorModel method #

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

ColorModel method #

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

ColorModel method #

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

ColorModel method #

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

ColorModel method #

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

ColorModel method #

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

ColorModel method #

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

ColorModel method #

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

Convert method #

func (c *Uniform) Convert(color.Color) color.Color

Decode function #

Decode decodes an image that has been encoded in a registered format. The string returned is the format name used during format registration. Format registration is typically done by an init function in the codec- specific package.

func Decode(r io.Reader) (Image, string, error)

DecodeConfig function #

DecodeConfig decodes the color model and dimensions of an image that has been encoded in a registered format. The string returned is the format name used during format registration. Format registration is typically done by an init function in the codec-specific package.

func DecodeConfig(r io.Reader) (Config, string, error)

Div method #

Div returns the vector p/k.

func (p Point) Div(k int) Point

Dx method #

Dx returns r's width.

func (r Rectangle) Dx() int

Dy method #

Dy returns r's height.

func (r Rectangle) Dy() int

Empty method #

Empty reports whether the rectangle contains no points.

func (r Rectangle) Empty() bool

Eq method #

Eq reports whether p and q are equal.

func (p Point) Eq(q Point) bool

Eq method #

Eq reports whether r and s contain the same set of points. All empty rectangles are considered equal.

func (r Rectangle) Eq(s Rectangle) bool

Gray16At method #

func (p *Gray16) Gray16At(x int, y int) color.Gray16

GrayAt method #

func (p *Gray) GrayAt(x int, y int) color.Gray

In method #

In reports whether every point in r is in s.

func (r Rectangle) In(s Rectangle) bool

In method #

In reports whether p is in r.

func (p Point) In(r Rectangle) bool

Inset method #

Inset returns the rectangle r inset by n, which may be negative. If either of r's dimensions is less than 2*n then an empty rectangle near the center of r will be returned.

func (r Rectangle) Inset(n int) Rectangle

Intersect method #

Intersect returns the largest rectangle contained by both r and s. If the two rectangles do not overlap then the zero rectangle will be returned.

func (r Rectangle) Intersect(s Rectangle) Rectangle

Mod method #

Mod returns the point q in r such that p.X-q.X is a multiple of r's width and p.Y-q.Y is a multiple of r's height.

func (p Point) Mod(r Rectangle) Point

Mul method #

Mul returns the vector p*k.

func (p Point) Mul(k int) Point

NRGBA64At method #

func (p *NRGBA64) NRGBA64At(x int, y int) color.NRGBA64

NRGBAAt method #

func (p *NRGBA) NRGBAAt(x int, y int) color.NRGBA

NYCbCrAAt method #

func (p *NYCbCrA) NYCbCrAAt(x int, y int) color.NYCbCrA

NewAlpha function #

NewAlpha returns a new [Alpha] image with the given bounds.

func NewAlpha(r Rectangle) *Alpha

NewAlpha16 function #

NewAlpha16 returns a new [Alpha16] image with the given bounds.

func NewAlpha16(r Rectangle) *Alpha16

NewCMYK function #

NewCMYK returns a new CMYK image with the given bounds.

func NewCMYK(r Rectangle) *CMYK

NewGray function #

NewGray returns a new [Gray] image with the given bounds.

func NewGray(r Rectangle) *Gray

NewGray16 function #

NewGray16 returns a new [Gray16] image with the given bounds.

func NewGray16(r Rectangle) *Gray16

NewNRGBA function #

NewNRGBA returns a new [NRGBA] image with the given bounds.

func NewNRGBA(r Rectangle) *NRGBA

NewNRGBA64 function #

NewNRGBA64 returns a new [NRGBA64] image with the given bounds.

func NewNRGBA64(r Rectangle) *NRGBA64

NewNYCbCrA function #

NewNYCbCrA returns a new [NYCbCrA] image with the given bounds and subsample ratio.

func NewNYCbCrA(r Rectangle, subsampleRatio YCbCrSubsampleRatio) *NYCbCrA

NewPaletted function #

NewPaletted returns a new [Paletted] image with the given width, height and palette.

func NewPaletted(r Rectangle, p color.Palette) *Paletted

NewRGBA function #

NewRGBA returns a new [RGBA] image with the given bounds.

func NewRGBA(r Rectangle) *RGBA

NewRGBA64 function #

NewRGBA64 returns a new [RGBA64] image with the given bounds.

func NewRGBA64(r Rectangle) *RGBA64

NewUniform function #

NewUniform returns a new [Uniform] image of the given color.

func NewUniform(c color.Color) *Uniform

NewYCbCr function #

NewYCbCr returns a new YCbCr image with the given bounds and subsample ratio.

func NewYCbCr(r Rectangle, subsampleRatio YCbCrSubsampleRatio) *YCbCr

Opaque method #

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

func (p *NYCbCrA) Opaque() bool

Opaque method #

func (p *YCbCr) Opaque() bool

Opaque method #

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

func (p *RGBA64) Opaque() bool

Opaque method #

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

func (c *Uniform) Opaque() bool

Opaque method #

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

func (p *NRGBA64) Opaque() bool

Opaque method #

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

func (p *Gray) Opaque() bool

Opaque method #

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

func (p *NRGBA) Opaque() bool

Opaque method #

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

func (p *Paletted) Opaque() bool

Opaque method #

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

func (p *Alpha) Opaque() bool

Opaque method #

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

func (p *RGBA) Opaque() bool

Opaque method #

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

func (p *CMYK) Opaque() bool

Opaque method #

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

func (p *Gray16) Opaque() bool

Opaque method #

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

func (p *Alpha16) Opaque() bool

Overlaps method #

Overlaps reports whether r and s have a non-empty intersection.

func (r Rectangle) Overlaps(s Rectangle) bool

PixOffset method #

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

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

PixOffset method #

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

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

PixOffset method #

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

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

PixOffset method #

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

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

PixOffset method #

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

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

PixOffset method #

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

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

PixOffset method #

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

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

PixOffset method #

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

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

PixOffset method #

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

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

PixOffset method #

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

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

Pt function #

Pt is shorthand for [Point]{X, Y}.

func Pt(X int, Y int) Point

RGBA method #

func (c *Uniform) RGBA() (r uint32, g uint32, b uint32, a uint32)

RGBA64At method #

func (p *YCbCr) RGBA64At(x int, y int) color.RGBA64

RGBA64At method #

func (p *CMYK) RGBA64At(x int, y int) color.RGBA64

RGBA64At method #

func (p *Gray16) RGBA64At(x int, y int) color.RGBA64

RGBA64At method #

func (p *NRGBA64) RGBA64At(x int, y int) color.RGBA64

RGBA64At method #

func (p *RGBA64) RGBA64At(x int, y int) color.RGBA64

RGBA64At method #

func (p *RGBA) RGBA64At(x int, y int) color.RGBA64

RGBA64At method #

func (p *Alpha) RGBA64At(x int, y int) color.RGBA64

RGBA64At method #

func (p *NYCbCrA) RGBA64At(x int, y int) color.RGBA64

RGBA64At method #

func (p *NRGBA) RGBA64At(x int, y int) color.RGBA64

RGBA64At method #

func (p *Alpha16) RGBA64At(x int, y int) color.RGBA64

RGBA64At method #

func (p *Gray) RGBA64At(x int, y int) color.RGBA64

RGBA64At method #

func (p *Paletted) RGBA64At(x int, y int) color.RGBA64

RGBA64At method #

func (c *Uniform) RGBA64At(x int, y int) color.RGBA64

RGBA64At method #

RGBA64At implements the [RGBA64Image] interface.

func (r Rectangle) RGBA64At(x int, y int) color.RGBA64

RGBAAt method #

func (p *RGBA) RGBAAt(x int, y int) color.RGBA

Rect function #

Rect is shorthand for [Rectangle]{Pt(x0, y0), [Pt](x1, y1)}. The returned rectangle has minimum and maximum coordinates swapped if necessary so that it is well-formed.

func Rect(x0 int, y0 int, x1 int, y1 int) Rectangle

RegisterFormat function #

RegisterFormat registers an image format for use by [Decode]. Name is the name of the format, like "jpeg" or "png". Magic is the magic prefix that identifies the format's encoding. The magic string can contain "?" wildcards that each match any one byte. [Decode] is the function that decodes the encoded image. [DecodeConfig] is the function that decodes just its configuration.

func RegisterFormat(name string, magic string, decode func(io.Reader) (Image, error), decodeConfig func(io.Reader) (Config, error))

Set method #

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

Set method #

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

Set method #

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

Set method #

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

Set method #

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

Set method #

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

Set method #

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

Set method #

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

Set method #

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

Set method #

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

SetAlpha method #

func (p *Alpha) SetAlpha(x int, y int, c color.Alpha)

SetAlpha16 method #

func (p *Alpha16) SetAlpha16(x int, y int, c color.Alpha16)

SetCMYK method #

func (p *CMYK) SetCMYK(x int, y int, c color.CMYK)

SetColorIndex method #

func (p *Paletted) SetColorIndex(x int, y int, index uint8)

SetGray method #

func (p *Gray) SetGray(x int, y int, c color.Gray)

SetGray16 method #

func (p *Gray16) SetGray16(x int, y int, c color.Gray16)

SetNRGBA method #

func (p *NRGBA) SetNRGBA(x int, y int, c color.NRGBA)

SetNRGBA64 method #

func (p *NRGBA64) SetNRGBA64(x int, y int, c color.NRGBA64)

SetRGBA method #

func (p *RGBA) SetRGBA(x int, y int, c color.RGBA)

SetRGBA64 method #

func (p *NRGBA64) SetRGBA64(x int, y int, c color.RGBA64)

SetRGBA64 method #

func (p *CMYK) SetRGBA64(x int, y int, c color.RGBA64)

SetRGBA64 method #

func (p *Alpha16) SetRGBA64(x int, y int, c color.RGBA64)

SetRGBA64 method #

func (p *NRGBA) SetRGBA64(x int, y int, c color.RGBA64)

SetRGBA64 method #

func (p *RGBA64) SetRGBA64(x int, y int, c color.RGBA64)

SetRGBA64 method #

func (p *Alpha) SetRGBA64(x int, y int, c color.RGBA64)

SetRGBA64 method #

func (p *Paletted) SetRGBA64(x int, y int, c color.RGBA64)

SetRGBA64 method #

func (p *RGBA) SetRGBA64(x int, y int, c color.RGBA64)

SetRGBA64 method #

func (p *Gray) SetRGBA64(x int, y int, c color.RGBA64)

SetRGBA64 method #

func (p *Gray16) SetRGBA64(x int, y int, c color.RGBA64)

Size method #

Size returns r's width and height.

func (r Rectangle) Size() Point

String method #

func (s YCbCrSubsampleRatio) String() string

String method #

String returns a string representation of p like "(3,4)".

func (p Point) String() string

String method #

String returns a string representation of r like "(3,4)-(6,5)".

func (r Rectangle) String() string

Sub method #

Sub returns the rectangle r translated by -p.

func (r Rectangle) Sub(p Point) Rectangle

Sub method #

Sub returns the vector p-q.

func (p Point) Sub(q Point) Point

SubImage method #

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

func (p *Alpha) SubImage(r Rectangle) Image

SubImage method #

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

func (p *Paletted) SubImage(r Rectangle) Image

SubImage method #

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

func (p *RGBA64) SubImage(r Rectangle) Image

SubImage method #

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

func (p *Gray16) SubImage(r Rectangle) Image

SubImage method #

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

func (p *RGBA) SubImage(r Rectangle) Image

SubImage method #

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

func (p *NRGBA) SubImage(r Rectangle) Image

SubImage method #

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

func (p *Alpha16) SubImage(r Rectangle) Image

SubImage method #

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

func (p *YCbCr) SubImage(r Rectangle) Image

SubImage method #

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

func (p *CMYK) SubImage(r Rectangle) Image

SubImage method #

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

func (p *Gray) SubImage(r Rectangle) Image

SubImage method #

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

func (p *NYCbCrA) SubImage(r Rectangle) Image

SubImage method #

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

func (p *NRGBA64) SubImage(r Rectangle) Image

Union method #

Union returns the smallest rectangle that contains both r and s.

func (r Rectangle) Union(s Rectangle) Rectangle

YCbCrAt method #

func (p *YCbCr) YCbCrAt(x int, y int) color.YCbCr

YOffset method #

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

func (p *YCbCr) YOffset(x int, y int) int

add2NonNeg function #

add2NonNeg returns (x + y), unless at least one argument is negative or if the computation overflows the int type, in which case it returns -1.

func add2NonNeg(x int, y int) int

asReader function #

asReader converts an io.Reader to a reader.

func asReader(r io.Reader) reader

match function #

match reports whether magic matches b. Magic may contain "?" wildcards.

func match(magic string, b []byte) bool

mul3NonNeg function #

mul3NonNeg returns (x * y * z), unless at least one argument is negative or if the computation overflows the int type, in which case it returns -1.

func mul3NonNeg(x int, y int, z int) int

pixelBufferLength function #

pixelBufferLength returns the length of the []uint8 typed Pix slice field for the NewXxx functions. Conceptually, this is just (bpp * width * height), but this function panics if at least one of those is negative or if the computation would overflow the int type. This panics instead of returning an error because of backwards compatibility. The NewXxx functions do not return an error.

func pixelBufferLength(bytesPerPixel int, r Rectangle, imageTypeName string) int

sniff function #

sniff determines the format of r's data.

func sniff(r reader) format

yCbCrSize function #

func yCbCrSize(r Rectangle, subsampleRatio YCbCrSubsampleRatio) (w int, h int, cw int, ch int)

Generated with Arrow