8 #ifndef SkPixmap_DEFINED
9 #define SkPixmap_DEFINED
12 #include "SkFilterQuality.h"
13 #include "SkImageInfo.h"
26 : fPixels(NULL), fCTable(NULL), fRowBytes(0), fInfo(SkImageInfo::MakeUnknown(0, 0))
31 : fPixels(addr), fCTable(ctable), fRowBytes(rowBytes), fInfo(info)
33 if (kIndex_8_SkColorType == info.colorType()) {
36 SkASSERT(NULL == ctable);
41 void reset(
const SkImageInfo& info,
const void* addr,
size_t rowBytes,
44 this->reset(info, NULL, 0, NULL);
54 bool SK_WARN_UNUSED_RESULT reset(
const SkMask&);
62 bool SK_WARN_UNUSED_RESULT extractSubset(
SkPixmap* subset,
const SkIRect& area)
const;
65 size_t rowBytes()
const {
return fRowBytes; }
66 const void* addr()
const {
return fPixels; }
69 int width()
const {
return fInfo.width(); }
70 int height()
const {
return fInfo.height(); }
71 SkColorType colorType()
const {
return fInfo.colorType(); }
72 SkAlphaType alphaType()
const {
return fInfo.alphaType(); }
73 SkColorSpace* colorSpace()
const {
return fInfo.colorSpace(); }
74 bool isOpaque()
const {
return fInfo.isOpaque(); }
76 SkIRect bounds()
const {
return SkIRect::MakeWH(this->width(), this->height()); }
89 uint64_t getSize64()
const {
return sk_64_mul(fInfo.height(), fRowBytes); }
90 uint64_t getSafeSize64()
const {
return fInfo.getSafeSize64(fRowBytes); }
91 size_t getSafeSize()
const {
return fInfo.getSafeSize(fRowBytes); }
97 bool computeIsOpaque()
const;
107 SkColor getColor(
int x,
int y)
const;
109 const void* addr(
int x,
int y)
const {
110 return (
const char*)fPixels + fInfo.computeOffset(x, y, fRowBytes);
112 const uint8_t* addr8()
const {
113 SkASSERT(1 == SkColorTypeBytesPerPixel(fInfo.colorType()));
114 return reinterpret_cast<const uint8_t*
>(fPixels);
116 const uint16_t* addr16()
const {
117 SkASSERT(2 == SkColorTypeBytesPerPixel(fInfo.colorType()));
118 return reinterpret_cast<const uint16_t*
>(fPixels);
120 const uint32_t* addr32()
const {
121 SkASSERT(4 == SkColorTypeBytesPerPixel(fInfo.colorType()));
122 return reinterpret_cast<const uint32_t*
>(fPixels);
124 const uint64_t* addr64()
const {
125 SkASSERT(8 == SkColorTypeBytesPerPixel(fInfo.colorType()));
126 return reinterpret_cast<const uint64_t*
>(fPixels);
128 const uint16_t* addrF16()
const {
129 SkASSERT(8 == SkColorTypeBytesPerPixel(fInfo.colorType()));
130 SkASSERT(kRGBA_F16_SkColorType == fInfo.colorType());
131 return reinterpret_cast<const uint16_t*
>(fPixels);
136 const uint8_t* addr8(
int x,
int y)
const {
137 SkASSERT((
unsigned)x < (
unsigned)fInfo.width());
138 SkASSERT((
unsigned)y < (
unsigned)fInfo.height());
139 return (
const uint8_t*)((
const char*)this->addr8() + y * fRowBytes + (x << 0));
141 const uint16_t* addr16(
int x,
int y)
const {
142 SkASSERT((
unsigned)x < (
unsigned)fInfo.width());
143 SkASSERT((
unsigned)y < (
unsigned)fInfo.height());
144 return (
const uint16_t*)((
const char*)this->addr16() + y * fRowBytes + (x << 1));
146 const uint32_t* addr32(
int x,
int y)
const {
147 SkASSERT((
unsigned)x < (
unsigned)fInfo.width());
148 SkASSERT((
unsigned)y < (
unsigned)fInfo.height());
149 return (
const uint32_t*)((
const char*)this->addr32() + y * fRowBytes + (x << 2));
151 const uint64_t* addr64(
int x,
int y)
const {
152 SkASSERT((
unsigned)x < (
unsigned)fInfo.width());
153 SkASSERT((
unsigned)y < (
unsigned)fInfo.height());
154 return (
const uint64_t*)((
const char*)this->addr64() + y * fRowBytes + (x << 3));
156 const uint16_t* addrF16(
int x,
int y)
const {
157 SkASSERT(kRGBA_F16_SkColorType == fInfo.colorType());
158 return reinterpret_cast<const uint16_t*
>(this->addr64(x, y));
163 void* writable_addr()
const {
return const_cast<void*
>(fPixels); }
164 void* writable_addr(
int x,
int y)
const {
165 return const_cast<void*
>(this->addr(x, y));
167 uint8_t* writable_addr8(
int x,
int y)
const {
168 return const_cast<uint8_t*
>(this->addr8(x, y));
170 uint16_t* writable_addr16(
int x,
int y)
const {
171 return const_cast<uint16_t*
>(this->addr16(x, y));
173 uint32_t* writable_addr32(
int x,
int y)
const {
174 return const_cast<uint32_t*
>(this->addr32(x, y));
176 uint64_t* writable_addr64(
int x,
int y)
const {
177 return const_cast<uint64_t*
>(this->addr64(x, y));
179 uint16_t* writable_addrF16(
int x,
int y)
const {
180 return reinterpret_cast<uint16_t*
>(writable_addr64(x, y));
185 bool readPixels(
const SkImageInfo& dstInfo,
void* dstPixels,
size_t dstRowBytes,
186 int srcX,
int srcY, SkTransferFunctionBehavior behavior)
const;
187 bool readPixels(
const SkImageInfo& dstInfo,
void* dstPixels,
size_t dstRowBytes)
const {
188 return this->readPixels(dstInfo, dstPixels, dstRowBytes, 0, 0);
190 bool readPixels(
const SkImageInfo& dstInfo,
void* dstPixels,
size_t dstRowBytes,
int srcX,
192 return this->readPixels(dstInfo, dstPixels, dstRowBytes, srcX, srcY,
193 SkTransferFunctionBehavior::kRespect);
195 bool readPixels(
const SkPixmap& dst,
int srcX,
int srcY)
const {
196 return this->readPixels(dst.info(), dst.writable_addr(), dst.rowBytes(), srcX, srcY);
198 bool readPixels(
const SkPixmap& dst)
const {
199 return this->readPixels(dst.info(), dst.writable_addr(), dst.rowBytes(), 0, 0);
209 bool scalePixels(
const SkPixmap& dst, SkFilterQuality)
const;
217 bool erase(
SkColor color)
const {
return this->erase(color, this->bounds()); }
int rowBytesAsPixels() const
Return the rowbytes expressed as a number of pixels (like width and height).
Definition: SkPixmap.h:81
Definition: SkColorSpace.h:59
Describe an image's dimensions and pixel type.
Definition: SkImageInfo.h:181
SkColorTable holds an array SkPMColors (premultiplied 32-bit colors) used by 8-bit bitmaps...
Definition: SkColorTable.h:25
Pairs SkImageInfo with actual pixels and rowbytes.
Definition: SkPixmap.h:23
Definition: SkColor.h:179
SkMask is used to describe alpha bitmaps, either 1bit, 8bit, or the 3-channel 3D format.
Definition: SkMask.h:19
SkData holds an immutable data buffer.
Definition: SkData.h:22
uint32_t SkColor
32 bit ARGB color value, not premultiplied.
Definition: SkColor.h:28
SkIRect holds four 32 bit integer coordinates for a rectangle.
Definition: SkRect.h:20
int shiftPerPixel() const
Return the shift amount per pixel (i.e.
Definition: SkPixmap.h:87
Types and macros for colors.