/* * Copyright 2013 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SkImageInfo_DEFINED #define SkImageInfo_DEFINED #include "include/core/SkAlphaType.h" #include "include/core/SkColorType.h" #include "include/core/SkRect.h" #include "include/core/SkRefCnt.h" #include "include/core/SkSize.h" #include "include/private/base/SkAPI.h" #include "include/private/base/SkDebug.h" #include "include/private/base/SkMath.h" #include "include/private/base/SkTFitsIn.h" #include <cstddef> #include <cstdint> #include <utility> class SkColorSpace; /** Returns the number of bytes required to store a pixel, including unused padding. Returns zero if ct is kUnknown_SkColorType or invalid. @return bytes per pixel */ SK_API int SkColorTypeBytesPerPixel(SkColorType ct); /** Returns true if SkColorType always decodes alpha to 1.0, making the pixel fully opaque. If true, SkColorType does not reserve bits to encode alpha. @return true if alpha is always set to 1.0 */ SK_API bool SkColorTypeIsAlwaysOpaque(SkColorType ct); /** Returns true if canonical can be set to a valid SkAlphaType for colorType. If there is more than one valid canonical SkAlphaType, set to alphaType, if valid. If true is returned and canonical is not nullptr, store valid SkAlphaType. Returns false only if alphaType is kUnknown_SkAlphaType, color type is not kUnknown_SkColorType, and SkColorType is not always opaque. If false is returned, canonical is ignored. @param canonical storage for SkAlphaType @return true if valid SkAlphaType can be associated with colorType */ SK_API bool SkColorTypeValidateAlphaType(SkColorType colorType, SkAlphaType alphaType, SkAlphaType* canonical = nullptr); /** \enum SkImageInfo::SkYUVColorSpace Describes color range of YUV pixels. The color mapping from YUV to RGB varies depending on the source. YUV pixels may be generated by JPEG images, standard video streams, or high definition video streams. Each has its own mapping from YUV to RGB. JPEG YUV values encode the full range of 0 to 255 for all three components. Video YUV values often range from 16 to 235 for Y and from 16 to 240 for U and V (limited). Details of encoding and conversion to RGB are described in YCbCr color space. The identity colorspace exists to provide a utility mapping from Y to R, U to G and V to B. It can be used to visualize the YUV planes or to explicitly post process the YUV channels. */ enum SkYUVColorSpace : int { … }; SK_API bool SkYUVColorSpaceIsLimitedRange(SkYUVColorSpace cs); /** \struct SkColorInfo Describes pixel and encoding. SkImageInfo can be created from SkColorInfo by providing dimensions. It encodes how pixel bits describe alpha, transparency; color components red, blue, and green; and SkColorSpace, the range and linearity of colors. */ class SK_API SkColorInfo { … }; /** \struct SkImageInfo Describes pixel dimensions and encoding. SkBitmap, SkImage, PixMap, and SkSurface can be created from SkImageInfo. SkImageInfo can be retrieved from SkBitmap and SkPixmap, but not from SkImage and SkSurface. For example, SkImage and SkSurface implementations may defer pixel depth, so may not completely specify SkImageInfo. SkImageInfo contains dimensions, the pixel integral width and height. It encodes how pixel bits describe alpha, transparency; color components red, blue, and green; and SkColorSpace, the range and linearity of colors. */ struct SK_API SkImageInfo { … }; #endif