skia2/site/user/api/SkImageInfo_Reference.md
Cary Clark 2dc84ad3ef working on global enum and image info
Added global enum support. That exposed one
big hole in bookmaker: The topic overview
should not be in the class or struct if
the topic includes multiple objects, which
is the case for SkImageInfo and enums like
SkColorType.

This straightens that out, and then used that
knowledge to strengthen the topics in
SkRect as a test. Now SkRect has more
groups of methods, and can expose and link
to sets of methods with the same name.

This work also is getting ready for tightening
SeeAlso data, to be checked as part of the
bots' tasks soon.

Also, remove links from markup for lowercase
method names unless the reference has
trailing parentheses.

TBR=caryclark@google.com
Docs-Preview: https://skia.org/?cl=98782
Bug: skia:6898
Change-Id: I35419c9789da17e272047bf7b9c95b1cf44bb7fe
Reviewed-on: https://skia-review.googlesource.com/98782
Commit-Queue: Cary Clark <caryclark@google.com>
Reviewed-by: Cary Clark <caryclark@skia.org>
Reviewed-by: Cary Clark <caryclark@google.com>
2018-01-26 18:22:10 +00:00

34 KiB

SkImageInfo Reference

Image Info

Overview

Subtopics

name description
Constants enum and enum class, const values
Constructors functions that construct ImageInfo
Member Functions static functions and member methods
Operators operator overloading methods

Constants

name description
Alpha Type encoding for pixel transparency
Color Type encoding for pixel color components
SkDestinationSurfaceColorMode
SkYUVColorSpace

Alpha Type

Enum SkAlphaType

enum SkAlphaType {
kUnknown SkAlphaType,
kOpaque SkAlphaType,
kPremul SkAlphaType,
kUnpremul SkAlphaType,
kLastEnum_SkAlphaType = kUnpremul SkAlphaType,
};

Describes how to interpret the alpha component of a pixel.

Constants

kUnknown_SkAlphaType 0
kOpaque_SkAlphaType 1All pixels are stored as opaque.
kPremul_SkAlphaType 2All pixels have their alpha premultiplied in their color components. This is the natural format for the rendering target pixels.
kUnpremul_SkAlphaType 3All pixels have their color components stored without any regard to the alpha. e.g. this is the default configuration for PNG images. kUnpremul SkAlphaType is supported only for input images. Rendering cannot generate this on output.

Example

See Also

incomplete

Color Type

Native Color Type

Enum SkColorType

enum SkColorType {
kUnknown SkColorType,
kAlpha 8 SkColorType,
kRGB 565 SkColorType,
kARGB 4444 SkColorType,
kRGBA 8888 SkColorType,
kBGRA 8888 SkColorType,
kGray 8 SkColorType,
kRGBA F16 SkColorType,
kLastEnum_SkColorType = kRGBA F16 SkColorType,
kN32 SkColorType = kBGRA 8888 SkColorType,
kN32 SkColorType = kRGBA 8888 SkColorType,
};

Describes how to interpret the components of a pixel. kN32 SkColorType is an alias for whichever 32 bit Color ARGB format is the "" form for skia's blitters. Use this if you don't have a swizzle preference for 32 bit pixels.

Constants

kUnknown_SkColorType 0
kAlpha_8_SkColorType 1
kRGB_565_SkColorType 2
kARGB_4444_SkColorType 3
kRGBA_8888_SkColorType 4
kBGRA_8888_SkColorType 5
kGray_8_SkColorType 6
kRGBA_F16_SkColorType 7
kN32_SkColorType 4

Example

See Also

incomplete

Enum SkYUVColorSpace

enum SkYUVColorSpace {
kJPEG SkYUVColorSpace,
kRec601 SkYUVColorSpace,
kRec709 SkYUVColorSpace,
kLastEnum_SkYUVColorSpace = kRec709 SkYUVColorSpace,
};

Describes the color space a YUV pixel.

Constants

kJPEG_SkYUVColorSpace 0Standard JPEG color space.
kRec601_SkYUVColorSpace 1SDTV standard Rec. 601 color space. Uses "studio swing" [16, 235] color range. See http://en.wikipedia.org/wiki/Rec._601 for details.
kRec709_SkYUVColorSpace 2HDTV standard Rec. 709 color space. Uses "studio swing" [16, 235] color range. See http://en.wikipedia.org/wiki/Rec._709 for details.

Example

See Also

incomplete

Enum SkDestinationSurfaceColorMode

enum class SkDestinationSurfaceColorMode {
kLegacy,
kGammaAndColorSpaceAware,
};

Constants

SkDestinationSurfaceColorMode::kLegacy 0
SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware 1

Example

See Also

incomplete

Struct SkImageInfo

Describe an image's dimensions and pixel type. Used for both src images and render-targets (surfaces).

Operators

name description
bool operator!=(const SkImageInfo& other) const
bool operator==(const SkImageInfo& other) const

Member Functions

name description
ByteSizeOverflowed
Make creates Image Info from dimensions, Color Type, Alpha Type, Color Space
MakeA8 creates Image Info with kAlpha 8 SkColorType, kPremul SkAlphaType
MakeN32 creates Image Info with Native Color Type
MakeN32Premul creates Image Info with Native Color Type, kPremul SkAlphaType
MakeS32 creates Image Info with Native Color Type, sRGB Color Space
MakeUnknown creates Image Info with kUnknown SkColorType, kUnknown SkAlphaType
alphaType
bounds
bytesPerPixel
colorSpace
colorType
computeByteSize
computeMinByteSize
computeOffset
dimensions
flatten
gammaCloseToSRGB
height
isEmpty
isOpaque
makeAlphaType creates Image Info with changed Alpha Type
makeColorSpace creates Image Info with changed Color Space
makeColorType creates Image Info with changed Color Type
makeWH creates Image Info with changed dimensions
minRowBytes
minRowBytes64
refColorSpace
reset
shiftPerPixel
unflatten
validRowBytes
validate
width

Constructors

name description
Make creates Image Info from dimensions, Color Type, Alpha Type, Color Space
MakeA8 creates Image Info with kAlpha 8 SkColorType, kPremul SkAlphaType
MakeN32 creates Image Info with Native Color Type
MakeN32Premul creates Image Info with Native Color Type, kPremul SkAlphaType
MakeS32 creates Image Info with Native Color Type, sRGB Color Space
MakeUnknown creates Image Info with kUnknown SkColorType, kUnknown SkAlphaType
SkImageInfo() creates with zero dimensions, kUnknown SkColorType, kUnknown SkAlphaType
makeAlphaType creates Image Info with changed Alpha Type
makeColorSpace creates Image Info with changed Color Space
makeColorType creates Image Info with changed Color Type
makeWH creates Image Info with changed dimensions

SkImageInfo

SkImageInfo()

Return Value

incomplete

Example

See Also

incomplete


Make

static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at,
                        sk_sp<SkColorSpace> cs = nullptr)

Parameters

width incomplete
height incomplete
ct incomplete
at incomplete
cs incomplete

Return Value

incomplete

Example

See Also

incomplete


MakeN32

static SkImageInfo MakeN32(int width, int height, SkAlphaType at, sk_sp<SkColorSpace> cs = nullptr)

Sets colortype to kN32 SkColorType.

Parameters

width incomplete
height incomplete
at incomplete
cs incomplete

Return Value

incomplete

Example

See Also

incomplete


MakeS32

static SkImageInfo MakeS32(int width, int height, SkAlphaType at)

Creates Image Info marked as sRGB with kN32 SkColorType swizzle.

Parameters

width incomplete
height incomplete
at incomplete

Return Value

incomplete

Example

See Also

incomplete


MakeN32Premul

static SkImageInfo MakeN32Premul(int width, int height, sk_sp<SkColorSpace> cs = nullptr)

Sets colortype to kN32 SkColorType, and the alphatype to premul.

Parameters

width incomplete
height incomplete
cs incomplete

Return Value

incomplete

Example

See Also

incomplete


static SkImageInfo MakeN32Premul(const SkISize& size)

Parameters

size incomplete

Return Value

incomplete

Example

See Also

incomplete


MakeA8

static SkImageInfo MakeA8(int width, int height)

Parameters

width incomplete
height incomplete

Return Value

incomplete

Example

See Also

incomplete


MakeUnknown

static SkImageInfo MakeUnknown(int width, int height)

Parameters

width incomplete
height incomplete

Return Value

incomplete

Example

See Also

incomplete


static SkImageInfo MakeUnknown()

Return Value

incomplete

Example

See Also

incomplete


width

int width() const

Return Value

incomplete

Example

See Also

incomplete


height

int height() const

Return Value

incomplete

Example

See Also

incomplete


colorType

SkColorType colorType() const

Return Value

incomplete

Example

See Also

incomplete


alphaType

SkAlphaType alphaType() const

Return Value

incomplete

Example

See Also

incomplete


colorSpace

SkColorSpace* colorSpace() const

Return Value

incomplete

Example

See Also

incomplete


refColorSpace

sk_sp<SkColorSpace> refColorSpace() const

Return Value

incomplete

Example

See Also

incomplete


isEmpty

bool isEmpty() const

Return Value

incomplete

Example

See Also

incomplete


isOpaque

bool isOpaque() const

Return Value

incomplete

Example

See Also

incomplete


dimensions

SkISize dimensions() const

Return Value

incomplete

Example

See Also

incomplete


bounds

SkIRect bounds() const

Return Value

incomplete

Example

See Also

incomplete


gammaCloseToSRGB

bool gammaCloseToSRGB() const

Return Value

incomplete

Example

See Also

incomplete


makeWH

SkImageInfo makeWH(int newWidth, int newHeight) const

Creates Image Info with the same colortype and alphatype as this info, but with the specified width and height.

Parameters

newWidth incomplete
newHeight incomplete

Return Value

incomplete

Example

See Also

incomplete


makeAlphaType

SkImageInfo makeAlphaType(SkAlphaType newAlphaType) const

Parameters

newAlphaType incomplete

Return Value

incomplete

Example

See Also

incomplete


makeColorType

SkImageInfo makeColorType(SkColorType newColorType) const

Parameters

newColorType incomplete

Return Value

incomplete

Example

See Also

incomplete


makeColorSpace

SkImageInfo makeColorSpace(sk_sp<SkColorSpace> cs) const

Parameters

cs incomplete

Return Value

incomplete

Example

See Also

incomplete


bytesPerPixel

int bytesPerPixel() const

Return Value

incomplete

Example

See Also

incomplete


shiftPerPixel

int shiftPerPixel() const

Return Value

incomplete

Example

See Also

incomplete


minRowBytes64

uint64_t minRowBytes64() const

Return Value

incomplete

Example

See Also

incomplete


minRowBytes

size_t minRowBytes() const

Return Value

incomplete

Example

See Also

incomplete


computeOffset

size_t computeOffset(int x, int y, size_t rowBytes) const

Parameters

x incomplete
y incomplete
rowBytes incomplete

Return Value

incomplete

Example

See Also

incomplete


operator==

bool operator==(const SkImageInfo& other) _const

Parameters

other incomplete

Return Value

incomplete

Example

See Also

incomplete


operator!=

bool operator!=(const SkImageInfo& other) _const

Parameters

other incomplete

Return Value

incomplete

Example

See Also

incomplete


unflatten

void unflatten(SkReadBuffer& buffer)

Parameters

buffer incomplete

Example

See Also

incomplete


flatten

void flatten(SkWriteBuffer& buffer) const

Parameters

buffer incomplete

Example

See Also

incomplete


computeByteSize

size_t computeByteSize(size_t rowBytes) const

Returns the size (in bytes) of the image buffer that this info needs, given the specified rowBytes. The rowBytes must be >= this->minRowBytes. if (height == 0) { return 0; } else { return (height - 1) * rowBytes + width * bytes_per_pixel.

If the calculation overflows this returns SK MaxSizeT.

Parameters

rowBytes incomplete

Return Value

incomplete

Example

See Also

incomplete


computeMinByteSize

size_t computeMinByteSize() const

Returns the minimum size (in bytes) of the image buffer that this info needs. If the calculation overflows, or if the height is 0, this returns 0.

Return Value

incomplete

Example

See Also

incomplete


ByteSizeOverflowed

static bool ByteSizeOverflowed(size_t byteSize)

Returns true if the result of computeByteSize (or computeMinByteSize) overflowed

Parameters

byteSize incomplete

Return Value

incomplete

Example

See Also

incomplete


validRowBytes

bool validRowBytes(size_t rowBytes) const

Parameters

rowBytes incomplete

Return Value

incomplete

Example

See Also

incomplete


reset

void reset()

Example

See Also

incomplete


validate

void validate() const

Example

See Also

incomplete