Skip to content

Image Formats

Narta Xaymar Dirks edited this page Oct 31, 2026 · 6 revisions

Image formats

The commands that read a picture file all use the same loader: LoadImage, LoadAnimImage, LoadTexture, LoadAnimTexture, LoadBrush, LoadSprite, LoadTerrain, LoadBuffer, the textures of loaded meshes and levels, and the icons of the gadgets. The format is recognized from the content of the file, not from its name.

The original read what Windows 98 could load: BMP, PNG, JPEG, JPEG 2000, GIF, TGA and TIFF. Here the formats are:

Format Original Here
BMP, PNG, JPEG, GIF Yes Yes
TGA Yes Yes, if the file name ends in .tga
TIFF Yes Yes, but not with Deflate (ZIP) or JPEG compression
JPEG 2000 Yes No
WebP, AVIF, JPEG XL No Yes
DDS No Yes (block compressed ones stay compressed on the graphics card, see LoadTexture)
ICO, CUR, PCX, PNM (PBM, PGM, PPM), QOI, SVG, XPM, XCF, XV, LBM No Yes

TGA files have no marker at the start that identifies them, so they are recognized by the extension of the file name: a TGA file that is named .dat is not read. The TIFF reader is built without zlib and JPEG, so TIFF files with Deflate (ZIP) or JPEG compression are not read (on macOS the system reads TIFF files instead, which handles them; uncompressed, LZW, PackBits and CCITT ones are), and nothing reads JPEG 2000. Convert those files to PNG, WebP or another format from the list before loading them. The code for a few of the extra formats (WebP, AVIF, JPEG XL and TIFF) is in shared libraries that are shipped with the program, and a program that loads such a file warns once if one of them is missing.

Animated GIF, WebP and AVIF files load as frames with LoadAnimTexture and LoadAnimImage when the frame size is 0. Animated PNG (APNG) is intentionally not supported: it loads as an ordinary PNG, showing its first frame.

Saving is a separate list, see Saving pictures: PNG, JPEG, WebP, JPEG XL, TGA, DDS and BMP can be written, AVIF, GIF and the others can only be read.

Anything that is not in the table, or is damaged, gives 0 from the command (or a runtime error where the command has no way to report it, such as LoadTerrain).

Bits per channel

PNG files of 16 bits per channel are read with all of their bits. Pictures hold 8 bits per channel when they are loaded as an image (LoadImage and the commands built on it), and so does a texture that has alpha. A LoadTexture without the alpha flag (2), or with the mask flag (4) and no mip maps, keeps a picture of more than 8 bits per channel as 10 bits per channel on the graphics card (the 2 bits left over are enough for a mask), with mip maps made from the full picture. The size in memory is the same, and ReadPixel and WritePixel on the TextureBuffer still work in 8 bits: the first time a program draws to or reads such a texture it is turned into 8 bits per channel.

Pictures of 8 bits per channel get nothing from the 10-bit form, so they stay in 8 bits. Textures with the sRGB flag (2048, there is no sRGB form of 10 bits) or the render target flag (4096) stay in 8 bits as well. The screen holds 8 bits per channel too, so the difference only shows in a texture that is filtered or minified a lot, and then by less than one step of a color.

Home · Command Index



Differences
Language Features
BlitzBasic
Blitz3D
BlitzPlus

Clone this wiki locally