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=cd203a3f9c5fb68272f21f302dd54fbc 5cb93a386Sopenharmony_ciREG_FIDDLE(ImageInfo_makeWH, 256, 144, false, 3) { 6cb93a386Sopenharmony_civoid draw(SkCanvas* canvas) { 7cb93a386Sopenharmony_ci SkImageInfo canvasImageInfo = canvas->imageInfo(); 8cb93a386Sopenharmony_ci SkRect canvasBounds = SkRect::Make(canvasImageInfo.bounds()); 9cb93a386Sopenharmony_ci canvas->drawImageRect(image, SkRect::Make(source.bounds()), canvasBounds, SkSamplingOptions(), 10cb93a386Sopenharmony_ci nullptr, SkCanvas::kStrict_SrcRectConstraint); 11cb93a386Sopenharmony_ci SkImageInfo insetImageInfo = 12cb93a386Sopenharmony_ci canvasImageInfo.makeWH(canvasBounds.width() / 2, canvasBounds.height() / 2); 13cb93a386Sopenharmony_ci SkBitmap inset; 14cb93a386Sopenharmony_ci inset.allocPixels(insetImageInfo); 15cb93a386Sopenharmony_ci SkCanvas offscreen(inset); 16cb93a386Sopenharmony_ci offscreen.drawImageRect(image, SkRect::Make(source.bounds()), SkRect::Make(inset.bounds()), 17cb93a386Sopenharmony_ci SkSamplingOptions(), nullptr, SkCanvas::kStrict_SrcRectConstraint); 18cb93a386Sopenharmony_ci canvas->drawImage(inset.asImage(), canvasBounds.width() / 4, canvasBounds.height() / 4); 19cb93a386Sopenharmony_ci} 20cb93a386Sopenharmony_ci} // END FIDDLE 21