Framework

Runtime spatial images

Use Image from bedform/Spatial/Components with the same Text.CreateSurface that draws spatial text. The Bedform build includes the shared Canvas glyph assets when this surface is used.

import { Image, View } from "bedform/Spatial/Components";

<View Dimension="overworld" Width={128} Height={72}>
    <Image Source={imageBytes} Fill ObjectFit="cover" />
</View>

Source accepts PNG, JPEG, lossy and lossless still WebP, still AVIF, and GIF as a Uint8Array, ArrayBuffer, a Blob with an arrayBuffer() method, raw base64, or a base64 data URL. APNG uses its default PNG image. The decoder accepts up to 8 MiB of encoded data and 4,194,304 source pixels with a 4,096-pixel cap per edge.

For HTTP(S) sources, pass http from @bedform/server-net to View.ImageHttp once. Enable Beta APIs for the world, declare the native @minecraft/server-net dependency in the behavior pack, and add it to allowed_modules in the script module's Bedrock Dedicated Server permissions.json. Bedrock Dedicated Server scripting setup

Bedrock exposes the response body as a string. On BDS 1.26.60.6, this conversion corrupted a raw PNG response. Serve base64 or a base64 data URL through server-net to preserve the image bytes. A Load override can use another transport and return any supported encoded source form. Only pass trusted URLs or use an adapter that applies your origin policy. Bedrock HttpResponse reference

A failed full-image load reaches OnError when supplied and the nearest React error boundary otherwise.

Animated GIF and GIFV

GIF playback follows the source's timing, transparency, disposal and loop count. Bedform samples the animation up to 12 times per second at the normal 20-tick server rate. It skips intermediate frames when the source is faster and holds frames that have longer delays. A placeholder uses the first frame, and playback starts when the full image takes over. GIFs may have up to 512 frames and 64 MiB of decoded frame pixels.

GIFV hosts such as Imgur deliver video. Convert the underlying MP4 or WebM payload with ConvertGifv on a Node.js host with FFmpeg installed, then pass the resulting GIF bytes to Image. Imgur's .gifv page URL represents the player. Provide the underlying video bytes to the converter. Imgur's GIFV format announcement

import { ConvertGifv } from "bedform/Spatial/ConvertGifv";

// Run on the Node.js asset or HTTP host.
const gif = await ConvertGifv(videoBytes);
const body = Buffer.from(gif).toString("base64");

The converter produces a looping GIF at 12 fps and keeps at most 30 seconds at up to 192 pixels per edge. For runtime GIFV links, use Image.Load to request this base64 response from your conversion host, or pass the converted endpoint URL directly as Source with View.ImageHttp.

Progressive previews

import { http } from "@bedform/server-net";
import { Image, View } from "bedform/Spatial/Components";

<View Dimension="overworld" ImageHttp={http} Loading={pageReady}>
    <Image
        Source="https://assets.example.com/map.base64"
        Width={128}
        Height={72}
        ObjectFit="contain"
        Placeholder="blur"
        BlurDataURL={mapThumbnailDataURL}
    />
    <MapControls />
</View>

Provide View.Loading as a boolean or as the promise shared by the page's child loaders. The preview stays visible while that signal is pending or the full image is loading. Once both are ready, Bedform promotes the image immediately. OnLoad runs after the full image replaces the preview.

  • Placeholder="empty" is the default.
  • Placeholder="blur" uses BlurDataURL for remote images. Embedded image sources can derive a blur preview from the decoded image.
  • Placeholder="data:image/png;base64,..." uses the supplied inline raster as a preview.
  • Placeholder={{ Source, SourceResolution: 8, Resolution: 12 }} can use a separate thumbnail source, including a URL, and gives independent control over the longest edge of the downscaled source and the rendered octant grid. Either resolution option can be omitted. With no preview source, Bedform derives a thumbnail after the full image bytes arrive. Downscaling preserves the source aspect ratio for ObjectFit.

Supply a small inline thumbnail to show a URL image before its network request finishes. Reserve space with Width and Height or use Fill. Preview configurations apply to runtime raster sources.

Sizing and sampling

  • With neither Width nor Height, decoded dimensions provide the natural layout size. A single dimension preserves the source aspect ratio. Supply both to reserve the box while a source loads.
  • Fill positions the image over the parent's content box, outside normal flow. Give that parent dimensions or size it with other layout content. ObjectFit="contain" centers the whole image and leaves margins as needed. ObjectFit="cover" centers and crops it. ObjectFit="fill" stretches it and is the default.
  • Resolution selects 1–64 sample pixels along the longest displayed image edge. PixelSize instead requests a sample size in world blocks (one block is approximately one meter). These are mutually exclusive. Samples are square and the renderer rounds to the nearest grid it can fit inside the box.
  • Automatic resolution uses source dimensions, sampled local contrast, the displayed size in blocks, and the number of visible images in the same top-level View. It shares a sample budget among those images. It accepts at most two resolution updates per ten server ticks (about 500 ms at 20 TPS). Bursts coalesce and can back off by up to 40 ticks.

Color and presentation

Colors defaults to eight and accepts any integer from 1 to 256 or false. Use false to preserve the sampled RGB values. Dither defaults to adaptive error diffusion based on palette size, local contrast, and downsampling. Use false to turn it off or pass a strength from zero to one. Diffusion applies when the renderer maps samples onto a limited palette. Source coverage below 50% leaves a transparent sample.

The surface places samples on the Canvas 2×4 octant grid. Each group's dark gray samples can share a Canvas octant glyph. Canvas glyph colors are baked into their font pages, so other colors use tinted Mojangles block glyphs positioned on the same grid. Each primitive is private to its viewer and retires when the image is removed. Partial samples at a scroll viewport edge are omitted.

Generated Canvas.Images descriptors still use their existing particle backends and animation clocks.

On this page