1cb93a386Sopenharmony_ci// Copyright 2019 Google LLC.
2cb93a386Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
3cb93a386Sopenharmony_ci#include "tools/fiddle/examples.h"
4cb93a386Sopenharmony_ci// HASH=cd7543fa8c9f3cede46dc2d72eb8c4bd
5cb93a386Sopenharmony_ciREG_FIDDLE(Bitmap_extractAlpha_3, 256, 128, false, 0) {
6cb93a386Sopenharmony_civoid draw(SkCanvas* canvas) {
7cb93a386Sopenharmony_ci    SkBitmap alpha, bitmap;
8cb93a386Sopenharmony_ci    bitmap.allocN32Pixels(100, 100);
9cb93a386Sopenharmony_ci    SkCanvas offscreen(bitmap);
10cb93a386Sopenharmony_ci    offscreen.clear(0);
11cb93a386Sopenharmony_ci    SkPaint paint;
12cb93a386Sopenharmony_ci    paint.setAntiAlias(true);
13cb93a386Sopenharmony_ci    paint.setColor(SK_ColorBLUE);
14cb93a386Sopenharmony_ci    paint.setStyle(SkPaint::kStroke_Style);
15cb93a386Sopenharmony_ci    paint.setStrokeWidth(20);
16cb93a386Sopenharmony_ci    offscreen.drawCircle(50, 50, 39, paint);
17cb93a386Sopenharmony_ci    offscreen.flush();
18cb93a386Sopenharmony_ci    paint.setMaskFilter(SkMaskFilter::MakeBlur(kOuter_SkBlurStyle, 3));
19cb93a386Sopenharmony_ci    SkIPoint offset;
20cb93a386Sopenharmony_ci    bitmap.extractAlpha(&alpha, &paint, nullptr, &offset);
21cb93a386Sopenharmony_ci    paint.setColor(SK_ColorRED);
22cb93a386Sopenharmony_ci    canvas->drawImage(bitmap.asImage(), 0, -offset.fY, SkSamplingOptions(), &paint);
23cb93a386Sopenharmony_ci    canvas->drawImage(alpha.asImage(), 100 + offset.fX, 0, SkSamplingOptions(), &paint);
24cb93a386Sopenharmony_ci}
25cb93a386Sopenharmony_ci}  // END FIDDLE
26