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=304148c50c91490bfd58e9222342419c |
Hal Canary | a7181e7c | 2019-03-18 16:06:34 -0400 | [diff] [blame] | 5 | REG_FIDDLE(Bitmap_extractSubset, 256, 256, true, 3) { |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 6 | void draw(SkCanvas* canvas) { |
| 7 | SkIRect bounds, s; |
| 8 | source.getBounds(&bounds); |
| 9 | SkDebugf("bounds: %d, %d, %d, %d\n", bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom); |
| 10 | SkBitmap subset; |
| 11 | for (int left: { -100, 0, 100, 1000 } ) { |
| 12 | for (int right: { 0, 100, 1000 } ) { |
| 13 | SkIRect b = SkIRect::MakeLTRB(left, 100, right, 200); |
| 14 | bool success = source.extractSubset(&subset, b); |
| 15 | SkDebugf("subset: %4d, %4d, %4d, %4d ", b.fLeft, b.fTop, b.fRight, b.fBottom); |
| 16 | SkDebugf("success; %s", success ? "true" : "false"); |
| 17 | if (success) { |
| 18 | subset.getBounds(&s); |
| 19 | SkDebugf(" subset: %d, %d, %d, %d", s.fLeft, s.fTop, s.fRight, s.fBottom); |
| 20 | } |
| 21 | SkDebugf("\n"); |
| 22 | } |
| 23 | } |
| 24 | } |
| 25 | } // END FIDDLE |