![]() |
PicoVGA
1.2-cmake
VGA/TV display on Raspberry Pico
|
The tools
folder contains the support programs used to prepare images, palettes, and sounds for use with the PicoVGA library. These tools convert standard file formats (BMP, WAV, ACT) into optimized C arrays that can be compiled directly into PicoVGA projects.
The generated arrays provide graphics and audio data in formats tailored for the Raspberry Pi Pico’s hardware and the PicoVGA rendering pipeline. By using these utilities, you can ensure that assets created in common editors (e.g., Photoshop, GIMP, Audacity) are correctly formatted and ready to use without additional runtime conversion.
All tools are lightweight console applications that should compile for all platforms. Building the library will build these applications into the tools
folder.
.act
palette files for use in image editors. picovga_img
is a command-line utility that converts Windows BMP images into C array data for use with the PicoVGA library on the Raspberry Pi Pico. It ensures that images are properly formatted and optimized for 8-bit, 4-bit, 2-bit, or 1-bit palette graphics.
input.bmp
– Source image file (must be a Windows BMP format). output.cpp
– Destination C++ file containing the image data. arrayname
– Name of the C++ array that will hold the image data. The tool reads the BMP image, validates its format, and writes the pixel data into a const u8[]
array that can be directly included in PicoVGA projects.
All input images must be:
When exporting from your image editor, always apply the correct palette (.act
files) before saving:
pal332.act
(332 RGB palette). pal4_PC.act
(CGA palettes) or pal4_ZX.act
(ZX Spectrum). palcga*.act
(CGA palettes, modes 1–6). pal1.act
(black & white). ⚠️ Note: BMP does not natively support 2-bit images. Save as a 4-bit BMP with a 4-color palette, and RaspPicoImg will automatically detect and convert it to 2-bit format.
The generated .c
file contains:
const u8[]
array with pixel data aligned to 4 bytes. Example excerpt:
This array can be included in your PicoVGA project and drawn directly to the screen.
picovga_rle
is a command-line utility that compresses 8-bit PicoVGA images into a run-length encoded (RLE) format suitable for use with the PicoVGA library on the Raspberry Pi Pico. The compression significantly reduces image size while maintaining compatibility with the RLE PIO routines in PicoVGA.
input.bmp
– Source image file (must be an 8-bit BMP using the PicoVGA palette pal332.act
). output.cpp
– Destination C++ file containing the compressed image data. arrayname
– Name of the generated C array. transparent_color
– Index of the color to be used as transparency (0–255). Use -1
for no transparency. The tool reads the BMP image, compresses it using RLE, and outputs a set of C arrays containing both pixel data and row offsets.
pal332.act
). ⚠️ If the input image does not meet these conditions, the tool will reject it.
The fourth parameter specifies which color index should be treated as transparent.
#8080FF
, locate it in pal332.csv
to find the matching PicoVGA index. -1
. Example:
This command compresses sprite.bmp
, outputs to sprite.c
, creates an array named mysprite
, and treats color index 120 as transparent.
The generated .cpp
file contains:
u16
values marking where each scanline begins in the compressed data. Example excerpt:
The RLE compression encodes pixel sequences into tokens:
Each scanline is terminated with an idle
command and aligned to 32-bit boundaries for efficient processing on the Pico.
The compressed output is tightly coupled with the RLE PIO program in PicoVGA. Since the instruction format may change between library versions, always use picovga_rle from the same release as your PicoVGA library to avoid incompatibility issues.
picovga_snd
is a command-line utility that converts WAV audio files into C array data for playback with the PicoVGA library on the Raspberry Pi Pico. It ensures that sound effects or music are properly formatted for the Pico’s audio playback routines.
input.wav
– Source WAV file. output.cpp
– Destination C++ file containing the audio data array. arrayname
– Name of the generated C array. The tool validates the WAV file format and writes its sample data into a const u8[]
array that can be directly included in PicoVGA projects.
The input WAV file must meet strict format requirements:
⚠️ If the file does not meet these conditions, the tool will reject it.
These tools allow trimming, resampling, and converting audio to the exact format needed for PicoVGA.
The generated .cpp
file contains:
const u8[]
array aligned to 4 bytes, containing all audio samples. Example excerpt:
This array can be compiled into your PicoVGA program and played back using the sound routines in the library.
picvovga_pal332
is a utility program used to generate the standard 8-bit PicoVGA palette. This palette is the foundation for all 8-bit graphics in PicoVGA and defines a total of 256 colors based on a 3-3-2 bit RGB model:
This RGB332 format allows compact color representation while providing a broad enough spectrum for retro-style graphics.
When you run picvovga_pal332
, it generates two important files:
pal332.act
– Adobe Color Table file containing the 256-color PicoVGA palette. This file can be imported into image editors such as Photoshop or GIMP to ensure images are created using PicoVGA’s 8-bit colors.pal332.csv
– A CSV table with detailed color information. Each row includes:Example (excerpt from pal332.csv
):
pal332.act
as the palette before saving your image as an 8-bit BMP. This ensures the image uses the exact PicoVGA colors.#8080FF
), you can use pal332.csv
to look up which PicoVGA color index corresponds to that HEX value.This is especially useful when working with transparency or when preparing assets for use with other PicoVGA tools such as picovga_img
or picovga_rle
.
The PicoVGA project includes a set of predefined palettes located in the tools\palettes
folder. These palettes (*.act
files) can be used in Photoshop, GIMP, or other graphics editors to ensure images match PicoVGA’s supported color sets.
pal332.act
– The primary 8-bit PicoVGA palette. This file defines the 256 standard colors used by PicoVGA. pal4_PC.act
– Standard CGA 16-color palette. pal4_ZX.act
– ZX Spectrum–style 16-color palette. palcga*.act
– Variants of CGA palettes for different modes (used for 2-bit conversions). pal1.act
– Black & white palette for 1-bit images. The most important palette is pal332.act
, which represents the 3-3-2 bit RGB layout (3 bits red, 3 bits green, 2 bits blue). It is generated by the picovga_pal332
tool and comes with an additional CSV file:
pal332.csv
– Contains detailed information about each color entry:This CSV file can be opened in Excel, LibreOffice, or any text editor. It is especially useful if you want to map a color you’ve selected in Photoshop (by HEX code) to its exact PicoVGA color index. Simply search for the HEX value in pal332.csv
and read the index number at the beginning of the corresponding line.
⚠️ Tip: Always apply the correct .act
palette before saving your BMP images for conversion with picovga_img
. This ensures the tool interprets the colors correctly.