Expand description
Drawing somebody else’s pixels: the positioned, blended blit.
Canvas::copy_from is the damage-publish blit — same coordinates both
sides, no blending, not for pictures. These are the picture operations: a
borrowed block of pixels drawn at a position, composited per pixel, clipped
like everything else.
§The source is premultiplied
Source pixels are 0xAARRGGBB with the colour channels already multiplied
by alpha — the same convention Paint uses internally, and
for the same reason: the multiply happens once when the image is prepared,
not once per pixel per frame. Decoders produce straight alpha;
blend::premultiply converts a buffer in
place, once. Fully opaque pixels are identical in both conventions, so an
image with no transparency needs no conversion at all.
§Scaling is nearest-neighbour
Canvas::blit_scaled samples at pixel centres, integer arithmetic only —
exact for icons, QR codes and pixel art, and for integer upscales each
source pixel becomes a crisp block. Bilinear is what a photo wants and is
deliberately absent until it has been benched on the Pi-class targets;
pre-sizing assets is the embedded answer in the meantime.