xref: /third_party/skia/docs/examples/Surface_makeImageSnapshot_2.cpp
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/skia/docs/examples/
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=b18b8ab693b09eb70a1d22ab63790cc7
5cb93a386Sopenharmony_ciREG_FIDDLE(Surface_makeImageSnapshot_2, 256, 64, false, 0) {
6cb93a386Sopenharmony_civoid draw(SkCanvas* canvas) {
7cb93a386Sopenharmony_ci    sk_sp<SkSurface> big(SkSurface::MakeRasterN32Premul(64, 64));
8cb93a386Sopenharmony_ci    sk_sp<SkSurface> lil(big->makeSurface(SkImageInfo::MakeN32(32, 32, kPremul_SkAlphaType)));
9cb93a386Sopenharmony_ci    big->getCanvas()->clear(SK_ColorRED);
10cb93a386Sopenharmony_ci    lil->getCanvas()->clear(SK_ColorBLACK);
11cb93a386Sopenharmony_ci    sk_sp<SkImage> early(big->makeImageSnapshot());
12cb93a386Sopenharmony_ci    lil->draw(big->getCanvas(), 16, 16);
13cb93a386Sopenharmony_ci    sk_sp<SkImage> later(big->makeImageSnapshot({0, 0, 16, 16}));
14cb93a386Sopenharmony_ci    canvas->drawImage(early, 0, 0);
15cb93a386Sopenharmony_ci    canvas->drawImage(later, 0, 0);
16cb93a386Sopenharmony_ci}
17cb93a386Sopenharmony_ci}  // END FIDDLE
18

Indexes created Thu Nov 07 10:32:03 CST 2024