Skia
2D Graphics Library
SkBitmap.h
Go to the documentation of this file.
1 /*
2  * Copyright 2006 The Android Open Source Project
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef SkBitmap_DEFINED
9 #define SkBitmap_DEFINED
10 
11 #include "include/core/SkColor.h"
13 #include "include/core/SkMatrix.h"
14 #include "include/core/SkPixmap.h"
15 #include "include/core/SkPoint.h"
16 #include "include/core/SkRefCnt.h"
17 #include "include/core/SkShader.h"
19 
20 class SkBitmap;
21 struct SkMask;
22 class SkMipmap;
23 struct SkIRect;
24 struct SkRect;
25 class SkPaint;
26 class SkPixelRef;
27 class SkShader;
28 
51 public:
52  class SK_API Allocator;
53 
66 
75  SkBitmap(const SkBitmap& src);
76 
86 
90 
99  SkBitmap& operator=(const SkBitmap& src);
100 
110 
117  void swap(SkBitmap& other);
118 
124  const SkPixmap& pixmap() const { return fPixmap; }
125 
130  const SkImageInfo& info() const { return fPixmap.info(); }
131 
140  int width() const { return fPixmap.width(); }
141 
149  int height() const { return fPixmap.height(); }
150 
151  SkColorType colorType() const { return fPixmap.colorType(); }
152 
153  SkAlphaType alphaType() const { return fPixmap.alphaType(); }
154 
161  SkColorSpace* colorSpace() const { return fPixmap.colorSpace(); }
162 
171  sk_sp<SkColorSpace> refColorSpace() const { return fPixmap.info().refColorSpace(); }
172 
178  int bytesPerPixel() const { return fPixmap.info().bytesPerPixel(); }
179 
185  int rowBytesAsPixels() const { return fPixmap.rowBytesAsPixels(); }
186 
192  int shiftPerPixel() const { return fPixmap.shiftPerPixel(); }
193 
201  bool empty() const { return fPixmap.info().isEmpty(); }
202 
210  bool isNull() const { return nullptr == fPixelRef; }
211 
217  bool drawsNothing() const {
218  return this->empty() || this->isNull();
219  }
220 
229  size_t rowBytes() const { return fPixmap.rowBytes(); }
230 
258  bool setAlphaType(SkAlphaType alphaType);
259 
264  void* getPixels() const { return fPixmap.writable_addr(); }
265 
274  size_t computeByteSize() const { return fPixmap.computeByteSize(); }
275 
284  bool isImmutable() const;
285 
294  void setImmutable();
295 
305  bool isOpaque() const {
306  return SkAlphaTypeIsOpaque(this->alphaType());
307  }
308 
320  void reset();
321 
339  static bool ComputeIsOpaque(const SkBitmap& bm) {
340  return bm.pixmap().computeIsOpaque();
341  }
342 
349  void getBounds(SkRect* bounds) const;
350 
357  void getBounds(SkIRect* bounds) const;
358 
363  SkIRect bounds() const { return fPixmap.info().bounds(); }
364 
369  SkISize dimensions() const { return fPixmap.info().dimensions(); }
370 
375  SkIRect getSubset() const {
376  SkIPoint origin = this->pixelRefOrigin();
377  return SkIRect::MakeXYWH(origin.x(), origin.y(), this->width(), this->height());
378  }
379 
410  bool setInfo(const SkImageInfo& imageInfo, size_t rowBytes = 0);
411 
415  enum AllocFlags {
416  kZeroPixels_AllocFlag = 1 << 0,
417  };
418 
434  bool SK_WARN_UNUSED_RESULT tryAllocPixelsFlags(const SkImageInfo& info, uint32_t flags);
435 
454  void allocPixelsFlags(const SkImageInfo& info, uint32_t flags);
455 
472  bool SK_WARN_UNUSED_RESULT tryAllocPixels(const SkImageInfo& info, size_t rowBytes);
473 
492  void allocPixels(const SkImageInfo& info, size_t rowBytes);
493 
509  return this->tryAllocPixels(info, info.minRowBytes());
510  }
511 
528  void allocPixels(const SkImageInfo& info);
529 
547  bool SK_WARN_UNUSED_RESULT tryAllocN32Pixels(int width, int height, bool isOpaque = false);
548 
566  void allocN32Pixels(int width, int height, bool isOpaque = false);
567 
590  bool installPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
591  void (*releaseProc)(void* addr, void* context), void* context);
592 
608  bool installPixels(const SkImageInfo& info, void* pixels, size_t rowBytes) {
609  return this->installPixels(info, pixels, rowBytes, nullptr, nullptr);
610  }
611 
627  bool installPixels(const SkPixmap& pixmap);
628 
631  bool installMaskPixels(const SkMask& mask);
632 
646  void setPixels(void* pixels);
647 
656  return this->tryAllocPixels((Allocator*)nullptr);
657  }
658 
668  void allocPixels();
669 
680 
692  void allocPixels(Allocator* allocator);
693 
701  SkPixelRef* pixelRef() const { return fPixelRef.get(); }
702 
717 
733  void setPixelRef(sk_sp<SkPixelRef> pixelRef, int dx, int dy);
734 
739  bool readyToDraw() const {
740  return this->getPixels() != nullptr;
741  }
742 
753  uint32_t getGenerationID() const;
754 
760  void notifyPixelsChanged() const;
761 
771  void eraseColor(SkColor c) const;
772 
784  void eraseARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b) const {
785  this->eraseColor(SkColorSetARGB(a, r, g, b));
786  }
787 
800  void erase(SkColor c, const SkIRect& area) const;
801 
804  void eraseArea(const SkIRect& area, SkColor c) const {
805  this->erase(c, area);
806  }
807 
824  SkColor getColor(int x, int y) const {
825  return this->pixmap().getColor(x, y);
826  }
827 
836  float getAlphaf(int x, int y) const {
837  return this->pixmap().getAlphaf(x, y);
838  }
839 
855  void* getAddr(int x, int y) const;
856 
869  inline uint32_t* getAddr32(int x, int y) const;
870 
883  inline uint16_t* getAddr16(int x, int y) const;
884 
897  inline uint8_t* getAddr8(int x, int y) const;
898 
918  bool extractSubset(SkBitmap* dst, const SkIRect& subset) const;
919 
948  bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
949  int srcX, int srcY) const;
950 
979  bool readPixels(const SkPixmap& dst, int srcX, int srcY) const;
980 
1001  bool readPixels(const SkPixmap& dst) const {
1002  return this->readPixels(dst, 0, 0);
1003  }
1004 
1033  bool writePixels(const SkPixmap& src, int dstX, int dstY);
1034 
1055  bool writePixels(const SkPixmap& src) {
1056  return this->writePixels(src, 0, 0);
1057  }
1058 
1067  bool extractAlpha(SkBitmap* dst) const {
1068  return this->extractAlpha(dst, nullptr, nullptr, nullptr);
1069  }
1070 
1084  bool extractAlpha(SkBitmap* dst, const SkPaint* paint,
1085  SkIPoint* offset) const {
1086  return this->extractAlpha(dst, paint, nullptr, offset);
1087  }
1088 
1104  bool extractAlpha(SkBitmap* dst, const SkPaint* paint, Allocator* allocator,
1105  SkIPoint* offset) const;
1106 
1118  bool peekPixels(SkPixmap* pixmap) const;
1120  const SkMatrix* = nullptr) const;
1121 
1123  const SkMatrix& localMatrix) const {
1124  return this->makeShader(tmx, tmy, sampling, &localMatrix);
1125  }
1126 
1128  const SkMatrix* localMatrix = nullptr) const {
1129  return this->makeShader(SkTileMode::kClamp, SkTileMode::kClamp, sampling, localMatrix);
1130  }
1131 
1133  const SkMatrix& localMatrix) const {
1134  return this->makeShader(sampling, &localMatrix);
1135  }
1136 
1137 #ifdef SK_SUPPORT_LEGACY_IMPLICIT_FILTERQUALITY
1138  sk_sp<SkShader> makeShader(SkTileMode tmx, SkTileMode tmy,
1139  const SkMatrix* localMatrix = nullptr) const;
1140  // defaults to Clamp in x, and y
1141  sk_sp<SkShader> makeShader(const SkMatrix* localMatrix = nullptr) const {
1142  return this->makeShader(SkTileMode::kClamp, SkTileMode::kClamp, localMatrix);
1143  }
1144 #endif
1145 
1151 
1155  SkDEBUGCODE(void validate() const;)
1156 
1160  class Allocator : public SkRefCnt {
1161  public:
1162 
1170  virtual bool allocPixelRef(SkBitmap* bitmap) = 0;
1171  private:
1172  using INHERITED = SkRefCnt;
1173  };
1174 
1180  class HeapAllocator : public Allocator {
1181  public:
1182 
1192  bool allocPixelRef(SkBitmap* bitmap) override;
1193  };
1194 
1195 private:
1196  sk_sp<SkPixelRef> fPixelRef;
1197  SkPixmap fPixmap;
1198  sk_sp<SkMipmap> fMips;
1199 
1200  friend class SkImage_Raster;
1201  friend class SkReadBuffer; // unflatten
1202 };
1203 
1205 
1206 inline uint32_t* SkBitmap::getAddr32(int x, int y) const {
1207  SkASSERT(fPixmap.addr());
1208  return fPixmap.writable_addr32(x, y);
1209 }
1210 
1211 inline uint16_t* SkBitmap::getAddr16(int x, int y) const {
1212  SkASSERT(fPixmap.addr());
1213  return fPixmap.writable_addr16(x, y);
1214 }
1215 
1216 inline uint8_t* SkBitmap::getAddr8(int x, int y) const {
1217  SkASSERT(fPixmap.addr());
1218  return fPixmap.writable_addr8(x, y);
1219 }
1220 
1221 #endif
SkTileMode::kClamp
@ kClamp
Replicate the edge color if the shader draws outside of its original bounds.
SkBitmap::asImage
sk_sp< SkImage > asImage() const
Returns a new image from the bitmap.
SkBitmap::tryAllocN32Pixels
bool SK_WARN_UNUSED_RESULT tryAllocN32Pixels(int width, int height, bool isOpaque=false)
Sets SkImageInfo to width, height, and native color type; and allocates pixel memory.
SkBitmap::getBounds
void getBounds(SkRect *bounds) const
Returns SkRect { 0, 0, width(), height() }.
SkBitmap::getAddr
void * getAddr(int x, int y) const
Returns pixel address at (x, y).
SkBitmap::erase
void erase(SkColor c, const SkIRect &area) const
Replaces pixel values inside area with c.
SkRefCnt
Definition: SkRefCnt.h:118
SkBitmap::HeapAllocator
Definition: SkBitmap.h:1180
SkPixmap::writable_addr32
uint32_t * writable_addr32(int x, int y) const
Returns writable pixel address at (x, y).
Definition: SkPixmap.h:509
SkBitmap::extractAlpha
bool extractAlpha(SkBitmap *dst, const SkPaint *paint, Allocator *allocator, SkIPoint *offset) const
Sets dst to alpha described by pixels.
SkBitmap::pixelRef
SkPixelRef * pixelRef() const
Returns SkPixelRef, which contains: pixel base address; its dimensions; and rowBytes(),...
Definition: SkBitmap.h:701
Allocator
Asserts if internal values are illegal or inconsistent.
Definition: SkBitmap.h:1155
SkBitmap::getAddr8
uint8_t * getAddr8(int x, int y) const
Returns address at (x, y).
Definition: SkBitmap.h:1216
SkBitmap::SkBitmap
SkBitmap(const SkBitmap &src)
Copies settings from src to returned SkBitmap.
SkBitmap::colorSpace
SkColorSpace * colorSpace() const
Returns SkColorSpace, the range of colors, associated with SkImageInfo.
Definition: SkBitmap.h:161
SkBitmap::drawsNothing
bool drawsNothing() const
Returns true if width() or height() are zero, or if SkPixelRef is nullptr.
Definition: SkBitmap.h:217
SkBitmap::ComputeIsOpaque
static bool ComputeIsOpaque(const SkBitmap &bm)
Returns true if all pixels are opaque.
Definition: SkBitmap.h:339
SkBitmap::SkBitmap
SkBitmap()
Creates an empty SkBitmap without pixels, with kUnknown_SkColorType, kUnknown_SkAlphaType,...
SkPixelRef
Definition: SkPixelRef.h:33
SkBitmap::getAddr16
uint16_t * getAddr16(int x, int y) const
Returns address at (x, y).
Definition: SkBitmap.h:1211
SkBitmap::colorType
SkColorType colorType() const
Definition: SkBitmap.h:151
SkBitmap::bounds
SkIRect bounds() const
Returns SkIRect { 0, 0, width(), height() }.
Definition: SkBitmap.h:363
SkBitmap::reset
void reset()
Resets to its initial state; all fields are set to zero, as if SkBitmap had been initialized by SkBit...
SkShader
Definition: SkShader.h:39
SkIPoint::y
constexpr int32_t y() const
Returns y-axis value of SkIPoint.
Definition: SkPoint.h:49
SkIPoint::x
constexpr int32_t x() const
Returns x-axis value of SkIPoint.
Definition: SkPoint.h:43
SkBitmap::setPixels
void setPixels(void *pixels)
Replaces SkPixelRef with pixels, preserving SkImageInfo and rowBytes().
SkBitmap::extractAlpha
bool extractAlpha(SkBitmap *dst, const SkPaint *paint, SkIPoint *offset) const
Sets dst to alpha described by pixels.
Definition: SkBitmap.h:1084
SkBitmap::tryAllocPixels
bool SK_WARN_UNUSED_RESULT tryAllocPixels(const SkImageInfo &info)
Sets SkImageInfo to info following the rules in setInfo() and allocates pixel memory.
Definition: SkBitmap.h:508
SkBitmap::makeShader
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *=nullptr) const
SkPixmap.h
SkBitmap::writePixels
bool writePixels(const SkPixmap &src, int dstX, int dstY)
Copies a SkRect of pixels from src.
SkBitmap::makeShader
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &sampling, const SkMatrix &localMatrix) const
Definition: SkBitmap.h:1122
SkBitmap::notifyPixelsChanged
void notifyPixelsChanged() const
Marks that pixels in SkPixelRef have changed.
SkPixmap::writable_addr8
uint8_t * writable_addr8(int x, int y) const
Returns writable pixel address at (x, y).
Definition: SkPixmap.h:480
SkBitmap::eraseColor
void eraseColor(SkColor c) const
Replaces pixel values with c, interpreted as being in the sRGB SkColorSpace.
SkRefCnt.h
SkBitmap::tryAllocPixels
bool SK_WARN_UNUSED_RESULT tryAllocPixels()
Allocates pixel memory with HeapAllocator, and replaces existing SkPixelRef.
Definition: SkBitmap.h:655
SkBitmap::HeapAllocator::allocPixelRef
bool allocPixelRef(SkBitmap *bitmap) override
Allocates the pixel memory for the bitmap, given its dimensions and SkColorType.
SkBitmap::getGenerationID
uint32_t getGenerationID() const
Returns a unique value corresponding to the pixels in SkPixelRef.
SkTileMode
SkTileMode
Definition: SkTileMode.h:13
sk_sp< SkColorSpace >
SkSamplingOptions
Definition: SkSamplingOptions.h:50
SkBitmap::allocPixelsFlags
void allocPixelsFlags(const SkImageInfo &info, uint32_t flags)
Sets SkImageInfo to info following the rules in setInfo() and allocates pixel memory.
SkBitmap::makeShader
sk_sp< SkShader > makeShader(const SkSamplingOptions &sampling, const SkMatrix *localMatrix=nullptr) const
Definition: SkBitmap.h:1127
SkBitmap::installMaskPixels
bool installMaskPixels(const SkMask &mask)
Deprecated.
SkBitmap::pixmap
const SkPixmap & pixmap() const
Returns a constant reference to the SkPixmap holding the SkBitmap pixel address, row bytes,...
Definition: SkBitmap.h:124
SkBitmap::tryAllocPixels
bool SK_WARN_UNUSED_RESULT tryAllocPixels(const SkImageInfo &info, size_t rowBytes)
Sets SkImageInfo to info following the rules in setInfo() and allocates pixel memory.
SkBitmap::extractSubset
bool extractSubset(SkBitmap *dst, const SkIRect &subset) const
Shares SkPixelRef with dst.
SkDEBUGCODE
#define SkDEBUGCODE(...)
Definition: SkTypes.h:467
SkBitmap::installPixels
bool installPixels(const SkPixmap &pixmap)
Sets SkImageInfo to pixmap.info() following the rules in setInfo(), and creates SkPixelRef containing...
SkBitmap::readyToDraw
bool readyToDraw() const
Returns true if SkBitmap is can be drawn.
Definition: SkBitmap.h:739
SkPaint
Definition: SkPaint.h:39
SkBitmap::isImmutable
bool isImmutable() const
Returns true if pixels can not change.
SK_API
#define SK_API
Definition: SkTypes.h:181
SkASSERT
#define SkASSERT(cond)
Definition: SkTypes.h:460
SkBitmap::rowBytesAsPixels
int rowBytesAsPixels() const
Returns number of pixels that fit on row.
Definition: SkBitmap.h:185
SkBitmap::shiftPerPixel
int shiftPerPixel() const
Returns bit shift converting row bytes to row pixels.
Definition: SkBitmap.h:192
SkBitmap::AllocFlags
AllocFlags
Definition: SkBitmap.h:415
SkImageInfo
Definition: SkImageInfo.h:283
SkBitmap::operator=
SkBitmap & operator=(SkBitmap &&src)
Copies settings from src to returned SkBitmap.
SkBitmap::swap
void swap(SkBitmap &other)
Swaps the fields of the two bitmaps.
SkBitmap::bytesPerPixel
int bytesPerPixel() const
Returns number of bytes per pixel required by SkColorType.
Definition: SkBitmap.h:178
SkColorSetARGB
static constexpr SkColor SkColorSetARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
Returns color value from 8-bit component values.
Definition: SkColor.h:47
SkISize
Definition: SkSize.h:13
SkBitmap::installPixels
bool installPixels(const SkImageInfo &info, void *pixels, size_t rowBytes, void(*releaseProc)(void *addr, void *context), void *context)
Sets SkImageInfo to info following the rules in setInfo(), and creates SkPixelRef containing pixels a...
SkBitmap::computeByteSize
size_t computeByteSize() const
Returns minimum memory required for pixel storage.
Definition: SkBitmap.h:274
SkBitmap::refColorSpace
sk_sp< SkColorSpace > refColorSpace() const
Returns smart pointer to SkColorSpace, the range of colors, associated with SkImageInfo.
Definition: SkBitmap.h:171
SkPoint.h
SkBitmap::alphaType
SkAlphaType alphaType() const
Definition: SkBitmap.h:153
SkBitmap::~SkBitmap
~SkBitmap()
Decrements SkPixelRef reference count, if SkPixelRef is not nullptr.
SkBitmap::writePixels
bool writePixels(const SkPixmap &src)
Copies a SkRect of pixels from src.
Definition: SkBitmap.h:1055
SkBitmap::makeShader
sk_sp< SkShader > makeShader(const SkSamplingOptions &sampling, const SkMatrix &localMatrix) const
Definition: SkBitmap.h:1132
SkBitmap::readPixels
bool readPixels(const SkPixmap &dst, int srcX, int srcY) const
Copies a SkRect of pixels from SkBitmap to dst.
SkBitmap::allocPixels
void allocPixels(const SkImageInfo &info, size_t rowBytes)
Sets SkImageInfo to info following the rules in setInfo() and allocates pixel memory.
SkBitmap::peekPixels
bool peekPixels(SkPixmap *pixmap) const
Copies SkBitmap pixel address, row bytes, and SkImageInfo to pixmap, if address is available,...
SkBitmap::setAlphaType
bool setAlphaType(SkAlphaType alphaType)
Sets SkAlphaType, if alphaType is compatible with SkColorType.
SkBitmap::info
const SkImageInfo & info() const
Returns width, height, SkAlphaType, SkColorType, and SkColorSpace.
Definition: SkBitmap.h:130
SkBitmap::setPixelRef
void setPixelRef(sk_sp< SkPixelRef > pixelRef, int dx, int dy)
Replaces pixelRef and origin in SkBitmap.
SkIRect::MakeXYWH
static constexpr SkIRect SK_WARN_UNUSED_RESULT MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
Returns constructed SkIRect set to: (x, y, x + w, y + h).
Definition: SkRect.h:101
SkBitmap::eraseArea
void eraseArea(const SkIRect &area, SkColor c) const
Deprecated.
Definition: SkBitmap.h:804
SkBitmap::allocPixels
void allocPixels(const SkImageInfo &info)
Sets SkImageInfo to info following the rules in setInfo() and allocates pixel memory.
SkBitmap::setInfo
bool setInfo(const SkImageInfo &imageInfo, size_t rowBytes=0)
Sets width, height, SkAlphaType, SkColorType, SkColorSpace, and optional rowBytes.
SkBitmap::height
int height() const
Returns pixel row count.
Definition: SkBitmap.h:149
SkBitmap::operator=
SkBitmap & operator=(const SkBitmap &src)
Copies settings from src to returned SkBitmap.
SkBitmap::readPixels
bool readPixels(const SkPixmap &dst) const
Copies a SkRect of pixels from SkBitmap to dst.
Definition: SkBitmap.h:1001
SkPixmap
Definition: SkPixmap.h:31
SkPixmap::addr
const void * addr() const
Returns pixel address, the base address corresponding to the pixel origin.
Definition: SkPixmap.h:144
SkBitmap::tryAllocPixels
bool SK_WARN_UNUSED_RESULT tryAllocPixels(Allocator *allocator)
Allocates pixel memory with allocator, and replaces existing SkPixelRef.
SkBitmap::width
int width() const
Returns pixel count in each row.
Definition: SkBitmap.h:140
SkMatrix
Definition: SkMatrix.h:48
SkTileMode.h
SkBitmap::getSubset
SkIRect getSubset() const
Returns the bounds of this bitmap, offset by its SkPixelRef origin.
Definition: SkBitmap.h:375
SkMatrix.h
SkIRect
Definition: SkRect.h:28
SkPixmap::writable_addr16
uint16_t * writable_addr16(int x, int y) const
Returns writable_addr pixel address at (x, y).
Definition: SkPixmap.h:494
SkImageInfo::minRowBytes
size_t minRowBytes() const
Returns minimum bytes per row, computed from pixel width() and SkColorType, which specifies bytesPerP...
Definition: SkImageInfo.h:606
SK_WARN_UNUSED_RESULT
#define SK_WARN_UNUSED_RESULT
Definition: SkTypes.h:60
SkBitmap::dimensions
SkISize dimensions() const
Returns SkISize { width(), height() }.
Definition: SkBitmap.h:369
SkBitmap::getBounds
void getBounds(SkIRect *bounds) const
Returns SkIRect { 0, 0, width(), height() }.
SkPixmap::computeIsOpaque
bool computeIsOpaque() const
Returns true if all pixels are opaque.
SkBitmap::allocN32Pixels
void allocN32Pixels(int width, int height, bool isOpaque=false)
Sets SkImageInfo to width, height, and the native color type; and allocates pixel memory.
SkBitmap::installPixels
bool installPixels(const SkImageInfo &info, void *pixels, size_t rowBytes)
Sets SkImageInfo to info following the rules in setInfo(), and creates SkPixelRef containing pixels a...
Definition: SkBitmap.h:608
SkBitmap::setImmutable
void setImmutable()
Sets internal flag to mark SkBitmap as immutable.
SkBitmap::getPixels
void * getPixels() const
Returns pixel address, the base address corresponding to the pixel origin.
Definition: SkBitmap.h:264
SkBitmap::extractAlpha
bool extractAlpha(SkBitmap *dst) const
Sets dst to alpha described by pixels.
Definition: SkBitmap.h:1067
SkColor
uint32_t SkColor
32-bit ARGB color value, unpremultiplied.
Definition: SkColor.h:35
SkRect
Definition: SkRect.h:572
SkBitmap::SkBitmap
SkBitmap(SkBitmap &&src)
Copies settings from src to returned SkBitmap.
SkBitmap::empty
bool empty() const
Returns true if either width() or height() are zero.
Definition: SkBitmap.h:201
SkColorType
SkColorType
Definition: SkImageInfo.h:64
SkBitmap::allocPixels
void allocPixels()
Allocates pixel memory with HeapAllocator, and replaces existing SkPixelRef.
SkBitmap::isOpaque
bool isOpaque() const
Returns true if SkAlphaType is set to hint that all pixels are opaque; their alpha value is implicitl...
Definition: SkBitmap.h:305
U8CPU
unsigned U8CPU
Fast type for unsigned 8 bits.
Definition: SkTypes.h:488
SkBitmap::getAlphaf
float getAlphaf(int x, int y) const
Look up the pixel at (x,y) and return its alpha component, normalized to [0..1].
Definition: SkBitmap.h:836
SkBitmap::getColor
SkColor getColor(int x, int y) const
Returns pixel at (x, y) as unpremultiplied color.
Definition: SkBitmap.h:824
SkBitmap::readPixels
bool readPixels(const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes, int srcX, int srcY) const
Copies a SkRect of pixels from SkBitmap to dstPixels.
SkIPoint
Definition: SkPoint.h:25
SkShader.h
SkColor.h
SkBitmap::eraseARGB
void eraseARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b) const
Replaces pixel values with unpremultiplied color built from a, r, g, and b, interpreted as being in t...
Definition: SkBitmap.h:784
SkBitmap::getAddr32
uint32_t * getAddr32(int x, int y) const
Returns address at (x, y).
Definition: SkBitmap.h:1206
SkBitmap::isNull
bool isNull() const
Returns true if SkPixelRef is nullptr.
Definition: SkBitmap.h:210
SkAlphaType
SkAlphaType
Definition: SkImageInfo.h:37
SkAlphaTypeIsOpaque
static bool SkAlphaTypeIsOpaque(SkAlphaType at)
Returns true if SkAlphaType equals kOpaque_SkAlphaType.
Definition: SkImageInfo.h:52
SkBitmap::rowBytes
size_t rowBytes() const
Returns row bytes, the interval from one pixel row to the next.
Definition: SkBitmap.h:229
SkBitmap::allocPixels
void allocPixels(Allocator *allocator)
Allocates pixel memory with allocator, and replaces existing SkPixelRef.
SkImageInfo.h
SkBitmap
Definition: SkBitmap.h:50
SkBitmap::tryAllocPixelsFlags
bool SK_WARN_UNUSED_RESULT tryAllocPixelsFlags(const SkImageInfo &info, uint32_t flags)
Sets SkImageInfo to info following the rules in setInfo() and allocates pixel memory.
SkColorSpace
Definition: SkColorSpace.h:104
SkBitmap::pixelRefOrigin
SkIPoint pixelRefOrigin() const
Returns origin of pixels within SkPixelRef.