blob: 5993c28d2964efb2011975b2af016fe111befedc [file] [log] [blame]
Hal Canary87515122019-03-15 14:22:51 -04001// 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 Kleinc0bd9f92019-04-23 12:05:21 -05003#include "tools/fiddle/examples.h"
Hal Canary87515122019-03-15 14:22:51 -04004// HASH=53e00899ef2e00e2096daf7a07d9b059
Hal Canarya7181e7c2019-03-18 16:06:34 -04005REG_FIDDLE(Bitmap_getAddr16, 256, 256, true, 3) {
Hal Canary87515122019-03-15 14:22:51 -04006void 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