RISC OS text and graphics output
This skill covers writing text, graphics, and fonts to the screen or other
output devices on RISC OS.
For graphical text, font, rectangle, and line rendering, the GContext library
can be used.
Boundaries
Use this skill when the task involves:
- VDU output and control sequences
OS_Plot graphics
- Draw and DrawFile rendering
- Font Manager usage
- sprite creation, plotting, redirection, or file layout
- palette programming or
ColourTrans
- screen mode selection or mode decoding
ImageFileRender
It is not needed for plain textual output that does not involve positioning,
graphics, fonts, sprites, or palette handling.
Terminology
- VDU output covers character and control codes written through
OS_WriteC,
OS_WriteN, and OS_Write0.
- Graphics output covers
OS_Plot, sprite rendering, font rendering, and
related drawing systems.
- Draw provides path-based vector graphics through
Draw_* SWIs.
- Outline fonts are provided through the Font Manager via
Font_* SWIs.
- Sprites are raster images rendered through
OS_SpriteOp.
- Sprite areas are in-memory collections of sprites; sprite files are their
on-disc representation.
ImageFileRender renders complete image files without the caller needing to
know whether the source is JPEG, DrawFile, Sprite, PNG, or another supported
format.
- Modes define resolutions, pixel geometry, and colour depth.
ColourTrans is used for colour selection and translation in mode-independent
code and for sprite translation tables.
Coordinate system
Graphics
Graphics coordinates on RISC OS use:
- Y=0 at the bottom, positive upwards
- X=0 at the left, positive rightwards
- units which are usually double the screen resolution
Before declaring graphics code complete, check that the coordinates really are
correct.
Text
Text coordinates on RISC OS use:
- Y=0 at the top, positive downwards
- X=0 at the left, positive rightwards
To write text at a specific text-cell position, use VDU 31, <xchar>, <ychar>.
Text characters are 8 pixels by 8 pixels.
Common gotchas
- Text and graphics coordinates do not share the same origin.
- Sprite plotting normally needs a
ColourTrans translation table to match the
destination mode correctly.
- Sprite row 0 is the bottom row, not the top row.
- If code reads or writes the framebuffer directly, remove cursors first and
restore them afterwards.
- While output is redirected to a sprite, do not call
Wimp_Poll.
- If a saved screen image is paletted, preserve and restore the palette block
as well as the pixel data.
Task selection
Choose the smallest useful subsystem for the task:
- For VDU control sequences and textual cursor movement, read
references/vdu-codes.md.
- For simple line, point, rectangle, and shape plotting, read
references/os_plot.md.
- For Draw paths, filled shapes, and DrawFile object layout, read
references/draw.md and
references/drawfile.md.
If the task is a viewer or plug-in that must fit a DrawFile into a Wimp redraw box, read
references/drawfile.md early.
- For Font Manager usage, sizing, rendering, and colour handling, start with
references/fonts-overview.md, then read the
focused font references listed there.
- For
ColourTrans, start with
references/colourtrans-overview.md,
then read the focused colour references listed there.
- For screen modes and mode decoding, start with
references/modes-overview.md, then read the
focused mode references listed there.
- For sprites, start with
references/sprites-overview.md, then read
the focused sprite references listed there.
- For framebuffer access, pointer-driver quirks, or palette restoration, read
references/framebuffer-and-palettes.md.
- For general image-file rendering, read
references/imagefilerender.md.
Cross-skill routing
- When implementing image converter modules, use
riscos-graphics-converters as well as this skill.
- When using the Toolbox ImageFileGadget, use
using-toolbox-imagefilegadget as well as this skill.
- For higher-level graphics primitives and font handling through a library
rather than raw SWIs, consider
using-libgcontext.
Image File Converters
This skill covers the sprite, palette, mode, and rendering details needed by
image converters, but it does not define the ImageFileConvert registration
interface. When creating modules which convert image formats to Sprite, use the
riscos-graphics-converters skill as well.
When creating converters whose destination is DrawFile, use the Draw and
DrawFile references in this skill for object layout, coordinate conversion,
paths, text objects, sprite objects, font tables, and bounding-box handling.
Use riscos-graphics-converters for registration, converter entry points,
caching, and validation workflow.
ImageFileRender
Use ImageFileRender for general image files that should be drawn to the
screen, printer, or a Wimp redraw context without the caller needing to know
whether the file is a JPEG, DrawFile, Sprite, PNG, or a third-party format.
For direct screen rendering, load the file into memory, derive the RISC OS
filetype from the load address, choose one of the transform modes, and call
ImageFileRender_Render. Use ImageFileRender_BBox when layout code needs the
natural or transformed extent first, and set a graphics window (VDU 24) or
use redraw rectangles for clipping.
For new renderers, implement and register an ImageFileRender renderer. Read
references/imagefilerender.md for the calling
sequences, structures, flags, and renderer registration workflow. For Toolbox
ImageFileGadget method usage, use the using-toolbox-imagefilegadget skill.
The public master documentation is:
https://gerph.github.io/riscos-prminxml-staging/prm/html/select/graphics/imagefilerender.html
Reference index
- VDU control codes: references/vdu-codes.md
OS_Plot operations: references/os_plot.md
- Draw paths: references/draw.md
- DrawFiles: references/drawfile.md
- Font quick reference: references/fonts-overview.md
ColourTrans quick reference: references/colourtrans-overview.md
- Mode quick reference: references/modes-overview.md
- Sprite quick reference: references/sprites-overview.md
- Framebuffer and palette handling: references/framebuffer-and-palettes.md
- ImageFileRender: references/imagefilerender.md
1---2name: riscos-output3description: Details of how the RISC OS output system works. Use when creating text and graphics output using text positioning, graphics, drawing shapes, sprites, fonts, sprite areas, palette programming, ImageFileRender, or ColourTrans translation tables. It is not needed for plain textual output.4license: MIT5---6# RISC OS text and graphics output78This skill covers writing text, graphics, and fonts to the screen or other9output devices on RISC OS.1011For graphical text, font, rectangle, and line rendering, the GContext library12can be used.1314## Boundaries1516Use this skill when the task involves:1718* VDU output and control sequences19* `OS_Plot` graphics20* Draw and DrawFile rendering21* Font Manager usage22* sprite creation, plotting, redirection, or file layout23* palette programming or `ColourTrans`24* screen mode selection or mode decoding25* `ImageFileRender`2627It is not needed for plain textual output that does not involve positioning,28graphics, fonts, sprites, or palette handling.2930## Terminology3132* VDU output covers character and control codes written through `OS_WriteC`,33 `OS_WriteN`, and `OS_Write0`.34* Graphics output covers `OS_Plot`, sprite rendering, font rendering, and35 related drawing systems.36* Draw provides path-based vector graphics through `Draw_*` SWIs.37* Outline fonts are provided through the Font Manager via `Font_*` SWIs.38* Sprites are raster images rendered through `OS_SpriteOp`.39* Sprite areas are in-memory collections of sprites; sprite files are their40 on-disc representation.41* `ImageFileRender` renders complete image files without the caller needing to42 know whether the source is JPEG, DrawFile, Sprite, PNG, or another supported43 format.44* Modes define resolutions, pixel geometry, and colour depth.45* `ColourTrans` is used for colour selection and translation in mode-independent46 code and for sprite translation tables.4748## Coordinate system4950### Graphics5152Graphics coordinates on RISC OS use:5354* Y=0 at the bottom, positive upwards55* X=0 at the left, positive rightwards56* units which are usually double the screen resolution5758Before declaring graphics code complete, check that the coordinates really are59correct.6061### Text6263Text coordinates on RISC OS use:6465* Y=0 at the top, positive downwards66* X=0 at the left, positive rightwards6768To write text at a specific text-cell position, use `VDU 31, <xchar>, <ychar>`.69Text characters are 8 pixels by 8 pixels.7071## Common gotchas7273* Text and graphics coordinates do not share the same origin.74* Sprite plotting normally needs a `ColourTrans` translation table to match the75 destination mode correctly.76* Sprite row 0 is the bottom row, not the top row.77* If code reads or writes the framebuffer directly, remove cursors first and78 restore them afterwards.79* While output is redirected to a sprite, do not call `Wimp_Poll`.80* If a saved screen image is paletted, preserve and restore the palette block81 as well as the pixel data.8283## Task selection8485Choose the smallest useful subsystem for the task:8687* For VDU control sequences and textual cursor movement, read88 [references/vdu-codes.md](references/vdu-codes.md).89* For simple line, point, rectangle, and shape plotting, read90 [references/os_plot.md](references/os_plot.md).91* For Draw paths, filled shapes, and DrawFile object layout, read92 [references/draw.md](references/draw.md) and93 [references/drawfile.md](references/drawfile.md).94 If the task is a viewer or plug-in that must fit a DrawFile into a Wimp redraw box, read `references/drawfile.md` early.95* For Font Manager usage, sizing, rendering, and colour handling, start with96 [references/fonts-overview.md](references/fonts-overview.md), then read the97 focused font references listed there.98* For `ColourTrans`, start with99 [references/colourtrans-overview.md](references/colourtrans-overview.md),100 then read the focused colour references listed there.101* For screen modes and mode decoding, start with102 [references/modes-overview.md](references/modes-overview.md), then read the103 focused mode references listed there.104* For sprites, start with105 [references/sprites-overview.md](references/sprites-overview.md), then read106 the focused sprite references listed there.107* For framebuffer access, pointer-driver quirks, or palette restoration, read108 [references/framebuffer-and-palettes.md](references/framebuffer-and-palettes.md).109* For general image-file rendering, read110 [references/imagefilerender.md](references/imagefilerender.md).111112## Cross-skill routing113114* When implementing image converter modules, use115 `riscos-graphics-converters` as well as this skill.116* When using the Toolbox ImageFileGadget, use117 `using-toolbox-imagefilegadget` as well as this skill.118* For higher-level graphics primitives and font handling through a library119 rather than raw SWIs, consider `using-libgcontext`.120121## Image File Converters122123This skill covers the sprite, palette, mode, and rendering details needed by124image converters, but it does not define the `ImageFileConvert` registration125interface. When creating modules which convert image formats to Sprite, use the126`riscos-graphics-converters` skill as well.127128When creating converters whose destination is DrawFile, use the Draw and129DrawFile references in this skill for object layout, coordinate conversion,130paths, text objects, sprite objects, font tables, and bounding-box handling.131Use `riscos-graphics-converters` for registration, converter entry points,132caching, and validation workflow.133134## ImageFileRender135136Use `ImageFileRender` for general image files that should be drawn to the137screen, printer, or a Wimp redraw context without the caller needing to know138whether the file is a JPEG, DrawFile, Sprite, PNG, or a third-party format.139140For direct screen rendering, load the file into memory, derive the RISC OS141filetype from the load address, choose one of the transform modes, and call142`ImageFileRender_Render`. Use `ImageFileRender_BBox` when layout code needs the143natural or transformed extent first, and set a graphics window (`VDU 24`) or144use redraw rectangles for clipping.145146For new renderers, implement and register an ImageFileRender renderer. Read147[references/imagefilerender.md](references/imagefilerender.md) for the calling148sequences, structures, flags, and renderer registration workflow. For Toolbox149ImageFileGadget method usage, use the `using-toolbox-imagefilegadget` skill.150151The public master documentation is:152https://gerph.github.io/riscos-prminxml-staging/prm/html/select/graphics/imagefilerender.html153154## Reference index155156* VDU control codes: [references/vdu-codes.md](references/vdu-codes.md)157* `OS_Plot` operations: [references/os_plot.md](references/os_plot.md)158* Draw paths: [references/draw.md](references/draw.md)159* DrawFiles: [references/drawfile.md](references/drawfile.md)160* Font quick reference: [references/fonts-overview.md](references/fonts-overview.md)161* `ColourTrans` quick reference: [references/colourtrans-overview.md](references/colourtrans-overview.md)162* Mode quick reference: [references/modes-overview.md](references/modes-overview.md)163* Sprite quick reference: [references/sprites-overview.md](references/sprites-overview.md)164* Framebuffer and palette handling: [references/framebuffer-and-palettes.md](references/framebuffer-and-palettes.md)165* ImageFileRender: [references/imagefilerender.md](references/imagefilerender.md)