///////////////////////////////////////////////////////////////////////////////
/**
+ * Describes the color space a YUV pixel.
+ */
+enum SkYUVColorSpace {
+ /** Standard JPEG color space. */
+ kJPEG_SkYUVColorSpace,
+ /** SDTV standard Rec. 601 color space. Uses "studio swing" [16, 235] color
+ range. See http://en.wikipedia.org/wiki/Rec._601 for details. */
+ kRec601_SkYUVColorSpace,
+
+ kLastEnum_SkYUVColorSpace = kRec601_SkYUVColorSpace
+};
+
+///////////////////////////////////////////////////////////////////////////////
+
+/**
* Describe an image's dimensions and pixel type.
*/
struct SkImageInfo {
- int fWidth;
- int fHeight;
- SkColorType fColorType;
- SkAlphaType fAlphaType;
+public:
+ SkImageInfo()
+ : fWidth(0)
+ , fHeight(0)
+ , fColorType(kUnknown_SkColorType)
+ , fAlphaType(kIgnore_SkAlphaType)
+ {}
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at) {
- SkImageInfo info = {
- width, height, ct, at
- };
- return info;
+ return SkImageInfo(width, height, ct, at);
}
/**
* Sets colortype to the native ARGB32 type.
*/
static SkImageInfo MakeN32(int width, int height, SkAlphaType at) {
- SkImageInfo info = {
- width, height, kN32_SkColorType, at
- };
- return info;
+ return SkImageInfo(width, height, kN32_SkColorType, at);
}
/**
* Sets colortype to the native ARGB32 type, and the alphatype to premul.
*/
static SkImageInfo MakeN32Premul(int width, int height) {
- SkImageInfo info = {
- width, height, kN32_SkColorType, kPremul_SkAlphaType
- };
- return info;
+ return SkImageInfo(width, height, kN32_SkColorType, kPremul_SkAlphaType);
}
/**
}
static SkImageInfo MakeA8(int width, int height) {
- SkImageInfo info = {
- width, height, kAlpha_8_SkColorType, kPremul_SkAlphaType
- };
- return info;
+ return SkImageInfo(width, height, kAlpha_8_SkColorType, kPremul_SkAlphaType);
}
static SkImageInfo MakeUnknown(int width, int height) {
- SkImageInfo info = {
- width, height, kUnknown_SkColorType, kIgnore_SkAlphaType
- };
- return info;
+ return SkImageInfo(width, height, kUnknown_SkColorType, kIgnore_SkAlphaType);
}
static SkImageInfo MakeUnknown() {
- SkImageInfo info = {
- 0, 0, kUnknown_SkColorType, kIgnore_SkAlphaType
- };
- return info;
+ return SkImageInfo();
}
int width() const { return fWidth; }
return SkImageInfo::Make(newWidth, newHeight, fColorType, fAlphaType);
}
+ SkImageInfo makeAlphaType(SkAlphaType newAlphaType) const {
+ return SkImageInfo::Make(fWidth, fHeight, fColorType, newAlphaType);
+ }
+
+ SkImageInfo makeColorType(SkColorType newColorType) const {
+ return SkImageInfo::Make(fWidth, fHeight, newColorType, fAlphaType);
+ }
+
int bytesPerPixel() const {
return SkColorTypeBytesPerPixel(fColorType);
}
}
SkDEBUGCODE(void validate() const;)
+
+#ifdef SK_SUPPORT_LEGACY_PUBLIC_IMAGEINFO_FIELDS
+public:
+#else
+private:
+#endif
+ int fWidth;
+ int fHeight;
+ SkColorType fColorType;
+ SkAlphaType fAlphaType;
+
+private:
+ SkImageInfo(int width, int height, SkColorType ct, SkAlphaType at)
+ : fWidth(width)
+ , fHeight(height)
+ , fColorType(ct)
+ , fAlphaType(at)
+ {}
};
#endif