| 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_extractAlpha, 256, 100, false, 0) { |
| 5 |
void draw(SkCanvas* canvas) { |
| 6 |
SkBitmap alpha, bitmap; |
| 7 |
bitmap.allocN32Pixels(100, 100); |
| 8 |
SkCanvas offscreen(bitmap); |
| 9 |
offscreen.clear(0); |
| 10 |
SkPaint paint; |
| 11 |
paint.setAntiAlias(true); |
| 12 |
paint.setColor(SK_ColorBLUE); |
| 13 |
paint.setStyle(SkPaint::kStroke_Style); |
| 14 |
paint.setStrokeWidth(20); |
| 15 |
offscreen.drawCircle(50, 50, 39, paint); |
| 16 |
bitmap.extractAlpha(&alpha); |
| 17 |
paint.setColor(SK_ColorRED); |
| 18 |
canvas->drawImage(bitmap.asImage(), 0, 0, SkSamplingOptions(), &paint); |
| 19 |
canvas->drawImage(alpha.asImage(), 100, 0, SkSamplingOptions(), &paint); |
| 20 |
} |
| 21 |
} // END FIDDLE |