#include "SkCanvas.h" SkBitmap bitmap; // ... load bitmap SkRect srcRect = SkRect::MakeLTRB(0, 0, 100, 100); SkRect dstRect = SkRect::MakeLTRB(50, 50, 150, 150); SkCanvas canvas; canvas.drawBitmapRect(bitmap, srcRect, dstRect, nullptr);
#include "SkCanvas.h" SkBitmap bitmap; // ... load bitmap SkRect srcRect = SkRect::MakeLTRB(50, 50, 150, 150); SkRect dstRect = SkRect::MakeLTRB(0, 0, 200, 200); SkPaint paint; paint.setColor(SK_ColorRED); SkCanvas canvas; canvas.drawBitmapRect(bitmap, srcRect, dstRect, &paint);In this example, the same bitmap is loaded and then a 100x100 pixel portion of the bitmap starting at (50, 50) is drawn onto the canvas inside a 200x200 pixel destination rectangle that starts at the top left corner of the canvas. The paint parameter is also used to color the drawn portion of the bitmap red.