Paint
What is it?
Paint is the planned built-in image editor, modelled on Windows Paint: a canvas, eight drawing tools, a colour bar, undo and redo, and opening and saving BMP and PNG files, with selection and zoom as stretch goals. It also serves as a workout for the graphics and widget stack. The app itself has not started, but most of the drawing and image calls it needs already ship in the kernel.
How does it work?
Today. There is no Paint window. The building blocks exist:
- Surfaces and drawing.
gfx.hprovidesgfx_surface_twithgfx_surface_create()andgfx_surface_destroy(), and the primitives Paint's tools map onto:gfx_put_pixel(),gfx_draw_line(),gfx_draw_rect(),gfx_fill_rect(),gfx_fill_circle(),gfx_blit()andgfx_blit_alpha(). - Images.
image.hloads files withimage_load()(andimage_load_mem()) into a BGRAimage_t, scales withimage_scale()using one of five fit modes (stretch, fill, fit, centre, tile; box filter above 2x downscale, bilinear otherwise), and saves withimage_save_bmp()andimage_save_png(). The PNG writer is the vendoredstb_image_writewith its allocator redirected to the kernel (image_save.c). - Text.
ttf_get(FONT_UI, size)thenttf_draw_string(surface, font, x, y, text, colour)(font_mgr.h). - Windows and controls.
wm_create_window()(wm.h) and the control library, which today has buttons, labels, text boxes and scroll bars only (controls.h).
Planned design.
- Canvas and viewport. A
struct paintholding an 800 by 600 canvas surface in page-allocated memory, a scrolling and zooming viewport, a tool panel and a palette bar. - Tools. Pencil (Bresenham lines between mouse samples), brush (circle stamps), eraser, line, rectangle, ellipse, a breadth-first flood fill with its work stack in page-allocated memory, and text.
- Colours. Twenty preset swatches, foreground and background squares with a swap button, and the colour picker dialog as a stretch.
- Undo and redo. A ring of 32 snapshots, storing only the changed rectangle for large canvases.
- Files. New, Open, Save and Save As through
image_load()and the BMP and PNG savers, with an unsaved-changes guard. - Stretch. A rectangular selection with copy, paste, move and delete through the clipboard, and zoom from 25 to 800 percent with resize and crop.
What are its interfaces?
| Interface | Status |
|---|---|
gfx_surface_create(), the gfx_* drawing primitives |
Shipped |
image_load(), image_scale(), image_save_bmp(), image_save_png() |
Shipped |
gfx_get_pixel(), gfx_surface_scale_blit() |
Planned; not declared in gfx.h |
| Menu bar, status bar, list view and slider controls | Planned in the widget roadmaps |
dialog_file_open(), dialog_file_save(), dialog_color() |
Planned in Complex Controls and Dialogs |
clipboard_set() and clipboard_get() with CLIP_IMAGE |
Planned in the Clipboard roadmap |
How do I use it?
Paint cannot be launched yet. Of the image calls it will use, image_load() and image_scale() already run at every boot, when the desktop decodes and scales the wallpaper (desktop.c). Nothing calls image_save_bmp() or image_save_png() yet, so Paint will be their first user. See Graphics Assets for the image pipeline.
What is not implemented yet?
- Canvas and Viewport, which also needs the menu bar and status bar controls
- Drawing Tools and the Color System
- Undo and Redo
- File Operations, which needs the file dialogs
- Selection Tool and Zoom and Resize, both stretch goals
How does it compare with Windows 11 and Linux?
Windows 11 Paint is a GDI-backed editor with 20 swatches, layers, limited undo and BMP, JPEG, GIF, PNG and TIFF formats. On Linux the usual equivalents are GIMP, Pinta and KolourPaint, with 50 or more undo levels and many formats. The Impossible OS plan is smaller: BMP and PNG only, 32 undo snapshots and a flood fill whose stack lives in page-allocated memory so a large fill cannot exhaust the kernel heap. It does not exist yet.