Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1 | #Topic Pixmap |
Cary Clark | 137b874 | 2018-05-30 09:21:49 -0400 | [diff] [blame] | 2 | #Alias Pixmap_Reference ## |
Cary Clark | e4aa371 | 2017-09-15 02:56:12 -0400 | [diff] [blame] | 3 | |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 4 | #Class SkPixmap |
| 5 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame^] | 6 | #Code |
| 7 | #Populate |
| 8 | ## |
| 9 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 10 | Pixmap provides a utility to pair SkImageInfo with pixels and row bytes. |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 11 | Pixmap is a low level class which provides convenience functions to access |
| 12 | raster destinations. Canvas can not draw Pixmap, nor does Pixmap provide |
| 13 | a direct drawing destination. |
| 14 | |
| 15 | Use Bitmap to draw pixels referenced by Pixmap; use Surface to draw into |
| 16 | pixels referenced by Pixmap. |
| 17 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 18 | Pixmap does not try to manage the lifetime of the pixel memory. Use Pixel_Ref |
| 19 | to manage pixel memory; Pixel_Ref is safe across threads. |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 20 | |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 21 | |
| 22 | #Subtopic Initialization |
Cary Clark | 08895c4 | 2018-02-01 09:37:32 -0500 | [diff] [blame] | 23 | #Line # sets fields for use ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 24 | |
| 25 | # ------------------------------------------------------------------------------ |
| 26 | |
| 27 | #Method SkPixmap() |
| 28 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 29 | #In Initialization |
| 30 | #Line # constructs with default values ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 31 | Creates an empty Pixmap without pixels, with kUnknown_SkColorType, with |
| 32 | kUnknown_SkAlphaType, and with a width and height of zero. Use |
| 33 | reset() to associate pixels, SkColorType, SkAlphaType, width, and height |
| 34 | after Pixmap has been created. |
| 35 | |
| 36 | #Return empty Pixmap ## |
| 37 | |
| 38 | #Example |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 39 | void draw(SkCanvas* canvas) { |
| 40 | const char* alphas[] = {"Unknown", "Opaque", "Premul", "Unpremul"}; |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 41 | const char* colors[] = {"Unknown", "Alpha_8", "RGB_565", "ARGB_4444", "RGBA_8888", "RGB_888x", |
| 42 | "BGRA_8888", "RGBA_1010102", "RGB_101010x", "Gray_8", "RGBA_F16"}; |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 43 | SkPixmap pixmap; |
| 44 | for (int i = 0; i < 2; ++i) { |
| 45 | SkDebugf("width: %2d height: %2d", pixmap.width(), pixmap.height()); |
| 46 | SkDebugf(" color: k%s_SkColorType", colors[pixmap.colorType()]); |
| 47 | SkDebugf(" alpha: k%s_SkAlphaType\n", alphas[pixmap.alphaType()]); |
| 48 | pixmap.reset(SkImageInfo::Make(25, 35, kRGBA_8888_SkColorType, kOpaque_SkAlphaType), |
| 49 | nullptr, 0); |
| 50 | } |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 51 | } |
| 52 | #StdOut |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 53 | width: 0 height: 0 color: kUnknown_SkColorType alpha: kUnknown_SkAlphaType |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 54 | width: 25 height: 35 color: kRGBA_8888_SkColorType alpha: kOpaque_SkAlphaType |
| 55 | ## |
| 56 | ## |
| 57 | |
| 58 | #SeeAlso SkPixmap(const SkImageInfo& info, const void* addr, size_t rowBytes) reset() SkAlphaType SkColorType |
| 59 | |
| 60 | ## |
| 61 | |
| 62 | # ------------------------------------------------------------------------------ |
| 63 | |
| 64 | #Method SkPixmap(const SkImageInfo& info, const void* addr, size_t rowBytes) |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 65 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 66 | #In Initialization |
| 67 | #Line # constructs from Image_Info, pixels ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 68 | Creates Pixmap from info width, height, SkAlphaType, and SkColorType. |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 69 | addr points to pixels, or nullptr. rowBytes should be info.width() times |
| 70 | info.bytesPerPixel(), or larger. |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 71 | |
| 72 | No parameter checking is performed; it is up to the caller to ensure that |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 73 | addr and rowBytes agree with info. |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 74 | |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 75 | The memory lifetime of pixels is managed by the caller. When Pixmap goes |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 76 | out of scope, addr is unaffected. |
| 77 | |
| 78 | Pixmap may be later modified by reset() to change its size, pixel type, or |
| 79 | storage. |
| 80 | |
| 81 | #Param info width, height, SkAlphaType, SkColorType of Image_Info ## |
| 82 | #Param addr pointer to pixels allocated by caller; may be nullptr ## |
| 83 | #Param rowBytes size of one row of addr; width times pixel size, or larger ## |
| 84 | |
| 85 | #Return initialized Pixmap ## |
| 86 | |
| 87 | #Example |
| 88 | #Image 3 |
| 89 | #Description |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 90 | SkImage::MakeRasterCopy takes const SkPixmap& as an argument. The example |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 91 | constructs a SkPixmap from the brace-delimited parameters. |
| 92 | ## |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 93 | SkDebugf("image alpha only = %s\n", image->isAlphaOnly() ? "true" : "false"); |
| 94 | SkPMColor pmColors = 0; |
| 95 | sk_sp<SkImage> copy = SkImage::MakeRasterCopy({SkImageInfo::MakeA8(1, 1), |
| 96 | (uint8_t*)&pmColors, |
| 97 | 1}); |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 98 | SkDebugf("copy alpha only = %s\n", copy->isAlphaOnly() ? "true" : "false"); |
| 99 | #StdOut |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 100 | image alpha only = false |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 101 | copy alpha only = true |
| 102 | ## |
| 103 | ## |
| 104 | |
| 105 | #SeeAlso SkPixmap() reset() SkAlphaType SkColorType |
| 106 | |
| 107 | ## |
| 108 | |
| 109 | # ------------------------------------------------------------------------------ |
| 110 | |
| 111 | #Method void reset() |
| 112 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 113 | #In Initialization |
| 114 | #Line # reuses existing Pixmap with replacement values ## |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 115 | Sets width, height, row bytes to zero; pixel address to nullptr; SkColorType to |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 116 | kUnknown_SkColorType; and SkAlphaType to kUnknown_SkAlphaType. |
| 117 | |
| 118 | The prior pixels are unaffected; it is up to the caller to release pixels |
| 119 | memory if desired. |
| 120 | |
| 121 | #Example |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 122 | void draw(SkCanvas* canvas) { |
| 123 | const char* alphas[] = {"Unknown", "Opaque", "Premul", "Unpremul"}; |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 124 | const char* colors[] = {"Unknown", "Alpha_8", "RGB_565", "ARGB_4444", "RGBA_8888", "RGB_888x", |
| 125 | "BGRA_8888", "RGBA_1010102", "RGB_101010x", "Gray_8", "RGBA_F16"}; |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 126 | SkPixmap pixmap(SkImageInfo::Make(25, 35, kRGBA_8888_SkColorType, kOpaque_SkAlphaType), |
| 127 | nullptr, 0); |
| 128 | for (int i = 0; i < 2; ++i) { |
| 129 | SkDebugf("width: %2d height: %2d", pixmap.width(), pixmap.height()); |
| 130 | SkDebugf(" color: k%s_SkColorType", colors[pixmap.colorType()]); |
| 131 | SkDebugf(" alpha: k%s_SkAlphaType\n", alphas[pixmap.alphaType()]); |
| 132 | pixmap.reset(); |
| 133 | } |
| 134 | } |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 135 | #StdOut |
| 136 | width: 25 height: 35 color: kRGBA_8888_SkColorType alpha: kOpaque_SkAlphaType |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 137 | width: 0 height: 0 color: kUnknown_SkColorType alpha: kUnknown_SkAlphaType |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 138 | ## |
| 139 | ## |
| 140 | |
| 141 | #SeeAlso SkPixmap() SkAlphaType SkColorType |
| 142 | |
| 143 | ## |
| 144 | |
| 145 | # ------------------------------------------------------------------------------ |
| 146 | |
| 147 | #Method void reset(const SkImageInfo& info, const void* addr, size_t rowBytes) |
| 148 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 149 | #In Initialization |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 150 | Sets width, height, SkAlphaType, and SkColorType from info. |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 151 | Sets pixel address from addr, which may be nullptr. |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 152 | Sets row bytes from rowBytes, which should be info.width() times |
| 153 | info.bytesPerPixel(), or larger. |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 154 | |
| 155 | Does not check addr. Asserts if built with SK_DEBUG defined and if rowBytes is |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 156 | too small to hold one row of pixels. |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 157 | |
| 158 | The memory lifetime pixels are managed by the caller. When Pixmap goes |
| 159 | out of scope, addr is unaffected. |
| 160 | |
| 161 | #Param info width, height, SkAlphaType, SkColorType of Image_Info ## |
| 162 | #Param addr pointer to pixels allocated by caller; may be nullptr ## |
| 163 | #Param rowBytes size of one row of addr; width times pixel size, or larger ## |
| 164 | |
| 165 | #Example |
| 166 | #Image 4 |
Cary Clark | 2ade997 | 2017-11-02 17:49:34 -0400 | [diff] [blame] | 167 | #Height 64 |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 168 | void draw(SkCanvas* canvas) { |
| 169 | std::vector<int32_t> pixels; |
| 170 | pixels.resize(image->height() * image->width() * 4); |
| 171 | SkPixmap pixmap(SkImageInfo::Make(image->width(), image->height(), kN32_SkColorType, |
| 172 | image->alphaType()), (const void*) &pixels.front(), image->width() * 4); |
| 173 | image->readPixels(pixmap, 0, 0); |
| 174 | int x = 0; |
| 175 | for (auto colorType : { kRGBA_8888_SkColorType, kBGRA_8888_SkColorType } ) { |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 176 | pixmap.reset(SkImageInfo::Make(image->width(), image->height(), colorType, |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 177 | image->alphaType()), (const void*) &pixels.front(), image->width() * 4); |
| 178 | SkBitmap bitmap; |
| 179 | bitmap.installPixels(pixmap); |
| 180 | canvas->drawBitmap(bitmap, x, 0); |
| 181 | x += 128; |
| 182 | } |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 183 | } |
| 184 | ## |
| 185 | |
| 186 | #SeeAlso SkPixmap(const SkImageInfo& info, const void* addr, size_t rowBytes) reset() SkAlphaType SkColorType |
| 187 | |
| 188 | ## |
| 189 | |
| 190 | # ------------------------------------------------------------------------------ |
| 191 | |
| 192 | #Method void setColorSpace(sk_sp<SkColorSpace> colorSpace) |
| 193 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 194 | #In Initialization |
| 195 | #Line # sets Image_Info Color_Space ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 196 | |
| 197 | Changes Color_Space in Image_Info; preserves width, height, SkAlphaType, and |
| 198 | SkColorType in Image, and leaves pixel address and row bytes unchanged. |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 199 | Color_Space reference count is incremented. |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 200 | |
| 201 | #Param colorSpace Color_Space moved to Image_Info ## |
| 202 | |
| 203 | #Example |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 204 | void draw(SkCanvas* canvas) { |
| 205 | SkPixmap pixmap; |
| 206 | sk_sp<SkColorSpace> colorSpace1 = SkColorSpace::MakeRGB(SkColorSpace::kLinear_RenderTargetGamma, |
| 207 | SkColorSpace::kRec2020_Gamut); |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 208 | SkDebugf("is %sunique\n", colorSpace1->unique() ? "" : "not "); |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 209 | pixmap.setColorSpace(colorSpace1); |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 210 | SkDebugf("is %sunique\n", colorSpace1->unique() ? "" : "not "); |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 211 | } |
| 212 | #StdOut |
| 213 | is unique |
| 214 | is not unique |
| 215 | ## |
| 216 | ## |
| 217 | |
| 218 | #SeeAlso Color_Space SkImageInfo::makeColorSpace |
| 219 | |
| 220 | ## |
| 221 | |
| 222 | # ------------------------------------------------------------------------------ |
| 223 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame^] | 224 | #Method bool reset(const SkMask& mask) |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 225 | #Deprecated soon |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 226 | ## |
| 227 | |
| 228 | # ------------------------------------------------------------------------------ |
| 229 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame^] | 230 | #Method bool extractSubset(SkPixmap* subset, const SkIRect& area) const |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 231 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 232 | #In Initialization |
| 233 | #Line # sets pointer to portion of original ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 234 | Sets subset width, height, pixel address to intersection of Pixmap with area, |
| 235 | if intersection is not empty; and return true. Otherwise, leave subset unchanged |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 236 | and return false. |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 237 | |
| 238 | Failing to read the return value generates a compile time warning. |
| 239 | |
| 240 | #Param subset storage for width, height, pixel address of intersection ## |
| 241 | #Param area bounds to intersect with Pixmap ## |
| 242 | |
| 243 | #Return true if intersection of Pixmap and area is not empty ## |
| 244 | |
| 245 | #Example |
| 246 | #Image 3 |
| 247 | #Height 128 |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 248 | void draw(SkCanvas* canvas) { |
| 249 | std::vector<int32_t> pixels; |
| 250 | pixels.resize(image->height() * image->width() * 4); |
| 251 | SkPixmap pixmap(SkImageInfo::Make(image->width(), image->height(), kN32_SkColorType, |
| 252 | image->alphaType()), (const void*) &pixels.front(), image->width() * 4); |
| 253 | image->readPixels(pixmap, 0, 0); |
| 254 | SkPixmap inset; |
| 255 | if (pixmap.extractSubset(&inset, {128, 128, 512, 512})) { |
| 256 | SkBitmap bitmap; |
| 257 | bitmap.installPixels(inset); |
| 258 | canvas->drawBitmap(bitmap, 0, 0); |
| 259 | } |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 260 | } |
| 261 | ## |
| 262 | |
| 263 | #SeeAlso reset() SkIRect::intersect |
| 264 | |
| 265 | ## |
| 266 | |
| 267 | #Subtopic Initialization ## |
| 268 | |
| 269 | #Subtopic Image_Info_Access |
Cary Clark | 08895c4 | 2018-02-01 09:37:32 -0500 | [diff] [blame] | 270 | #Line # returns all or part of Image_Info ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 271 | |
| 272 | # ------------------------------------------------------------------------------ |
| 273 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 274 | #Method const SkImageInfo& info() const |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 275 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 276 | #In Image_Info_Access |
| 277 | #Line # returns Image_Info ## |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 278 | Returns width, height, Alpha_Type, Color_Type, and Color_Space. |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 279 | |
| 280 | #Return reference to ImageInfo ## |
| 281 | |
| 282 | #Example |
| 283 | #Image 3 |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 284 | std::vector<int32_t> pixels; |
| 285 | pixels.resize(image->height() * image->width() * 4); |
| 286 | SkPixmap pixmap(SkImageInfo::Make(image->width(), image->height(), kN32_SkColorType, |
| 287 | image->alphaType()), (const void*) &pixels.front(), image->width() * 4); |
| 288 | image->readPixels(pixmap, 0, 0); |
| 289 | SkPixmap inset; |
| 290 | if (pixmap.extractSubset(&inset, {128, 128, 512, 512})) { |
| 291 | const SkImageInfo& info = inset.info(); |
| 292 | const char* alphas[] = {"Unknown", "Opaque", "Premul", "Unpremul"}; |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 293 | const char* colors[] = {"Unknown", "Alpha_8", "RGB_565", "ARGB_4444", "RGBA_8888", |
| 294 | "RGB_888x", "BGRA_8888", "RGBA_1010102", "RGB_101010x", "Gray_8", "RGBA_F16"}; |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 295 | SkDebugf("width: %d height: %d color: %s alpha: %s\n", info.width(), info.height(), |
| 296 | colors[info.colorType()], alphas[info.alphaType()]); |
| 297 | } |
| 298 | #StdOut |
| 299 | width: 384 height: 384 color: BGRA_8888 alpha: Opaque |
| 300 | ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 301 | ## |
| 302 | |
| 303 | #SeeAlso Image_Info |
| 304 | |
| 305 | ## |
| 306 | |
| 307 | # ------------------------------------------------------------------------------ |
| 308 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 309 | #Method size_t rowBytes() const |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 310 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 311 | #In Image_Info_Access |
| 312 | #Line # returns interval between rows in bytes ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 313 | Returns row bytes, the interval from one pixel row to the next. Row bytes |
Cary Clark | 2be81cf | 2018-09-13 12:04:30 -0400 | [diff] [blame] | 314 | is at least as large as: #Formula # width() * info().bytesPerPixel() ##. |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 315 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 316 | Returns zero if colorType is kUnknown_SkColorType. |
| 317 | It is up to the Bitmap creator to ensure that row bytes is a useful value. |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 318 | |
| 319 | #Return byte length of pixel row ## |
| 320 | |
| 321 | #Example |
| 322 | SkPixmap badPixmap = {SkImageInfo::MakeA8(4, 4), nullptr, 2}; |
| 323 | SkPixmap okPixmap = {SkImageInfo::MakeA8(4, 4), nullptr, 8}; |
| 324 | for (auto& pixmap : { badPixmap, okPixmap } ) { |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 325 | SkDebugf("rowBytes: %d minRowBytes: %d\n", pixmap.rowBytes(), |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 326 | pixmap.info().minRowBytes()); |
| 327 | } |
| 328 | #StdOut |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 329 | rowBytes: 2 minRowBytes: 4 |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 330 | rowBytes: 8 minRowBytes: 4 |
| 331 | ## |
| 332 | ## |
| 333 | |
| 334 | #SeeAlso addr() info() SkImageInfo::minRowBytes |
| 335 | |
| 336 | ## |
| 337 | |
| 338 | # ------------------------------------------------------------------------------ |
| 339 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 340 | #Method const void* addr() const |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 341 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 342 | #In Image_Info_Access |
| 343 | #Line # returns readable pixel address as void pointer ## |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 344 | Returns pixel address, the base address corresponding to the pixel origin. |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 345 | |
| 346 | It is up to the Pixmap creator to ensure that pixel address is a useful value. |
| 347 | |
| 348 | #Return pixel address ## |
| 349 | |
| 350 | #Example |
| 351 | #Image 3 |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 352 | std::vector<int32_t> pixels; |
| 353 | pixels.resize(image->height() * image->width() * 4); |
| 354 | SkPixmap pixmap(SkImageInfo::Make(image->width(), image->height(), kN32_SkColorType, |
| 355 | image->alphaType()), (const void*) &pixels.front(), image->width() * 4); |
| 356 | image->readPixels(pixmap, 0, 0); |
| 357 | SkDebugf("pixels address: 0x%llx\n", pixmap.addr()); |
| 358 | SkPixmap inset; |
| 359 | if (pixmap.extractSubset(&inset, {128, 128, 512, 512})) { |
| 360 | SkDebugf("inset address: 0x%llx\n", inset.addr()); |
| 361 | } |
| 362 | #StdOut |
| 363 | #Volatile |
| 364 | pixels address: 0x7f2a440bb010 |
| 365 | inset address: 0x7f2a440fb210 |
| 366 | ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 367 | ## |
| 368 | |
| 369 | #SeeAlso addr(int x, int y) addr8 addr16 addr32 addr64 info() rowBytes() |
| 370 | |
| 371 | ## |
| 372 | |
| 373 | # ------------------------------------------------------------------------------ |
| 374 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 375 | #Method int width() const |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 376 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 377 | #In Image_Info_Access |
| 378 | #Line # returns pixel column count ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 379 | Returns pixel count in each pixel row. Should be equal or less than: |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 380 | |
Cary Clark | 2be81cf | 2018-09-13 12:04:30 -0400 | [diff] [blame] | 381 | #Formula # rowBytes() / info().bytesPerPixel() ##. |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 382 | |
| 383 | #Return pixel width in Image_Info ## |
| 384 | |
| 385 | #Example |
| 386 | SkImageInfo info = SkImageInfo::MakeA8(16, 32); |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 387 | SkPixmap pixmap(info, nullptr, 64); |
| 388 | SkDebugf("pixmap width: %d info width: %d\n", pixmap.width(), info.width()); |
| 389 | #StdOut |
| 390 | pixmap width: 16 info width: 16 |
| 391 | ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 392 | ## |
| 393 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 394 | #SeeAlso height() SkImageInfo::width() |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 395 | |
| 396 | ## |
| 397 | |
| 398 | # ------------------------------------------------------------------------------ |
| 399 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 400 | #Method int height() const |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 401 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 402 | #In Image_Info_Access |
| 403 | #Line # returns pixel row count ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 404 | Returns pixel row count. |
| 405 | |
| 406 | #Return pixel height in Image_Info ## |
| 407 | |
| 408 | #Example |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 409 | SkPixmap pixmap(SkImageInfo::MakeA8(16, 32), nullptr, 64); |
| 410 | SkDebugf("pixmap height: %d info height: %d\n", pixmap.height(), pixmap.info().height()); |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 411 | #StdOut |
| 412 | pixmap height: 32 info height: 32 |
| 413 | ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 414 | ## |
| 415 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 416 | #SeeAlso width() ImageInfo::height() |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 417 | |
| 418 | ## |
| 419 | |
| 420 | # ------------------------------------------------------------------------------ |
| 421 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 422 | #Method SkColorType colorType() const |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 423 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 424 | #In Image_Info_Access |
| 425 | #Line # returns Image_Info Color_Type ## |
Cary Clark | 1a8d762 | 2018-03-05 13:26:16 -0500 | [diff] [blame] | 426 | Returns Color_Type, one of: #list_of_color_types#. |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 427 | |
| 428 | #Return Color_Type in Image_Info ## |
| 429 | |
| 430 | #Example |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 431 | const char* colors[] = {"Unknown", "Alpha_8", "RGB_565", "ARGB_4444", "RGBA_8888", "RGB_888x", |
| 432 | "BGRA_8888", "RGBA_1010102", "RGB_101010x", "Gray_8", "RGBA_F16"}; |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 433 | SkPixmap pixmap(SkImageInfo::MakeA8(16, 32), nullptr, 64); |
| 434 | SkDebugf("color type: k" "%s" "_SkColorType\n", colors[pixmap.colorType()]); |
| 435 | #StdOut |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 436 | color type: kAlpha_8_SkColorType |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 437 | ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 438 | ## |
| 439 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 440 | #SeeAlso alphaType() SkImageInfo::colorType |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 441 | |
| 442 | ## |
| 443 | |
| 444 | # ------------------------------------------------------------------------------ |
| 445 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 446 | #Method SkAlphaType alphaType() const |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 447 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 448 | #In Image_Info_Access |
| 449 | #Line # returns Image_Info Alpha_Type ## |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 450 | Returns Alpha_Type, one of: #list_of_alpha_types#. |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 451 | |
| 452 | #Return Alpha_Type in Image_Info ## |
| 453 | |
| 454 | #Example |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 455 | const char* alphas[] = {"Unknown", "Opaque", "Premul", "Unpremul"}; |
| 456 | SkPixmap pixmap(SkImageInfo::MakeA8(16, 32), nullptr, 64); |
| 457 | SkDebugf("alpha type: k" "%s" "_SkAlphaType\n", alphas[pixmap.alphaType()]); |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 458 | #StdOut |
| 459 | alpha type: kPremul_SkAlphaType |
| 460 | ## |
| 461 | ## |
| 462 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 463 | #SeeAlso colorType() SkImageInfo::alphaType |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 464 | |
| 465 | ## |
| 466 | |
| 467 | # ------------------------------------------------------------------------------ |
| 468 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 469 | #Method SkColorSpace* colorSpace() const |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 470 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 471 | #In Image_Info_Access |
| 472 | #Line # returns Image_Info Color_Space ## |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 473 | Returns Color_Space, the range of colors, associated with Image_Info. The |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 474 | reference count of Color_Space is unchanged. The returned Color_Space is |
| 475 | immutable. |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 476 | |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 477 | #Return Color_Space in Image_Info, or nullptr ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 478 | |
| 479 | #Example |
| 480 | #Description |
| 481 | SkColorSpace::MakeSRGBLinear creates Color_Space with linear gamma |
| 482 | and an sRGB gamut. This Color_Space gamma is not close to sRGB gamma. |
| 483 | ## |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 484 | SkPixmap pixmap(SkImageInfo::MakeN32(16, 32, kPremul_SkAlphaType, |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 485 | SkColorSpace::MakeSRGBLinear()), nullptr, 64); |
| 486 | SkColorSpace* colorSpace = pixmap.colorSpace(); |
| 487 | SkDebugf("gammaCloseToSRGB: %s gammaIsLinear: %s isSRGB: %s\n", |
| 488 | colorSpace->gammaCloseToSRGB() ? "true" : "false", |
| 489 | colorSpace->gammaIsLinear() ? "true" : "false", |
| 490 | colorSpace->isSRGB() ? "true" : "false"); |
| 491 | #StdOut |
| 492 | gammaCloseToSRGB: false gammaIsLinear: true isSRGB: false |
| 493 | ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 494 | ## |
| 495 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 496 | #SeeAlso Color_Space SkImageInfo::colorSpace |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 497 | |
| 498 | ## |
| 499 | |
| 500 | # ------------------------------------------------------------------------------ |
| 501 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 502 | #Method bool isOpaque() const |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 503 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 504 | #In Image_Info_Access |
| 505 | #Line # returns true if Image_Info describes opaque pixels ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 506 | Returns true if Alpha_Type is kOpaque_SkAlphaType. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 507 | Does not check if Color_Type allows Alpha, or if any pixel value has |
| 508 | transparency. |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 509 | |
| 510 | #Return true if Image_Info has opaque Alpha_Type ## |
| 511 | |
| 512 | #Example |
| 513 | #Description |
| 514 | isOpaque ignores whether all pixels are opaque or not. |
| 515 | ## |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 516 | std::vector<uint32_t> pixels; |
| 517 | const int height = 2; |
| 518 | const int width = 2; |
| 519 | pixels.resize(height * width * 4); |
| 520 | SkPixmap pixmap(SkImageInfo::Make(width, height, kN32_SkColorType, |
| 521 | kPremul_SkAlphaType), (const void*) &pixels.front(), width * 4); |
| 522 | for (int index = 0; index < 2; ++index) { |
| 523 | pixmap.erase(0x00000000); |
| 524 | SkDebugf("isOpaque: %s\n", pixmap.isOpaque() ? "true" : "false"); |
| 525 | pixmap.erase(0xFFFFFFFF); |
| 526 | SkDebugf("isOpaque: %s\n", pixmap.isOpaque() ? "true" : "false"); |
| 527 | pixmap.reset(pixmap.info().makeAlphaType(kOpaque_SkAlphaType), |
| 528 | (const void*) &pixels.front(), width * 4); |
| 529 | } |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 530 | #StdOut |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 531 | isOpaque: false |
| 532 | isOpaque: false |
| 533 | isOpaque: true |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 534 | isOpaque: true |
| 535 | ## |
| 536 | ## |
| 537 | |
| 538 | #SeeAlso computeIsOpaque SkImageInfo::isOpaque |
| 539 | |
| 540 | ## |
| 541 | |
| 542 | # ------------------------------------------------------------------------------ |
| 543 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 544 | #Method SkIRect bounds() const |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 545 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 546 | #In Image_Info_Access |
| 547 | #Line # returns width and height as Rectangle ## |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 548 | Returns IRect { 0, 0, width(), height() }. |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 549 | |
| 550 | #Return integral rectangle from origin to width() and height() ## |
| 551 | |
| 552 | #Example |
| 553 | for (int width : { 0, 2 } ) { |
| 554 | for (int height : { 0, 2 } ) { |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 555 | SkPixmap pixmap(SkImageInfo::MakeA8(width, height), nullptr, width); |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 556 | SkDebugf("width: %d height: %d empty: %s\n", width, height, |
| 557 | pixmap.bounds().isEmpty() ? "true" : "false"); |
| 558 | } |
| 559 | } |
| 560 | #StdOut |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 561 | width: 0 height: 0 empty: true |
| 562 | width: 0 height: 2 empty: true |
| 563 | width: 2 height: 0 empty: true |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 564 | width: 2 height: 2 empty: false |
| 565 | ## |
| 566 | ## |
| 567 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 568 | #SeeAlso height() width() IRect |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 569 | |
| 570 | ## |
| 571 | |
| 572 | # ------------------------------------------------------------------------------ |
| 573 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 574 | #Method int rowBytesAsPixels() const |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 575 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 576 | #In Image_Info_Access |
| 577 | #Line # returns interval between rows in pixels ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 578 | |
| 579 | Returns number of pixels that fit on row. Should be greater than or equal to |
| 580 | width(). |
| 581 | |
| 582 | #Return maximum pixels per row ## |
| 583 | |
| 584 | #Example |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 585 | for (int rowBytes : { 4, 5, 6, 7, 8} ) { |
| 586 | SkPixmap pixmap(SkImageInfo::MakeN32(1, 1, kPremul_SkAlphaType), nullptr, rowBytes); |
| 587 | SkDebugf("rowBytes: %d rowBytesAsPixels: %d\n", rowBytes, pixmap.rowBytesAsPixels()); |
| 588 | } |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 589 | #StdOut |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 590 | rowBytes: 4 rowBytesAsPixels: 1 |
| 591 | rowBytes: 5 rowBytesAsPixels: 1 |
| 592 | rowBytes: 6 rowBytesAsPixels: 1 |
| 593 | rowBytes: 7 rowBytesAsPixels: 1 |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 594 | rowBytes: 8 rowBytesAsPixels: 2 |
| 595 | ## |
| 596 | ## |
| 597 | |
| 598 | #SeeAlso rowBytes shiftPerPixel width SkImageInfo::bytesPerPixel |
| 599 | |
| 600 | ## |
| 601 | |
| 602 | # ------------------------------------------------------------------------------ |
| 603 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 604 | #Method int shiftPerPixel() const |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 605 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 606 | #In Image_Info_Access |
| 607 | #Line # returns bit shift from pixels to bytes ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 608 | Returns bit shift converting row bytes to row pixels. |
| 609 | Returns zero for kUnknown_SkColorType. |
| 610 | |
| 611 | #Return one of: 0, 1, 2, 3; left shift to convert pixels to bytes ## |
| 612 | |
| 613 | #Example |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 614 | const char* colors[] = {"Unknown", "Alpha_8", "RGB_565", "ARGB_4444", "RGBA_8888", "RGB_888x", |
| 615 | "BGRA_8888", "RGBA_1010102", "RGB_101010x", "Gray_8", "RGBA_F16"}; |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 616 | SkImageInfo info = SkImageInfo::MakeA8(1, 1); |
| 617 | for (SkColorType colorType : { kUnknown_SkColorType, kAlpha_8_SkColorType, |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 618 | kRGB_565_SkColorType, kARGB_4444_SkColorType, |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 619 | kRGBA_8888_SkColorType, kBGRA_8888_SkColorType, |
| 620 | kGray_8_SkColorType, kRGBA_F16_SkColorType } ) { |
| 621 | SkPixmap pixmap(info.makeColorType(colorType), nullptr, 4); |
| 622 | SkDebugf("color: k" "%s" "_SkColorType" "%*s" "bytesPerPixel: %d shiftPerPixel: %d\n", |
| 623 | colors[colorType], 10 - strlen(colors[colorType]), " ", |
| 624 | pixmap.info().bytesPerPixel(), pixmap.shiftPerPixel()); |
| 625 | } |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 626 | #StdOut |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 627 | color: kUnknown_SkColorType bytesPerPixel: 0 shiftPerPixel: 0 |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 628 | color: kAlpha_8_SkColorType bytesPerPixel: 1 shiftPerPixel: 0 |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 629 | color: kRGB_565_SkColorType bytesPerPixel: 2 shiftPerPixel: 1 |
| 630 | color: kARGB_4444_SkColorType bytesPerPixel: 2 shiftPerPixel: 1 |
| 631 | color: kRGBA_8888_SkColorType bytesPerPixel: 4 shiftPerPixel: 2 |
| 632 | color: kBGRA_8888_SkColorType bytesPerPixel: 4 shiftPerPixel: 2 |
| 633 | color: kGray_8_SkColorType bytesPerPixel: 1 shiftPerPixel: 0 |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 634 | color: kRGBA_F16_SkColorType bytesPerPixel: 8 shiftPerPixel: 3 |
| 635 | ## |
| 636 | ## |
| 637 | |
| 638 | #SeeAlso rowBytes rowBytesAsPixels width SkImageInfo::bytesPerPixel |
| 639 | |
| 640 | ## |
| 641 | |
| 642 | # ------------------------------------------------------------------------------ |
| 643 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 644 | #Method size_t computeByteSize() const |
| 645 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 646 | #In Image_Info_Access |
| 647 | #Line # returns size required for pixels ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 648 | Returns minimum memory required for pixel storage. |
| 649 | Does not include unused memory on last row when rowBytesAsPixels exceeds width(). |
| 650 | Returns zero if result does not fit in size_t. |
| 651 | Returns zero if height() or width() is 0. |
| 652 | Returns height() times rowBytes if colorType is kUnknown_SkColorType. |
| 653 | |
| 654 | #Return size in bytes of image buffer ## |
| 655 | |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 656 | #Example |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 657 | SkPixmap pixmap; |
| 658 | for (int width : { 1, 1000, 1000000 } ) { |
| 659 | for (int height: { 1, 1000, 1000000 } ) { |
| 660 | SkImageInfo imageInfo = SkImageInfo::MakeN32(width, height, kPremul_SkAlphaType); |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 661 | pixmap.reset(imageInfo, nullptr, width * 5); |
| 662 | SkDebugf("width: %7d height: %7d computeByteSize: %13lld\n", width, height, |
| 663 | pixmap.computeByteSize()); |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 664 | } |
| 665 | } |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 666 | #StdOut |
Ben Wagner | 29380bd | 2017-10-09 14:43:00 -0400 | [diff] [blame] | 667 | width: 1 height: 1 computeByteSize: 4 |
| 668 | width: 1 height: 1000 computeByteSize: 4999 |
| 669 | width: 1 height: 1000000 computeByteSize: 4999999 |
| 670 | width: 1000 height: 1 computeByteSize: 4000 |
| 671 | width: 1000 height: 1000 computeByteSize: 4999000 |
| 672 | width: 1000 height: 1000000 computeByteSize: 4999999000 |
| 673 | width: 1000000 height: 1 computeByteSize: 4000000 |
| 674 | width: 1000000 height: 1000 computeByteSize: 4999000000 |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 675 | width: 1000000 height: 1000000 computeByteSize: 4999999000000 |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 676 | ## |
| 677 | ## |
| 678 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 679 | #SeeAlso SkImageInfo::computeByteSize |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 680 | |
| 681 | ## |
| 682 | |
| 683 | #Subtopic Image_Info_Access ## |
| 684 | |
| 685 | #Subtopic Reader |
Cary Clark | 08895c4 | 2018-02-01 09:37:32 -0500 | [diff] [blame] | 686 | #Line # examine pixel value ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 687 | |
| 688 | # ------------------------------------------------------------------------------ |
| 689 | |
| 690 | #Method bool computeIsOpaque() const |
| 691 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 692 | #In Reader |
| 693 | #Line # returns true if all pixels are opaque ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 694 | Returns true if all pixels are opaque. Color_Type determines how pixels |
| 695 | are encoded, and whether pixel describes Alpha. Returns true for Color_Types |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 696 | without alpha in each pixel; for other Color_Types, returns true if all |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 697 | pixels have alpha values equivalent to 1.0 or greater. |
| 698 | |
| 699 | For Color_Types kRGB_565_SkColorType or kGray_8_SkColorType: always |
| 700 | returns true. For Color_Types kAlpha_8_SkColorType, kBGRA_8888_SkColorType, |
| 701 | kRGBA_8888_SkColorType: returns true if all pixel Alpha values are 255. |
| 702 | For Color_Type kARGB_4444_SkColorType: returns true if all pixel Alpha values are 15. |
| 703 | For kRGBA_F16_SkColorType: returns true if all pixel Alpha values are 1.0 or |
| 704 | greater. |
| 705 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 706 | Returns false for kUnknown_SkColorType. |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 707 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 708 | #Return true if all pixels have opaque values or Color_Type is opaque ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 709 | |
| 710 | #Example |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 711 | std::vector<uint32_t> pixels; |
| 712 | const int height = 2; |
| 713 | const int width = 2; |
| 714 | pixels.resize(height * width * 4); |
| 715 | SkPixmap pixmap(SkImageInfo::Make(width, height, kN32_SkColorType, |
| 716 | kPremul_SkAlphaType), (const void*) &pixels.front(), width * 4); |
| 717 | for (int index = 0; index < 2; ++index) { |
| 718 | pixmap.erase(0x00000000); |
| 719 | SkDebugf("computeIsOpaque: %s\n", pixmap.computeIsOpaque() ? "true" : "false"); |
| 720 | pixmap.erase(0xFFFFFFFF); |
| 721 | SkDebugf("computeIsOpaque: %s\n", pixmap.computeIsOpaque() ? "true" : "false"); |
| 722 | pixmap.reset(pixmap.info().makeAlphaType(kOpaque_SkAlphaType), |
| 723 | (const void*) &pixels.front(), width * 4); |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 724 | } |
| 725 | #StdOut |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 726 | computeIsOpaque: false |
| 727 | computeIsOpaque: true |
| 728 | computeIsOpaque: false |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 729 | computeIsOpaque: true |
| 730 | ## |
| 731 | ## |
| 732 | |
| 733 | #SeeAlso isOpaque Color_Type Alpha |
| 734 | |
| 735 | ## |
| 736 | |
| 737 | # ------------------------------------------------------------------------------ |
| 738 | |
| 739 | #Method SkColor getColor(int x, int y) const |
| 740 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 741 | #In Reader |
| 742 | #Line # returns one pixel as Unpremultiplied Color ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 743 | Returns pixel at (x, y) as Unpremultiplied Color. |
| 744 | Returns black with Alpha if Color_Type is kAlpha_8_SkColorType. |
| 745 | |
| 746 | Input is not validated: out of bounds values of x or y trigger an assert() if |
| 747 | built with SK_DEBUG defined; and returns undefined values or may crash if |
| 748 | SK_RELEASE is defined. Fails if Color_Type is kUnknown_SkColorType or |
| 749 | pixel address is nullptr. |
| 750 | |
| 751 | Color_Space in Image_Info is ignored. Some Color precision may be lost in the |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 752 | conversion to Unpremultiplied Color; original pixel data may have additional |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 753 | precision. |
| 754 | |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 755 | #Param x column index, zero or greater, and less than width() ## |
| 756 | #Param y row index, zero or greater, and less than height() ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 757 | |
| 758 | #Return pixel converted to Unpremultiplied Color ## |
| 759 | |
| 760 | #Example |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 761 | const int w = 4; |
| 762 | const int h = 4; |
| 763 | std::vector<SkPMColor> storage; |
| 764 | storage.resize(w * h); |
| 765 | SkDebugf("Premultiplied:\n"); |
| 766 | for (int y = 0; y < h; ++y) { |
| 767 | SkDebugf("(0, %d) ", y); |
| 768 | for (int x = 0; x < w; ++x) { |
| 769 | int a = 0xFF * (x + y) / (w - 1 + h - 1); |
| 770 | storage[x + y * w] = SkPackARGB32(a, a * x / (w - 1), a * y / (h - 1), a); |
| 771 | SkDebugf("0x%08x%c", storage[x + y * w], x == w - 1 ? '\n' : ' '); |
| 772 | } |
| 773 | } |
| 774 | SkPixmap pixmap(SkImageInfo::MakeN32(w, h, kPremul_SkAlphaType), &storage.front(), w * 4); |
| 775 | SkDebugf("Unpremultiplied:\n"); |
| 776 | for (int y = 0; y < h; ++y) { |
| 777 | SkDebugf("(0, %d) ", y); |
| 778 | for (int x = 0; x < w; ++x) { |
| 779 | SkDebugf("0x%08x%c", pixmap.getColor(x, y), x == w - 1 ? '\n' : ' '); |
| 780 | } |
| 781 | } |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 782 | #StdOut |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 783 | Premultiplied: |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 784 | (0, 0) 0x00000000 0x2a0e002a 0x55380055 0x7f7f007f |
| 785 | (0, 1) 0x2a000e2a 0x551c1c55 0x7f542a7f 0xaaaa38aa |
| 786 | (0, 2) 0x55003855 0x7f2a547f 0xaa7171aa 0xd4d48dd4 |
| 787 | (0, 3) 0x7f007f7f 0xaa38aaaa 0xd48dd4d4 0xffffffff |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 788 | Unpremultiplied: |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 789 | (0, 0) 0x00000000 0x2a5500ff 0x55a800ff 0x7fff00ff |
| 790 | (0, 1) 0x2a0055ff 0x555454ff 0x7fa954ff 0xaaff54ff |
| 791 | (0, 2) 0x5500a8ff 0x7f54a9ff 0xaaaaaaff 0xd4ffaaff |
| 792 | (0, 3) 0x7f00ffff 0xaa54ffff 0xd4aaffff 0xffffffff |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 793 | ## |
| 794 | ## |
| 795 | |
Cary Clark | 8fe2940 | 2018-09-20 17:31:43 -0400 | [diff] [blame] | 796 | #SeeAlso getAlphaf addr() readPixels |
| 797 | |
| 798 | ## |
| 799 | |
| 800 | #Method float getAlphaf(int x, int y) const |
| 801 | #In Property |
| 802 | #Line # returns Alpha normalized from zero to one ## |
| 803 | |
| 804 | Looks up the pixel at (x,y) and return its alpha component, normalized to [0..1]. |
| 805 | This is roughly equivalent to #Formula # SkGetColorA(getColor()) ##, but can be more efficent |
| 806 | (and more precise if the pixels store more than 8 bits per component). |
| 807 | |
| 808 | #Param x column index, zero or greater, and less than width() ## |
| 809 | #Param y row index, zero or greater, and less than height() ## |
| 810 | |
| 811 | #Return alpha converted to normalized float ## |
| 812 | |
| 813 | #NoExample |
| 814 | ## |
| 815 | |
| 816 | #SeeAlso getColor |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 817 | |
| 818 | ## |
| 819 | |
| 820 | #Subtopic Reader ## |
| 821 | |
| 822 | #Subtopic Readable_Address |
Cary Clark | 08895c4 | 2018-02-01 09:37:32 -0500 | [diff] [blame] | 823 | #Line # returns read only pixels ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 824 | |
| 825 | # ------------------------------------------------------------------------------ |
| 826 | |
| 827 | #Method const void* addr(int x, int y) const |
| 828 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 829 | #In Readable_Address |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 830 | Returns readable pixel address at (x, y). Returns nullptr if Pixel_Ref is nullptr. |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 831 | |
| 832 | Input is not validated: out of bounds values of x or y trigger an assert() if |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 833 | built with SK_DEBUG defined. Returns nullptr if Color_Type is kUnknown_SkColorType. |
| 834 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 835 | Performs a lookup of pixel size; for better performance, call |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 836 | one of: addr8, addr16, addr32, addr64, or addrF16. |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 837 | |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 838 | #Param x column index, zero or greater, and less than width() ## |
| 839 | #Param y row index, zero or greater, and less than height() ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 840 | |
| 841 | #Return readable generic pointer to pixel ## |
| 842 | |
| 843 | #Example |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 844 | const int w = 4; |
| 845 | const int h = 4; |
| 846 | std::vector<SkPMColor> storage; |
| 847 | storage.resize(w * h); |
| 848 | SkPixmap pixmap(SkImageInfo::MakeN32(w, h, kPremul_SkAlphaType), &storage.front(), w * 4); |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 849 | SkDebugf("pixmap.addr(1, 2) %c= &storage[1 + 2 * w]\n", |
| 850 | pixmap.addr(1, 2) == &storage[1 + 2 * w] ? '=' : '!'); |
| 851 | #StdOut |
| 852 | pixmap.addr(1, 2) == &storage[1 + 2 * w] |
| 853 | ## |
| 854 | ## |
| 855 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 856 | #SeeAlso addr8 addr16 addr32 addr64 addrF16 getColor writable_addr SkBitmap::getAddr |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 857 | |
| 858 | ## |
| 859 | |
| 860 | # ------------------------------------------------------------------------------ |
| 861 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 862 | #Method const uint8_t* addr8() const |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 863 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 864 | #In Readable_Address |
| 865 | #Line # returns readable pixel address as 8-bit pointer ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 866 | Returns readable base pixel address. Result is addressable as unsigned 8-bit bytes. |
| 867 | Will trigger an assert() if Color_Type is not kAlpha_8_SkColorType or |
| 868 | kGray_8_SkColorType, and is built with SK_DEBUG defined. |
| 869 | |
| 870 | One byte corresponds to one pixel. |
| 871 | |
| 872 | #Return readable unsigned 8-bit pointer to pixels ## |
| 873 | |
| 874 | #Example |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 875 | const int w = 4; |
| 876 | const int h = 4; |
| 877 | uint8_t storage[w * h]; |
| 878 | SkPixmap pixmap(SkImageInfo::Make(w, h, kGray_8_SkColorType, kPremul_SkAlphaType), |
| 879 | storage, w * sizeof(storage[0])); |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 880 | SkDebugf("pixmap.addr8() %c= storage\n", |
| 881 | pixmap.addr8() == storage ? '=' : '!'); |
| 882 | #StdOut |
| 883 | pixmap.addr8() == storage |
| 884 | ## |
| 885 | ## |
| 886 | |
| 887 | #SeeAlso addr() addr16 addr32 addr64 addrF16 getColor writable_addr writable_addr8 |
| 888 | |
| 889 | ## |
| 890 | |
| 891 | # ------------------------------------------------------------------------------ |
| 892 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 893 | #Method const uint16_t* addr16() const |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 894 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 895 | #In Readable_Address |
| 896 | #Line # returns readable pixel address as 16-bit pointer ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 897 | Returns readable base pixel address. Result is addressable as unsigned 16-bit words. |
| 898 | Will trigger an assert() if Color_Type is not kRGB_565_SkColorType or |
| 899 | kARGB_4444_SkColorType, and is built with SK_DEBUG defined. |
| 900 | |
| 901 | One word corresponds to one pixel. |
| 902 | |
| 903 | #Return readable unsigned 16-bit pointer to pixels ## |
| 904 | |
| 905 | #Example |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 906 | const int w = 4; |
| 907 | const int h = 4; |
| 908 | uint16_t storage[w * h]; |
| 909 | SkPixmap pixmap(SkImageInfo::Make(w, h, kARGB_4444_SkColorType, kPremul_SkAlphaType), |
| 910 | storage, w * sizeof(storage[0])); |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 911 | SkDebugf("pixmap.addr16() %c= storage\n", |
| 912 | pixmap.addr16() == storage ? '=' : '!'); |
| 913 | #StdOut |
| 914 | pixmap.addr16() == storage |
| 915 | ## |
| 916 | ## |
| 917 | |
| 918 | #SeeAlso addr() addr8 addr32 addr64 addrF16 getColor writable_addr writable_addr16 |
| 919 | |
| 920 | ## |
| 921 | |
| 922 | # ------------------------------------------------------------------------------ |
| 923 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 924 | #Method const uint32_t* addr32() const |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 925 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 926 | #In Readable_Address |
| 927 | #Line # returns readable pixel address as 32-bit pointer ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 928 | Returns readable base pixel address. Result is addressable as unsigned 32-bit words. |
| 929 | Will trigger an assert() if Color_Type is not kRGBA_8888_SkColorType or |
| 930 | kBGRA_8888_SkColorType, and is built with SK_DEBUG defined. |
| 931 | |
| 932 | One word corresponds to one pixel. |
| 933 | |
| 934 | #Return readable unsigned 32-bit pointer to pixels ## |
| 935 | |
| 936 | #Example |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 937 | const int w = 4; |
| 938 | const int h = 4; |
| 939 | uint32_t storage[w * h]; |
| 940 | SkPixmap pixmap(SkImageInfo::MakeN32(w, h, kPremul_SkAlphaType), |
| 941 | storage, w * sizeof(storage[0])); |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 942 | SkDebugf("pixmap.addr32() %c= storage\n", |
| 943 | pixmap.addr32() == storage ? '=' : '!'); |
| 944 | #StdOut |
| 945 | pixmap.addr32() == storage |
| 946 | ## |
| 947 | ## |
| 948 | |
| 949 | #SeeAlso addr() addr8 addr16 addr64 addrF16 getColor writable_addr writable_addr32 |
| 950 | |
| 951 | ## |
| 952 | |
| 953 | # ------------------------------------------------------------------------------ |
| 954 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 955 | #Method const uint64_t* addr64() const |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 956 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 957 | #In Readable_Address |
| 958 | #Line # returns readable pixel address as 64-bit pointer ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 959 | Returns readable base pixel address. Result is addressable as unsigned 64-bit words. |
| 960 | Will trigger an assert() if Color_Type is not kRGBA_F16_SkColorType and is built |
| 961 | with SK_DEBUG defined. |
| 962 | |
| 963 | One word corresponds to one pixel. |
| 964 | |
| 965 | #Return readable unsigned 64-bit pointer to pixels ## |
| 966 | |
| 967 | #Example |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 968 | const int w = 4; |
| 969 | const int h = 4; |
| 970 | uint64_t storage[w * h]; |
| 971 | SkPixmap pixmap(SkImageInfo::Make(w, h, kRGBA_F16_SkColorType, kPremul_SkAlphaType), |
| 972 | storage, w * sizeof(storage[0])); |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 973 | SkDebugf("pixmap.addr64() %c= storage\n", |
| 974 | pixmap.addr64() == storage ? '=' : '!'); |
| 975 | #StdOut |
| 976 | pixmap.addr64() == storage |
| 977 | ## |
| 978 | ## |
| 979 | |
| 980 | #SeeAlso addr() addr8 addr16 addr32 addrF16 getColor writable_addr writable_addr64 |
| 981 | |
| 982 | ## |
| 983 | |
| 984 | # ------------------------------------------------------------------------------ |
| 985 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 986 | #Method const uint16_t* addrF16() const |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 987 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 988 | #In Readable_Address |
| 989 | #Line # returns readable pixel component address as 16-bit pointer ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 990 | Returns readable base pixel address. Result is addressable as unsigned 16-bit words. |
| 991 | Will trigger an assert() if Color_Type is not kRGBA_F16_SkColorType and is built |
| 992 | with SK_DEBUG defined. |
| 993 | |
| 994 | Each word represents one color component encoded as a half float. |
| 995 | Four words correspond to one pixel. |
| 996 | |
| 997 | #Return readable unsigned 16-bit pointer to first component of pixels ## |
| 998 | |
| 999 | #Example |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1000 | const int w = 4; |
| 1001 | const int h = 4; |
| 1002 | uint16_t storage[w * h * 4]; |
| 1003 | SkPixmap pixmap(SkImageInfo::Make(w, h, kRGBA_F16_SkColorType, kPremul_SkAlphaType), |
| 1004 | storage, w * 4 * sizeof(storage[0])); |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1005 | SkDebugf("pixmap.addrF16() %c= storage\n", |
| 1006 | pixmap.addrF16() == storage ? '=' : '!'); |
| 1007 | #StdOut |
| 1008 | pixmap.addrF16() == storage |
| 1009 | ## |
| 1010 | ## |
| 1011 | |
| 1012 | #SeeAlso addr() addr8 addr16 addr32 addr64 getColor writable_addr writable_addrF16 |
| 1013 | |
| 1014 | ## |
| 1015 | |
| 1016 | # ------------------------------------------------------------------------------ |
| 1017 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 1018 | #Method const uint8_t* addr8(int x, int y) const |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1019 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 1020 | #In Readable_Address |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1021 | Returns readable pixel address at (x, y). |
| 1022 | |
| 1023 | Input is not validated: out of bounds values of x or y trigger an assert() if |
| 1024 | built with SK_DEBUG defined. |
| 1025 | |
| 1026 | Will trigger an assert() if Color_Type is not kAlpha_8_SkColorType or |
| 1027 | kGray_8_SkColorType, and is built with SK_DEBUG defined. |
| 1028 | |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1029 | #Param x column index, zero or greater, and less than width() ## |
| 1030 | #Param y row index, zero or greater, and less than height() ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1031 | |
| 1032 | #Return readable unsigned 8-bit pointer to pixel at (x, y) ## |
| 1033 | |
| 1034 | #Example |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1035 | const int w = 4; |
| 1036 | const int h = 4; |
| 1037 | uint8_t storage[w * h]; |
| 1038 | SkPixmap pixmap(SkImageInfo::Make(w, h, kGray_8_SkColorType, kPremul_SkAlphaType), |
| 1039 | storage, w * sizeof(storage[0])); |
| 1040 | SkDebugf("pixmap.addr8(1, 2) %c= &storage[1 + 2 * w]\n", |
| 1041 | pixmap.addr8(1, 2) == &storage[1 + 2 * w] ? '=' : '!'); |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1042 | #StdOut |
| 1043 | pixmap.addr8(1, 2) == &storage[1 + 2 * w] |
| 1044 | ## |
| 1045 | ## |
| 1046 | |
| 1047 | #SeeAlso addr() addr16 addr32 addr64 addrF16 getColor writable_addr writable_addr8 |
| 1048 | |
| 1049 | ## |
| 1050 | |
| 1051 | # ------------------------------------------------------------------------------ |
| 1052 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 1053 | #Method const uint16_t* addr16(int x, int y) const |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1054 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 1055 | #In Readable_Address |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1056 | Returns readable pixel address at (x, y). |
| 1057 | |
| 1058 | Input is not validated: out of bounds values of x or y trigger an assert() if |
| 1059 | built with SK_DEBUG defined. |
| 1060 | |
| 1061 | Will trigger an assert() if Color_Type is not kRGB_565_SkColorType or |
| 1062 | kARGB_4444_SkColorType, and is built with SK_DEBUG defined. |
| 1063 | |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1064 | #Param x column index, zero or greater, and less than width() ## |
| 1065 | #Param y row index, zero or greater, and less than height() ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1066 | |
| 1067 | #Return readable unsigned 16-bit pointer to pixel at (x, y) ## |
| 1068 | |
| 1069 | #Example |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1070 | const int w = 4; |
| 1071 | const int h = 4; |
| 1072 | uint16_t storage[w * h]; |
| 1073 | SkPixmap pixmap(SkImageInfo::Make(w, h, kARGB_4444_SkColorType, kPremul_SkAlphaType), |
| 1074 | storage, w * sizeof(storage[0])); |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1075 | SkDebugf("pixmap.addr16(1, 2) %c= &storage[1 + 2 * w]\n", |
| 1076 | pixmap.addr16(1, 2) == &storage[1 + 2 * w] ? '=' : '!'); |
| 1077 | #StdOut |
| 1078 | pixmap.addr16(1, 2) == &storage[1 + 2 * w] |
| 1079 | ## |
| 1080 | ## |
| 1081 | |
| 1082 | #SeeAlso addr() addr8 addr32 addr64 addrF16 getColor writable_addr writable_addr16 |
| 1083 | |
| 1084 | ## |
| 1085 | |
| 1086 | # ------------------------------------------------------------------------------ |
| 1087 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 1088 | #Method const uint32_t* addr32(int x, int y) const |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1089 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 1090 | #In Readable_Address |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1091 | Returns readable pixel address at (x, y). |
| 1092 | |
| 1093 | Input is not validated: out of bounds values of x or y trigger an assert() if |
| 1094 | built with SK_DEBUG defined. |
| 1095 | |
| 1096 | Will trigger an assert() if Color_Type is not kRGBA_8888_SkColorType or |
| 1097 | kBGRA_8888_SkColorType, and is built with SK_DEBUG defined. |
| 1098 | |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1099 | #Param x column index, zero or greater, and less than width() ## |
| 1100 | #Param y row index, zero or greater, and less than height() ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1101 | |
| 1102 | #Return readable unsigned 32-bit pointer to pixel at (x, y) ## |
| 1103 | |
| 1104 | #Example |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1105 | const int w = 4; |
| 1106 | const int h = 4; |
| 1107 | uint32_t storage[w * h]; |
| 1108 | SkPixmap pixmap(SkImageInfo::Make(w, h, kRGBA_8888_SkColorType, kPremul_SkAlphaType), |
| 1109 | storage, w * sizeof(storage[0])); |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1110 | SkDebugf("pixmap.addr32(1, 2) %c= &storage[1 + 2 * w]\n", |
| 1111 | pixmap.addr32(1, 2) == &storage[1 + 2 * w] ? '=' : '!'); |
| 1112 | #StdOut |
| 1113 | pixmap.addr32(1, 2) == &storage[1 + 2 * w] |
| 1114 | ## |
| 1115 | ## |
| 1116 | |
Cary Clark | 2ade997 | 2017-11-02 17:49:34 -0400 | [diff] [blame] | 1117 | #SeeAlso addr() addr8 addr16 addr64 addrF16 getColor writable_addr writable_addr64 |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1118 | |
| 1119 | ## |
| 1120 | |
| 1121 | # ------------------------------------------------------------------------------ |
| 1122 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 1123 | #Method const uint64_t* addr64(int x, int y) const |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1124 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 1125 | #In Readable_Address |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1126 | Returns readable pixel address at (x, y). |
| 1127 | |
| 1128 | Input is not validated: out of bounds values of x or y trigger an assert() if |
| 1129 | built with SK_DEBUG defined. |
| 1130 | |
| 1131 | Will trigger an assert() if Color_Type is not kRGBA_F16_SkColorType and is built |
| 1132 | with SK_DEBUG defined. |
| 1133 | |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1134 | #Param x column index, zero or greater, and less than width() ## |
| 1135 | #Param y row index, zero or greater, and less than height() ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1136 | |
| 1137 | #Return readable unsigned 64-bit pointer to pixel at (x, y) ## |
| 1138 | |
| 1139 | #Example |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1140 | const int w = 4; |
| 1141 | const int h = 4; |
| 1142 | uint64_t storage[w * h]; |
| 1143 | SkPixmap pixmap(SkImageInfo::Make(w, h, kRGBA_F16_SkColorType, kPremul_SkAlphaType), |
| 1144 | storage, w * sizeof(storage[0])); |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1145 | SkDebugf("pixmap.addr64(1, 2) %c= &storage[1 + 2 * w]\n", |
| 1146 | pixmap.addr64(1, 2) == &storage[1 + 2 * w] ? '=' : '!'); |
| 1147 | #StdOut |
| 1148 | pixmap.addr64(1, 2) == &storage[1 + 2 * w] |
| 1149 | ## |
| 1150 | ## |
| 1151 | |
| 1152 | #SeeAlso addr() addr8 addr16 addr32 addrF16 getColor writable_addr writable_addr64 |
| 1153 | |
| 1154 | ## |
| 1155 | |
| 1156 | # ------------------------------------------------------------------------------ |
| 1157 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 1158 | #Method const uint16_t* addrF16(int x, int y) const |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1159 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 1160 | #In Readable_Address |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1161 | Returns readable pixel address at (x, y). |
| 1162 | |
| 1163 | Input is not validated: out of bounds values of x or y trigger an assert() if |
| 1164 | built with SK_DEBUG defined. |
| 1165 | |
| 1166 | Will trigger an assert() if Color_Type is not kRGBA_F16_SkColorType and is built |
| 1167 | with SK_DEBUG defined. |
| 1168 | |
| 1169 | Each unsigned 16-bit word represents one color component encoded as a half float. |
| 1170 | Four words correspond to one pixel. |
| 1171 | |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1172 | #Param x column index, zero or greater, and less than width() ## |
| 1173 | #Param y row index, zero or greater, and less than height() ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1174 | |
| 1175 | #Return readable unsigned 16-bit pointer to pixel component at (x, y) ## |
| 1176 | |
| 1177 | #Example |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1178 | const int w = 4; |
| 1179 | const int h = 4; |
| 1180 | const int wordsPerPixel = 4; |
| 1181 | const int rowWords = w * wordsPerPixel; |
| 1182 | uint16_t storage[rowWords * h]; |
| 1183 | SkPixmap pixmap(SkImageInfo::Make(w, h, kRGBA_F16_SkColorType, kPremul_SkAlphaType), |
| 1184 | storage, rowWords * sizeof(storage[0])); |
| 1185 | SkDebugf("pixmap.addrF16(1, 2) %c= &storage[1 * wordsPerPixel + 2 * rowWords]\n", |
| 1186 | pixmap.addrF16(1, 2) == &storage[1 * wordsPerPixel + 2 * rowWords] ? '=' : '!'); |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1187 | #StdOut |
| 1188 | pixmap.addrF16(1, 2) == &storage[1 * wordsPerPixel + 2 * rowWords] |
| 1189 | ## |
| 1190 | ## |
| 1191 | |
| 1192 | #SeeAlso addr() addr8 addr16 addr32 addr64 getColor writable_addr writable_addrF16 |
| 1193 | |
| 1194 | ## |
| 1195 | |
| 1196 | #Subtopic Readable_Address ## |
| 1197 | |
| 1198 | #Subtopic Writable_Address |
Cary Clark | 08895c4 | 2018-02-01 09:37:32 -0500 | [diff] [blame] | 1199 | #Line # returns writable pixels ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1200 | |
| 1201 | # ------------------------------------------------------------------------------ |
| 1202 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 1203 | #Method void* writable_addr() const |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1204 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 1205 | #In Writable_Address |
| 1206 | #Line # returns writable pixel address as void pointer ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1207 | Returns writable base pixel address. |
| 1208 | |
| 1209 | #Return writable generic base pointer to pixels ## |
| 1210 | |
| 1211 | #Example |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1212 | const int w = 4; |
| 1213 | const int h = 4; |
| 1214 | SkPMColor storage[w * h * 4]; |
| 1215 | SkPixmap pixmap(SkImageInfo::MakeN32(w, h, kPremul_SkAlphaType), storage, w * 4); |
| 1216 | SkDebugf("pixmap.writable_addr() %c= (void *)storage\n", |
| 1217 | pixmap.writable_addr() == (void *)storage ? '=' : '!'); |
| 1218 | pixmap.erase(0x00000000); |
| 1219 | *(SkPMColor*)pixmap.writable_addr() = 0xFFFFFFFF; |
| 1220 | SkDebugf("pixmap.getColor(0, 1) %c= 0x00000000\n", |
| 1221 | pixmap.getColor(0, 1) == 0x00000000 ? '=' : '!'); |
| 1222 | SkDebugf("pixmap.getColor(0, 0) %c= 0xFFFFFFFF\n", |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1223 | pixmap.getColor(0, 0) == 0xFFFFFFFF ? '=' : '!'); |
| 1224 | #StdOut |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1225 | pixmap.writable_addr() == (void *)storage |
| 1226 | pixmap.getColor(0, 1) == 0x00000000 |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1227 | pixmap.getColor(0, 0) == 0xFFFFFFFF |
| 1228 | ## |
| 1229 | ## |
| 1230 | |
| 1231 | #SeeAlso writable_addr8 writable_addr16 writable_addr32 writable_addr64 writable_addrF16 addr() |
| 1232 | |
| 1233 | ## |
| 1234 | |
| 1235 | # ------------------------------------------------------------------------------ |
| 1236 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 1237 | #Method void* writable_addr(int x, int y) const |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1238 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 1239 | #In Writable_Address |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1240 | Returns writable pixel address at (x, y). |
| 1241 | |
| 1242 | Input is not validated: out of bounds values of x or y trigger an assert() if |
| 1243 | built with SK_DEBUG defined. Returns zero if Color_Type is kUnknown_SkColorType. |
| 1244 | |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1245 | #Param x column index, zero or greater, and less than width() ## |
| 1246 | #Param y row index, zero or greater, and less than height() ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1247 | |
| 1248 | #Return writable generic pointer to pixel ## |
| 1249 | |
| 1250 | #Example |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1251 | const int w = 4; |
| 1252 | const int h = 4; |
| 1253 | SkPMColor storage[w * h * 4]; |
| 1254 | SkPixmap pixmap(SkImageInfo::MakeN32(w, h, kPremul_SkAlphaType), storage, w * 4); |
| 1255 | SkDebugf("pixmap.writable_addr() %c= (void *)storage\n", |
| 1256 | pixmap.writable_addr() == (void *)storage ? '=' : '!'); |
| 1257 | pixmap.erase(0x00000000); |
| 1258 | *(SkPMColor*)pixmap.writable_addr(1, 2) = 0xFFFFFFFF; |
| 1259 | SkDebugf("pixmap.getColor(0, 0) %c= 0x00000000\n", |
| 1260 | pixmap.getColor(0, 0) == 0x00000000 ? '=' : '!'); |
| 1261 | SkDebugf("pixmap.getColor(1, 2) %c= 0xFFFFFFFF\n", |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1262 | pixmap.getColor(1, 2) == 0xFFFFFFFF ? '=' : '!'); |
| 1263 | #StdOut |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1264 | pixmap.writable_addr() == (void *)storage |
| 1265 | pixmap.getColor(0, 0) == 0x00000000 |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1266 | pixmap.getColor(1, 2) == 0xFFFFFFFF |
| 1267 | ## |
| 1268 | ## |
| 1269 | |
| 1270 | #SeeAlso writable_addr8 writable_addr16 writable_addr32 writable_addr64 writable_addrF16 addr() |
| 1271 | |
| 1272 | ## |
| 1273 | |
| 1274 | # ------------------------------------------------------------------------------ |
| 1275 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 1276 | #Method uint8_t* writable_addr8(int x, int y) const |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1277 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 1278 | #In Writable_Address |
| 1279 | #Line # returns writable pixel address as 8-bit pointer ## |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1280 | Returns writable pixel address at (x, y). Result is addressable as unsigned |
| 1281 | 8-bit bytes. Will trigger an assert() if Color_Type is not kAlpha_8_SkColorType |
| 1282 | or kGray_8_SkColorType, and is built with SK_DEBUG defined. |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1283 | |
| 1284 | One byte corresponds to one pixel. |
| 1285 | |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1286 | #Param x column index, zero or greater, and less than width() ## |
| 1287 | #Param y row index, zero or greater, and less than height() ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1288 | |
| 1289 | #Return writable unsigned 8-bit pointer to pixels ## |
| 1290 | |
| 1291 | #Example |
| 1292 | #Height 64 |
| 1293 | #Description |
| 1294 | Altering pixels after drawing Bitmap is not guaranteed to affect subsequent |
| 1295 | drawing on all platforms. Adding a second SkBitmap::installPixels after editing |
| 1296 | pixel memory is safer. |
| 1297 | ## |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1298 | void draw(SkCanvas* canvas) { |
| 1299 | uint8_t storage[][5] = {{ 0, 0, 64, 0, 0}, |
| 1300 | { 0, 128, 255, 128, 0}, |
| 1301 | {64, 255, 255, 255, 64}, |
| 1302 | { 0, 128, 255, 128, 0}, |
| 1303 | { 0, 0, 64, 0, 0}}; |
| 1304 | SkImageInfo imageInfo = SkImageInfo::Make(5, 5, kGray_8_SkColorType, kPremul_SkAlphaType); |
| 1305 | SkPixmap pixmap(imageInfo, storage[0], 5); |
| 1306 | SkBitmap bitmap; |
| 1307 | bitmap.installPixels(pixmap); |
| 1308 | canvas->scale(10, 10); |
| 1309 | canvas->drawBitmap(bitmap, 0, 0); |
| 1310 | *pixmap.writable_addr8(2, 2) = 0; |
| 1311 | // bitmap.installPixels(pixmap); // uncomment to fix on GPU |
| 1312 | canvas->drawBitmap(bitmap, 10, 0); |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1313 | } |
| 1314 | ## |
| 1315 | |
| 1316 | #SeeAlso writable_addr writable_addr16 writable_addr32 writable_addr64 writable_addrF16 addr() addr8 |
| 1317 | |
| 1318 | ## |
| 1319 | |
| 1320 | # ------------------------------------------------------------------------------ |
| 1321 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 1322 | #Method uint16_t* writable_addr16(int x, int y) const |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1323 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 1324 | #In Writable_Address |
| 1325 | #Line # returns writable pixel address as 16-bit pointer ## |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1326 | Returns writable_addr pixel address at (x, y). Result is addressable as unsigned |
| 1327 | 16-bit words. Will trigger an assert() if Color_Type is not kRGB_565_SkColorType |
| 1328 | or kARGB_4444_SkColorType, and is built with SK_DEBUG defined. |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1329 | |
| 1330 | One word corresponds to one pixel. |
| 1331 | |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1332 | #Param x column index, zero or greater, and less than width() ## |
| 1333 | #Param y row index, zero or greater, and less than height() ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1334 | |
| 1335 | #Return writable unsigned 16-bit pointer to pixel ## |
| 1336 | |
| 1337 | #Example |
| 1338 | #Description |
| 1339 | Draw a five by five bitmap, and draw it again with a center black pixel. |
| 1340 | The low nibble of the 16-bit word is Alpha. |
| 1341 | ## |
| 1342 | #Height 64 |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1343 | uint16_t storage[][5] = {{ 0xCABF, 0xDABE, 0xCA9D, 0xC96C, 0xA39B }, |
| 1344 | { 0xACEE, 0xA87C, 0x893A, 0x4779, 0x8708 }, |
| 1345 | { 0x4B7C, 0x255B, 0x2559, 0x2557, 0x4656 }, |
| 1346 | { 0x9099, 0x8128, 0x2557, 0x4124, 0x3323 }, |
| 1347 | { 0x7547, 0x5505, 0x4434, 0x2012, 0x0000 }}; |
| 1348 | SkImageInfo imageInfo = SkImageInfo::Make(5, 5, kARGB_4444_SkColorType, kPremul_SkAlphaType); |
| 1349 | SkPixmap pixmap(imageInfo, storage[0], sizeof(storage) / 5); |
| 1350 | SkBitmap bitmap; |
| 1351 | bitmap.installPixels(pixmap); |
| 1352 | canvas->scale(10, 10); |
| 1353 | canvas->drawBitmap(bitmap, 0, 0); |
| 1354 | *pixmap.writable_addr16(2, 2) = 0x000F; |
| 1355 | bitmap.installPixels(pixmap); |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1356 | canvas->drawBitmap(bitmap, 10, 0); |
| 1357 | ## |
| 1358 | |
| 1359 | #SeeAlso writable_addr writable_addr8 writable_addr32 writable_addr64 writable_addrF16 addr() addr16 |
| 1360 | |
| 1361 | ## |
| 1362 | |
| 1363 | # ------------------------------------------------------------------------------ |
| 1364 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 1365 | #Method uint32_t* writable_addr32(int x, int y) const |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1366 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 1367 | #In Writable_Address |
| 1368 | #Line # returns writable pixel address as 32-bit pointer ## |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1369 | Returns writable pixel address at (x, y). Result is addressable as unsigned |
| 1370 | 32-bit words. Will trigger an assert() if Color_Type is not |
| 1371 | kRGBA_8888_SkColorType or kBGRA_8888_SkColorType, and is built with SK_DEBUG |
| 1372 | defined. |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1373 | |
| 1374 | One word corresponds to one pixel. |
| 1375 | |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1376 | #Param x column index, zero or greater, and less than width() ## |
| 1377 | #Param y row index, zero or greater, and less than height() ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1378 | |
| 1379 | #Return writable unsigned 32-bit pointer to pixel ## |
| 1380 | |
| 1381 | #Example |
| 1382 | #Image 4 |
| 1383 | #Height 72 |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1384 | std::vector<int32_t> pixels; |
| 1385 | pixels.resize(image->height() * image->width() * 4); |
| 1386 | SkPixmap pixmap(SkImageInfo::Make(image->width(), image->height(), kN32_SkColorType, |
| 1387 | image->alphaType()), (const void*) &pixels.front(), image->width() * 4); |
| 1388 | image->readPixels(pixmap, 0, 0); |
| 1389 | for (int y = 0; y < pixmap.height() / 2; ++y) { |
| 1390 | for (int x = 0; x < pixmap.width(); ++x) { |
| 1391 | if ((x & 4) == (y & 4)) { |
Cary Clark | 4d75975 | 2018-06-19 12:57:43 -0400 | [diff] [blame] | 1392 | *pixmap.writable_addr32(x, y) = |
| 1393 | *pixmap.writable_addr32(pixmap.width() - x, pixmap.height() - y); |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1394 | } |
| 1395 | } |
| 1396 | } |
| 1397 | SkBitmap bitmap; |
| 1398 | bitmap.installPixels(pixmap); |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1399 | canvas->drawBitmap(bitmap, 0, 0); |
| 1400 | ## |
| 1401 | |
| 1402 | #SeeAlso writable_addr writable_addr8 writable_addr16 writable_addr64 writable_addrF16 addr() addr32 |
| 1403 | |
| 1404 | ## |
| 1405 | |
| 1406 | # ------------------------------------------------------------------------------ |
| 1407 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 1408 | #Method uint64_t* writable_addr64(int x, int y) const |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1409 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 1410 | #In Writable_Address |
| 1411 | #Line # returns writable pixel address as 64-bit pointer ## |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1412 | Returns writable pixel address at (x, y). Result is addressable as unsigned |
| 1413 | 64-bit words. Will trigger an assert() if Color_Type is not |
| 1414 | kRGBA_F16_SkColorType and is built with SK_DEBUG defined. |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1415 | |
| 1416 | One word corresponds to one pixel. |
| 1417 | |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1418 | #Param x column index, zero or greater, and less than width() ## |
| 1419 | #Param y row index, zero or greater, and less than height() ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1420 | |
| 1421 | #Return writable unsigned 64-bit pointer to pixel ## |
| 1422 | |
| 1423 | #Example |
Cary Clark | 2ade997 | 2017-11-02 17:49:34 -0400 | [diff] [blame] | 1424 | #Height 40 |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1425 | SkImageInfo info = SkImageInfo::Make(3, 3, kRGBA_F16_SkColorType, kPremul_SkAlphaType); |
| 1426 | uint64_t storage[9]; |
| 1427 | SkPixmap pixmap(info, storage, 3 * sizeof(uint64_t)); |
| 1428 | SkColor4f c4 { 1, 0.45f, 0.25f, 0.65f }; |
| 1429 | pixmap.erase(c4); |
| 1430 | SkBitmap bitmap; |
| 1431 | canvas->scale(10, 10); |
| 1432 | bitmap.installPixels(pixmap); |
| 1433 | canvas->drawBitmap(bitmap, 0, 0); |
| 1434 | *pixmap.writable_addr64(1, 1) |= 0x00ff000000000000LL; |
| 1435 | bitmap.installPixels(pixmap); |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1436 | canvas->drawBitmap(bitmap, 10, 0); |
| 1437 | ## |
| 1438 | |
| 1439 | #SeeAlso writable_addr writable_addr8 writable_addr16 writable_addr32 writable_addrF16 addr() addr64 |
| 1440 | |
| 1441 | ## |
| 1442 | |
| 1443 | # ------------------------------------------------------------------------------ |
| 1444 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 1445 | #Method uint16_t* writable_addrF16(int x, int y) const |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1446 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 1447 | #In Writable_Address |
| 1448 | #Line # returns writable pixel component address as 16-bit pointer ## |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1449 | Returns writable pixel address at (x, y). Result is addressable as unsigned |
| 1450 | 16-bit words. Will trigger an assert() if Color_Type is not |
| 1451 | kRGBA_F16_SkColorType and is built with SK_DEBUG defined. |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1452 | |
| 1453 | Each word represents one color component encoded as a half float. |
| 1454 | Four words correspond to one pixel. |
| 1455 | |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1456 | #Param x column index, zero or greater, and less than width() ## |
| 1457 | #Param y row index, zero or greater, and less than height() ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1458 | |
| 1459 | #Return writable unsigned 16-bit pointer to first component of pixel ## |
| 1460 | |
| 1461 | #Example |
| 1462 | #Height 64 |
| 1463 | #Description |
| 1464 | Left bitmap is drawn with two pixels defined in half float format. Right bitmap |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 1465 | is drawn after overwriting bottom half float color with top half float color. |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1466 | ## |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1467 | SkImageInfo info = SkImageInfo::Make(1, 2, kRGBA_F16_SkColorType, kPremul_SkAlphaType); |
| 1468 | uint16_t storage[2][4]; |
| 1469 | SkPixmap pixmap(info, storage[0], sizeof(uint64_t)); |
| 1470 | SkIRect topPixelBounds = {0, 0, 1, 1}; |
| 1471 | pixmap.erase({ 0.65f, 0.45f, 0.25f, 1 }, &topPixelBounds); |
| 1472 | SkIRect bottomPixelBounds = {0, 1, 1, 2}; |
| 1473 | pixmap.erase({ 0.25f, 0.65f, 0.45f, 1 }, &bottomPixelBounds); |
| 1474 | SkBitmap bitmap; |
| 1475 | canvas->scale(20, 20); |
| 1476 | bitmap.installPixels(pixmap); |
| 1477 | canvas->drawBitmap(bitmap, 0, 0); |
| 1478 | uint16_t* pixel2 = pixmap.writable_addrF16(0, 1); |
| 1479 | for (int i = 0; i < 4; ++i) { |
| 1480 | pixel2[i] = storage[0][i]; |
| 1481 | } |
| 1482 | bitmap.installPixels(pixmap); |
| 1483 | canvas->drawBitmap(bitmap, 4, 0); |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1484 | ## |
| 1485 | |
| 1486 | #SeeAlso writable_addr writable_addr8 writable_addr16 writable_addr32 writable_addr64 addr() addrF16 |
| 1487 | |
| 1488 | ## |
| 1489 | |
| 1490 | #Subtopic Writable_Address ## |
| 1491 | |
Cary Clark | 78de751 | 2018-02-07 07:27:09 -0500 | [diff] [blame] | 1492 | #Subtopic Pixels |
Cary Clark | 78de751 | 2018-02-07 07:27:09 -0500 | [diff] [blame] | 1493 | #Line # read and write pixel values ## |
| 1494 | ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1495 | |
| 1496 | # ------------------------------------------------------------------------------ |
| 1497 | |
Cary Clark | e80cd44 | 2018-07-17 13:19:56 -0400 | [diff] [blame] | 1498 | #Method bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes) const |
Cary Clark | 78de751 | 2018-02-07 07:27:09 -0500 | [diff] [blame] | 1499 | #In Pixels |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 1500 | #Line # copies and converts pixels ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1501 | |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1502 | Copies a Rect of pixels to dstPixels. Copy starts at (0, 0), and does not |
Cary Clark | ac47b88 | 2018-01-11 10:35:44 -0500 | [diff] [blame] | 1503 | exceed Pixmap (width(), height()). |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1504 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 1505 | dstInfo specifies width, height, Color_Type, Alpha_Type, and |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1506 | Color_Space of destination. dstRowBytes specifics the gap from one destination |
| 1507 | row to the next. Returns true if pixels are copied. Returns false if |
| 1508 | dstInfo.addr() equals nullptr, or dstRowBytes is less than dstInfo.minRowBytes. |
| 1509 | |
Cary Clark | ac47b88 | 2018-01-11 10:35:44 -0500 | [diff] [blame] | 1510 | Pixels are copied only if pixel conversion is possible. If Pixmap colorType is |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1511 | kGray_8_SkColorType, or kAlpha_8_SkColorType; dstInfo.colorType must match. |
Cary Clark | ac47b88 | 2018-01-11 10:35:44 -0500 | [diff] [blame] | 1512 | If Pixmap colorType is kGray_8_SkColorType, dstInfo.colorSpace must match. |
| 1513 | If Pixmap alphaType is kOpaque_SkAlphaType, dstInfo.alphaType must |
| 1514 | match. If Pixmap colorSpace is nullptr, dstInfo.colorSpace must match. Returns |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1515 | false if pixel conversion is not possible. |
| 1516 | |
Cary Clark | ac47b88 | 2018-01-11 10:35:44 -0500 | [diff] [blame] | 1517 | Returns false if Pixmap width() or height() is zero or negative. |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1518 | |
| 1519 | #Param dstInfo destination width, height, Color_Type, Alpha_Type, Color_Space ## |
| 1520 | #Param dstPixels destination pixel storage ## |
| 1521 | #Param dstRowBytes destination row length ## |
| 1522 | |
| 1523 | #Return true if pixels are copied to dstPixels ## |
| 1524 | |
| 1525 | #Example |
| 1526 | #Height 128 |
| 1527 | #Description |
| 1528 | Transferring the gradient from 8 bits per component to 4 bits per component |
| 1529 | creates visible banding. |
| 1530 | ## |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1531 | std::vector<int32_t> pixels; |
| 1532 | const int width = 256; |
| 1533 | const int height = 64; |
| 1534 | pixels.resize(height * width * 4); |
| 1535 | SkImageInfo srcInfo = SkImageInfo::MakeN32Premul(width, height); |
| 1536 | SkPixmap srcPixmap(srcInfo, (const void*) &pixels.front(), width * 4); |
| 1537 | SkColor gradColors[] = { 0xFFAA3300, 0x7F881122 }; |
| 1538 | SkPoint gradPoints[] = { { 0, 0 }, { 256, 0 } }; |
| 1539 | SkPaint paint; |
| 1540 | paint.setShader(SkGradientShader::MakeLinear(gradPoints, gradColors, nullptr, |
| 1541 | SK_ARRAY_COUNT(gradColors), SkShader::kClamp_TileMode)); |
| 1542 | SkBitmap bitmap; |
| 1543 | bitmap.installPixels(srcPixmap); |
| 1544 | SkCanvas srcCanvas(bitmap); |
| 1545 | srcCanvas.drawRect(SkRect::MakeWH(width, height), paint); |
| 1546 | canvas->drawBitmap(bitmap, 0, 0); |
| 1547 | std::vector<int32_t> dstPixels; |
| 1548 | dstPixels.resize(height * width * 2); |
| 1549 | SkImageInfo dstInfo = srcInfo.makeColorType(kARGB_4444_SkColorType); |
| 1550 | srcPixmap.readPixels(dstInfo, &dstPixels.front(), width * 2); |
| 1551 | SkPixmap dstPixmap(dstInfo, &dstPixels.front(), width * 2); |
| 1552 | bitmap.installPixels(dstPixmap); |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1553 | canvas->drawBitmap(bitmap, 0, 128); |
| 1554 | ## |
| 1555 | |
| 1556 | #SeeAlso erase SkBitmap::readPixels SkCanvas::drawBitmap SkCanvas::readPixels SkImage::readPixels SkSurface::readPixels |
| 1557 | |
| 1558 | ## |
| 1559 | |
| 1560 | # ------------------------------------------------------------------------------ |
| 1561 | |
| 1562 | #Method bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes, int srcX, |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 1563 | int srcY) const |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1564 | |
| 1565 | Copies a Rect of pixels to dstPixels. Copy starts at (srcX, srcY), and does not |
Cary Clark | ac47b88 | 2018-01-11 10:35:44 -0500 | [diff] [blame] | 1566 | exceed Pixmap (width(), height()). |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1567 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 1568 | dstInfo specifies width, height, Color_Type, Alpha_Type, and |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1569 | Color_Space of destination. dstRowBytes specifics the gap from one destination |
| 1570 | row to the next. Returns true if pixels are copied. Returns false if |
| 1571 | dstInfo.addr() equals nullptr, or dstRowBytes is less than dstInfo.minRowBytes. |
| 1572 | |
Cary Clark | ac47b88 | 2018-01-11 10:35:44 -0500 | [diff] [blame] | 1573 | Pixels are copied only if pixel conversion is possible. If Pixmap colorType is |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1574 | kGray_8_SkColorType, or kAlpha_8_SkColorType; dstInfo.colorType must match. |
Cary Clark | ac47b88 | 2018-01-11 10:35:44 -0500 | [diff] [blame] | 1575 | If Pixmap colorType is kGray_8_SkColorType, dstInfo.colorSpace must match. |
| 1576 | If Pixmap alphaType is kOpaque_SkAlphaType, dstInfo.alphaType must |
| 1577 | match. If Pixmap colorSpace is nullptr, dstInfo.colorSpace must match. Returns |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1578 | false if pixel conversion is not possible. |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 1579 | |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1580 | srcX and srcY may be negative to copy only top or left of source. Returns |
Cary Clark | ac47b88 | 2018-01-11 10:35:44 -0500 | [diff] [blame] | 1581 | false if Pixmap width() or height() is zero or negative. Returns false if: |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1582 | |
Cary Clark | 2be81cf | 2018-09-13 12:04:30 -0400 | [diff] [blame] | 1583 | #Formula # abs(srcX) >= Pixmap width() ##, or if #Formula # abs(srcY) >= Pixmap height() ##. |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1584 | |
| 1585 | #Param dstInfo destination width, height, Color_Type, Alpha_Type, Color_Space ## |
| 1586 | #Param dstPixels destination pixel storage ## |
| 1587 | #Param dstRowBytes destination row length ## |
| 1588 | #Param srcX column index whose absolute value is less than width() ## |
| 1589 | #Param srcY row index whose absolute value is less than height() ## |
| 1590 | |
| 1591 | #Return true if pixels are copied to dstPixels ## |
| 1592 | |
| 1593 | #Example |
| 1594 | #Image 3 |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1595 | void draw(SkCanvas* canvas) { |
| 1596 | SkImageInfo info = SkImageInfo::MakeN32Premul(image->width(), image->height()); |
| 1597 | std::vector<int32_t> srcPixels; |
| 1598 | const int rowBytes = image->width() * 4; |
| 1599 | srcPixels.resize(image->height() * rowBytes); |
| 1600 | SkPixmap pixmap(info, (const void*) &srcPixels.front(), rowBytes); |
| 1601 | image->readPixels(pixmap, 0, 0); |
| 1602 | for (int offset : { 32, 64, 96 } ) { |
| 1603 | std::vector<int32_t> dstPixels; |
| 1604 | dstPixels.resize(image->height() * rowBytes); |
| 1605 | pixmap.readPixels(info, &dstPixels.front(), rowBytes, offset, 0); |
| 1606 | SkBitmap bitmap; |
| 1607 | SkPixmap dstmap(info, &dstPixels.front(), rowBytes); |
| 1608 | bitmap.installPixels(dstmap); |
| 1609 | canvas->translate(32, 32); |
| 1610 | canvas->drawBitmap(bitmap, 0, 0); |
| 1611 | } |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1612 | } |
| 1613 | ## |
| 1614 | |
| 1615 | #SeeAlso erase SkBitmap::readPixels SkCanvas::drawBitmap SkCanvas::readPixels SkImage::readPixels SkSurface::readPixels |
| 1616 | |
| 1617 | ## |
| 1618 | |
| 1619 | # ------------------------------------------------------------------------------ |
| 1620 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 1621 | #Method bool readPixels(const SkPixmap& dst, int srcX, int srcY) const |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1622 | |
| 1623 | Copies a Rect of pixels to dst. Copy starts at (srcX, srcY), and does not |
Cary Clark | ac47b88 | 2018-01-11 10:35:44 -0500 | [diff] [blame] | 1624 | exceed Pixmap (width(), height()). dst specifies width, height, Color_Type, |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1625 | Alpha_Type, and Color_Space of destination. Returns true if pixels are copied. |
| 1626 | Returns false if dst.addr() equals nullptr, or dst.rowBytes is less than |
| 1627 | dst SkImageInfo::minRowBytes. |
| 1628 | |
Cary Clark | ac47b88 | 2018-01-11 10:35:44 -0500 | [diff] [blame] | 1629 | Pixels are copied only if pixel conversion is possible. If Pixmap colorType is |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1630 | kGray_8_SkColorType, or kAlpha_8_SkColorType; dst.info().colorType must match. |
Cary Clark | ac47b88 | 2018-01-11 10:35:44 -0500 | [diff] [blame] | 1631 | If Pixmap colorType is kGray_8_SkColorType, dst.info().colorSpace must match. |
| 1632 | If Pixmap alphaType is kOpaque_SkAlphaType, dst.info().alphaType must |
| 1633 | match. If Pixmap colorSpace is nullptr, dst.info().colorSpace must match. Returns |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1634 | false if pixel conversion is not possible. |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 1635 | |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1636 | srcX and srcY may be negative to copy only top or left of source. Returns |
Cary Clark | ac47b88 | 2018-01-11 10:35:44 -0500 | [diff] [blame] | 1637 | false Pixmap width() or height() is zero or negative. Returns false if: |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1638 | |
Cary Clark | 2be81cf | 2018-09-13 12:04:30 -0400 | [diff] [blame] | 1639 | #Formula # abs(srcX) >= Pixmap width() ##, or if #Formula # abs(srcY) >= Pixmap height() ##. |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1640 | |
| 1641 | #Param dst Image_Info and pixel address to write to ## |
| 1642 | #Param srcX column index whose absolute value is less than width() ## |
| 1643 | #Param srcY row index whose absolute value is less than height() ## |
| 1644 | |
| 1645 | #Return true if pixels are copied to dst ## |
| 1646 | |
| 1647 | #Example |
| 1648 | #Image 3 |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1649 | void draw(SkCanvas* canvas) { |
| 1650 | SkImageInfo info = SkImageInfo::MakeN32Premul(image->width(), image->height()); |
| 1651 | std::vector<int32_t> srcPixels; |
| 1652 | const int rowBytes = image->width() * 4; |
| 1653 | srcPixels.resize(image->height() * rowBytes); |
| 1654 | SkPixmap pixmap(info, (const void*) &srcPixels.front(), rowBytes); |
| 1655 | image->readPixels(pixmap, 0, 0); |
| 1656 | for (int offset : { 32, 64, 96 } ) { |
| 1657 | std::vector<int32_t> dstPixels; |
| 1658 | dstPixels.resize(image->height() * rowBytes); |
| 1659 | SkPixmap dstmap(info, &dstPixels.front(), rowBytes); |
| 1660 | pixmap.readPixels(dstmap, offset, 0); |
| 1661 | SkBitmap bitmap; |
| 1662 | bitmap.installPixels(dstmap); |
| 1663 | canvas->translate(32, 32); |
| 1664 | canvas->drawBitmap(bitmap, 0, 0); |
| 1665 | } |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1666 | } |
| 1667 | ## |
| 1668 | |
| 1669 | #SeeAlso erase SkBitmap::readPixels SkCanvas::drawBitmap SkCanvas::readPixels SkImage::readPixels SkSurface::readPixels |
| 1670 | |
| 1671 | ## |
| 1672 | |
| 1673 | # ------------------------------------------------------------------------------ |
| 1674 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 1675 | #Method bool readPixels(const SkPixmap& dst) const |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1676 | |
| 1677 | Copies pixels inside bounds() to dst. dst specifies width, height, Color_Type, |
| 1678 | Alpha_Type, and Color_Space of destination. Returns true if pixels are copied. |
| 1679 | Returns false if dst.addr() equals nullptr, or dst.rowBytes is less than |
| 1680 | dst SkImageInfo::minRowBytes. |
| 1681 | |
Cary Clark | ac47b88 | 2018-01-11 10:35:44 -0500 | [diff] [blame] | 1682 | Pixels are copied only if pixel conversion is possible. If Pixmap colorType is |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1683 | kGray_8_SkColorType, or kAlpha_8_SkColorType; dst Color_Type must match. |
Cary Clark | ac47b88 | 2018-01-11 10:35:44 -0500 | [diff] [blame] | 1684 | If Pixmap colorType is kGray_8_SkColorType, dst Color_Space must match. |
| 1685 | If Pixmap alphaType is kOpaque_SkAlphaType, dst Alpha_Type must |
| 1686 | match. If Pixmap colorSpace is nullptr, dst Color_Space must match. Returns |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1687 | false if pixel conversion is not possible. |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 1688 | |
Cary Clark | ac47b88 | 2018-01-11 10:35:44 -0500 | [diff] [blame] | 1689 | Returns false if Pixmap width() or height() is zero or negative. |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1690 | |
| 1691 | #Param dst Image_Info and pixel address to write to ## |
| 1692 | |
| 1693 | #Return true if pixels are copied to dst ## |
| 1694 | |
| 1695 | #Example |
| 1696 | #Image 3 |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1697 | void draw(SkCanvas* canvas) { |
| 1698 | SkImageInfo info = SkImageInfo::MakeN32Premul(image->width(), image->height()); |
| 1699 | std::vector<int32_t> srcPixels; |
| 1700 | const int rowBytes = image->width() * 4; |
| 1701 | srcPixels.resize(image->height() * rowBytes); |
| 1702 | SkPixmap pixmap(info, (const void*) &srcPixels.front(), rowBytes); |
| 1703 | image->readPixels(pixmap, 0, 0); |
| 1704 | for (int index = 0; index < 3; ++index ) { |
| 1705 | std::vector<int32_t> dstPixels; |
| 1706 | dstPixels.resize(image->height() * rowBytes); |
| 1707 | SkPixmap dstmap(info, &dstPixels.front(), rowBytes); |
| 1708 | pixmap.readPixels(dstmap); |
| 1709 | SkBitmap bitmap; |
| 1710 | bitmap.installPixels(dstmap); |
| 1711 | canvas->translate(32, 32); |
| 1712 | canvas->drawBitmap(bitmap, 0, 0); |
| 1713 | } |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1714 | } |
| 1715 | ## |
| 1716 | |
| 1717 | #SeeAlso erase SkBitmap::readPixels SkCanvas::drawBitmap SkCanvas::readPixels SkImage::readPixels SkSurface::readPixels |
| 1718 | |
| 1719 | ## |
| 1720 | |
| 1721 | # ------------------------------------------------------------------------------ |
| 1722 | |
| 1723 | #Method bool scalePixels(const SkPixmap& dst, SkFilterQuality filterQuality) const |
| 1724 | |
Cary Clark | 78de751 | 2018-02-07 07:27:09 -0500 | [diff] [blame] | 1725 | #In Pixels |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 1726 | #Line # scales and converts pixels ## |
Cary Clark | ac47b88 | 2018-01-11 10:35:44 -0500 | [diff] [blame] | 1727 | Copies Bitmap to dst, scaling pixels to fit dst.width() and dst.height(), and |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1728 | converting pixels to match dst.colorType and dst.alphaType. Returns true if |
| 1729 | pixels are copied. Returns false if dst.addr() is nullptr, or dst.rowBytes is |
| 1730 | less than dst SkImageInfo::minRowBytes. |
| 1731 | |
Cary Clark | ac47b88 | 2018-01-11 10:35:44 -0500 | [diff] [blame] | 1732 | Pixels are copied only if pixel conversion is possible. If Pixmap colorType is |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1733 | kGray_8_SkColorType, or kAlpha_8_SkColorType; dst Color_Type must match. |
Cary Clark | ac47b88 | 2018-01-11 10:35:44 -0500 | [diff] [blame] | 1734 | If Pixmap colorType is kGray_8_SkColorType, dst Color_Space must match. |
| 1735 | If Pixmap alphaType is kOpaque_SkAlphaType, dst Alpha_Type must |
| 1736 | match. If Pixmap colorSpace is nullptr, dst Color_Space must match. Returns |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1737 | false if pixel conversion is not possible. |
| 1738 | |
Cary Clark | ac47b88 | 2018-01-11 10:35:44 -0500 | [diff] [blame] | 1739 | Returns false if Bitmap width() or height() is zero or negative. |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1740 | |
| 1741 | Scales the image, with filterQuality, to match dst.width() and dst.height(). |
| 1742 | filterQuality kNone_SkFilterQuality is fastest, typically implemented with |
| 1743 | Filter_Quality_Nearest_Neighbor. kLow_SkFilterQuality is typically implemented with |
| 1744 | Filter_Quality_Bilerp. kMedium_SkFilterQuality is typically implemented with |
| 1745 | Filter_Quality_Bilerp, and Filter_Quality_MipMap when size is reduced. |
| 1746 | kHigh_SkFilterQuality is slowest, typically implemented with Filter_Quality_BiCubic. |
| 1747 | |
| 1748 | #Param dst Image_Info and pixel address to write to ## |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 1749 | #Param filterQuality one of: kNone_SkFilterQuality, kLow_SkFilterQuality, |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1750 | kMedium_SkFilterQuality, kHigh_SkFilterQuality |
| 1751 | ## |
| 1752 | |
Cary Clark | ac47b88 | 2018-01-11 10:35:44 -0500 | [diff] [blame] | 1753 | #Return true if pixels are scaled to fit dst ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1754 | |
| 1755 | #Example |
| 1756 | #Image 3 |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1757 | void draw(SkCanvas* canvas) { |
| 1758 | SkImageInfo info = SkImageInfo::MakeN32Premul(image->width(), image->height()); |
| 1759 | std::vector<int32_t> srcPixels; |
| 1760 | int rowBytes = image->width() * 4; |
| 1761 | srcPixels.resize(image->height() * rowBytes); |
| 1762 | SkPixmap pixmap(info, (const void*) &srcPixels.front(), rowBytes); |
| 1763 | image->readPixels(pixmap, 0, 0); |
| 1764 | for (int offset : { 32, 64, 96 } ) { |
| 1765 | info = SkImageInfo::MakeN32Premul(image->width() + offset, image->height()); |
| 1766 | rowBytes = info.width() * 4; |
| 1767 | std::vector<int32_t> dstPixels; |
| 1768 | dstPixels.resize(image->height() * rowBytes); |
| 1769 | SkPixmap dstmap(info, &dstPixels.front(), rowBytes); |
| 1770 | pixmap.scalePixels(dstmap, kMedium_SkFilterQuality); |
| 1771 | SkBitmap bitmap; |
| 1772 | bitmap.installPixels(dstmap); |
| 1773 | canvas->translate(32, 32); |
| 1774 | canvas->drawBitmap(bitmap, 0, 0); |
| 1775 | } |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1776 | } |
| 1777 | ## |
| 1778 | |
| 1779 | #SeeAlso SkCanvas::drawBitmap SkImage::scalePixels |
| 1780 | |
| 1781 | ## |
| 1782 | |
| 1783 | # ------------------------------------------------------------------------------ |
| 1784 | |
| 1785 | #Method bool erase(SkColor color, const SkIRect& subset) const |
| 1786 | |
Cary Clark | 78de751 | 2018-02-07 07:27:09 -0500 | [diff] [blame] | 1787 | #In Pixels |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 1788 | #Line # writes Color to pixels ## |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1789 | Writes color to pixels bounded by subset; returns true on success. |
| 1790 | Returns false if colorType is kUnknown_SkColorType, or if subset does |
| 1791 | not intersect bounds(). |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 1792 | |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1793 | #Param color Unpremultiplied Color to write ## |
| 1794 | #Param subset bounding integer Rect of written pixels ## |
| 1795 | |
| 1796 | #Return true if pixels are changed ## |
| 1797 | |
| 1798 | #Example |
Cary Clark | 2ade997 | 2017-11-02 17:49:34 -0400 | [diff] [blame] | 1799 | #Height 50 |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1800 | uint32_t storage[2]; |
| 1801 | SkImageInfo info = SkImageInfo::MakeN32Premul(1, 2); |
| 1802 | SkPixmap pixmap(info, storage, info.minRowBytes()); |
| 1803 | pixmap.erase(SK_ColorBLUE, {0, 0, 1, 1}); |
| 1804 | pixmap.erase(SK_ColorRED, {0, 1, 1, 2}); |
| 1805 | SkBitmap bitmap; |
| 1806 | canvas->scale(20, 20); |
| 1807 | bitmap.installPixels(pixmap); |
| 1808 | canvas->drawBitmap(bitmap, 0, 0); |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1809 | ## |
| 1810 | |
| 1811 | #SeeAlso SkBitmap::erase SkCanvas::clear SkCanvas::drawColor |
| 1812 | |
| 1813 | ## |
| 1814 | |
| 1815 | # ------------------------------------------------------------------------------ |
| 1816 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 1817 | #Method bool erase(SkColor color) const |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1818 | |
| 1819 | Writes color to pixels inside bounds(); returns true on success. |
| 1820 | Returns false if colorType is kUnknown_SkColorType, or if bounds() |
| 1821 | is empty. |
| 1822 | |
| 1823 | #Param color Unpremultiplied Color to write ## |
| 1824 | |
| 1825 | #Return true if pixels are changed ## |
| 1826 | |
| 1827 | #Example |
Cary Clark | 2ade997 | 2017-11-02 17:49:34 -0400 | [diff] [blame] | 1828 | #Height 50 |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1829 | uint32_t storage[2]; |
| 1830 | SkImageInfo info = SkImageInfo::MakeN32Premul(1, 2); |
| 1831 | SkPixmap pixmap(info, storage, info.minRowBytes()); |
| 1832 | pixmap.erase(SK_ColorBLUE); |
| 1833 | SkBitmap bitmap; |
| 1834 | canvas->scale(20, 20); |
| 1835 | bitmap.installPixels(pixmap); |
| 1836 | canvas->drawBitmap(bitmap, 0, 0); |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1837 | ## |
| 1838 | |
| 1839 | #SeeAlso SkBitmap::erase SkCanvas::clear SkCanvas::drawColor |
| 1840 | |
| 1841 | ## |
| 1842 | |
| 1843 | # ------------------------------------------------------------------------------ |
| 1844 | |
| 1845 | #Method bool erase(const SkColor4f& color, const SkIRect* subset = nullptr) const |
| 1846 | |
| 1847 | Writes color to pixels bounded by subset; returns true on success. |
| 1848 | if subset is nullptr, writes colors pixels inside bounds(). Returns false if |
| 1849 | colorType is kUnknown_SkColorType, if subset is not nullptr and does |
| 1850 | not intersect bounds(), or if subset is nullptr and bounds() is empty. |
| 1851 | |
| 1852 | #Param color Unpremultiplied Color to write ## |
| 1853 | #Param subset bounding integer Rect of pixels to write; may be nullptr ## |
| 1854 | |
| 1855 | #Return true if pixels are changed ## |
| 1856 | |
| 1857 | #Example |
Cary Clark | 2ade997 | 2017-11-02 17:49:34 -0400 | [diff] [blame] | 1858 | #Height 50 |
Cary Clark | 6fc5041 | 2017-09-21 12:31:06 -0400 | [diff] [blame] | 1859 | uint32_t storage[2]; |
| 1860 | SkImageInfo info = SkImageInfo::MakeN32Premul(1, 2); |
| 1861 | SkPixmap pixmap(info, storage, info.minRowBytes()); |
| 1862 | SkIRect topPixelBounds = {0, 0, 1, 1}; |
| 1863 | pixmap.erase({ 0.65f, 0.45f, 0.25f, 1 }, &topPixelBounds); |
| 1864 | SkIRect bottomPixelBounds = {0, 1, 1, 2}; |
| 1865 | pixmap.erase({ 0.25f, 0.65f, 0.45f, 1 }, &bottomPixelBounds); |
| 1866 | SkBitmap bitmap; |
| 1867 | canvas->scale(20, 20); |
| 1868 | bitmap.installPixels(pixmap); |
| 1869 | canvas->drawBitmap(bitmap, 0, 0); |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1870 | ## |
| 1871 | |
| 1872 | #SeeAlso SkBitmap::erase SkCanvas::clear SkCanvas::drawColor |
| 1873 | |
| 1874 | ## |
| 1875 | |
Cary Clark | d0530ba | 2017-09-14 11:25:39 -0400 | [diff] [blame] | 1876 | #Class SkPixmap ## |
| 1877 | |
| 1878 | #Topic Pixmap ## |