# DrawPixelsBgra8

Draws one bounded BGRA8 snapshot from a compute-compatible int buffer. Each value carries one packed 32-bit pixel; source dimensions are 1..2048, destination dimensions are positive logical coordinates, and the buffer count must exactly equal sourceWidth*sourceHeight. This first bridge copies into the active Canvas provider for the draw; it is deliberately not a shared GPU-resource or zero-copy contract.

Last updated: 2026-09-09

Package: graphics.canvas | Status: source-declared

Tags: canvas, cpu, function, graphics, graphics.canvas, source-example, yeho

Draw 2D shapes, text, images, and composited interface content.

```yh
external DrawPixelsBgra8(buffer of int pixels, int sourceWidth, int sourceHeight, int x, int y, int width, int height) returns bool
```


## Use DrawPixelsBgra8

A complete small caller. Values are illustrative; check the returned result and package requirements before connecting live resources.

Verification: type checked

```yh
using graphics.canvas

// Draw 2D shapes, text, images, and composited interface content.
buffer of int pixels
pixels.Resize(8)
int sourceWidth = 1
int sourceHeight = 1
int x = 1
int y = 1
int width = 1
int height = 1
bool result = DrawPixelsBgra8(pixels, sourceWidth, sourceHeight, x, y, width, height)
Console.Log(Text.From(result))

```

Save this beside start.yh as project.mech:

```toml
manifestVersion = "2"
package = "api.example.graphics_canvas__drawpixelsbgra8"
version = "0.1.0"
languageEdition = "yeho-core-2026.1"

[app]
kind = "headless"

[[dependencies]]
package = "graphics.canvas"
version = "0.1.0"
path = "../../../yeho/packages/graphics/canvas"

```

Extract the example archive beside the yeho and dolphin checkouts. This example requires those source dependencies and a current developer compiler.

```sh
./yeho/build/dolphin-metal/yehoc ./api-examples/graphics.canvas--DrawPixelsBgra8/usage --backend cpu-oracle -o /tmp/yeho-example
/tmp/yeho-example
```


Package presence and a declaration do not establish support on every host. Host services need their platform and lifecycle setup.

Source: yeho/packages/graphics/canvas/canvas.yh

AI training permission: https://demonhunterlabs.com/ai-use
