| 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. |
| 3 |
#include "tools/fiddle/examples.h" |
| 4 |
REG_FIDDLE(Bitmap_extractSubset, 256, 256, true, 3) { |
| 5 |
void draw(SkCanvas* canvas) { |
| 6 |
SkIRect bounds, s; |
| 7 |
source.getBounds(&bounds); |
| 8 |
SkDebugf("bounds: %d, %d, %d, %d\n", bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom); |
| 9 |
SkBitmap subset; |
| 10 |
for (int left: { -100, 0, 100, 1000 } ) { |
| 11 |
for (int right: { 0, 100, 1000 } ) { |
| 12 |
SkIRect b = SkIRect::MakeLTRB(left, 100, right, 200); |
| 13 |
bool success = source.extractSubset(&subset, b); |
| 14 |
SkDebugf("subset: %4d, %4d, %4d, %4d ", b.fLeft, b.fTop, b.fRight, b.fBottom); |
| 15 |
SkDebugf("success; %s", success ? "true" : "false"); |
| 16 |
if (success) { |
| 17 |
subset.getBounds(&s); |
| 18 |
SkDebugf(" subset: %d, %d, %d, %d", s.fLeft, s.fTop, s.fRight, s.fBottom); |
| 19 |
} |
| 20 |
SkDebugf("\n"); |
| 21 |
} |
| 22 |
} |
| 23 |
} |
| 24 |
} // END FIDDLE |