Hal Canary | 83c2f70 | 2019-03-07 14:53:03 -0500 | [diff] [blame] | 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 "fiddle/examples.h" |
| 4 | // HASH=cd203a3f9c5fb68272f21f302dd54fbc |
| 5 | REG_FIDDLE(ImageInfo_036, 256, 144, false, 3) { |
| 6 | void draw(SkCanvas* canvas) { |
| 7 | SkImageInfo canvasImageInfo = canvas->imageInfo(); |
| 8 | SkRect canvasBounds = SkRect::Make(canvasImageInfo.bounds()); |
| 9 | canvas->drawBitmapRect(source, source.bounds(), canvasBounds, nullptr); |
| 10 | SkImageInfo insetImageInfo = |
| 11 | canvasImageInfo.makeWH(canvasBounds.width() / 2, canvasBounds.height() / 2); |
| 12 | SkBitmap inset; |
| 13 | inset.allocPixels(insetImageInfo); |
| 14 | SkCanvas offscreen(inset); |
| 15 | offscreen.drawBitmapRect(source, source.bounds(), SkRect::Make(inset.bounds()), nullptr); |
| 16 | canvas->drawBitmap(inset, canvasBounds.width() / 4, canvasBounds.height() / 4); |
| 17 | } |
| 18 | } // END FIDDLE |