Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 1 | // Copyright 2019 Google LLC. |
| 2 | // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 3 | #include "tools/fiddle/examples.h" |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 4 | // HASH=53e00899ef2e00e2096daf7a07d9b059 |
Hal Canary | a7181e7c | 2019-03-18 16:06:34 -0400 | [diff] [blame] | 5 | REG_FIDDLE(Bitmap_getAddr16, 256, 256, true, 3) { |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 6 | void draw(SkCanvas* canvas) { |
| 7 | SkBitmap bitmap16; |
| 8 | SkImageInfo dstInfo = SkImageInfo::Make(source.width(), source.height(), kARGB_4444_SkColorType, |
| 9 | kPremul_SkAlphaType); |
| 10 | bitmap16.allocPixels(dstInfo); |
| 11 | if (source.readPixels(dstInfo, bitmap16.getPixels(), bitmap16.rowBytes(), 0, 0)) { |
| 12 | uint16_t* row0 = bitmap16.getAddr16(0, 0); |
| 13 | uint16_t* row1 = bitmap16.getAddr16(0, 1); |
| 14 | size_t interval = (row1 - row0) * bitmap16.bytesPerPixel(); |
| 15 | SkDebugf("addr interval %c= rowBytes\n", interval == bitmap16.rowBytes() ? '=' : '!'); |
| 16 | } |
| 17 | } |
| 18 | } // END FIDDLE |