r/GraphicsProgramming • u/Aspie96 • Aug 20 '26
Question On pixel formats
Hi all.
I'm writing a library for representing and managing basic raster RGBA images in D as rectangular arrays of pixels.
Images are represented in row-wise pixel order, either top to bottom (the default) or bottom to top, with each scan line going left to right. Color components are represented as 8-bit integral values ranging between, and including, 0 and 255.
My library doesn't provide any support for other color models, for high dynamic ranges or higher bit depths. What it should allow is reading images from memory that were created with other library.
Some pixel formats are "indexed" (they have a palette) and some are not (they store actual color values). The name implies the structure of the format:
Format1bppIndexedFormat4bppIndexedFormat8bppIndexedFormat8bppGrayFormat16bppRgb555Format16bppRgb565Format24bppRgbFormat32bppXrgbFormat32bppArgbFormat32bppRgba
Formats that use more than 1 byte per pixel allow the user to select between big endian and little endian mode.
I plan to keep supporting all formats I listed here. My question is if there is any I should support in addition to those.
Some candidates may be:
Format2bppIndexed(it used to be supported by Microsoft bitmaps and it is by the PNG format).Format16bppGrayAlpha(supported by STB nothings and by the PNG format).Format32bppRgbx(to have an opaque view of an RGBA image).
There may be others I haven't thought or heard of.
The ones I haven't supported seem to me to be less common and of less utility, but maybe there is something I haven't considered.
My question is: what pixel formats should I support in addition to those I already do? Should I support any of the three additional ones I suggested? Why or why not?
Thank you in advance!
View all comments
Show parent comment
1
u/fdwr Aug 22 '26
👍
Yeah, .NET probably copied GDI+'s faux pas. WIC did a little better, but it still has a mix sometimes (like the old
GUID_WICPixelFormat32bppRGBA1010102but then laterGUID_WICPixelFormat32bppR10G10B10A2). Then DGXI came along and said "we won't make that same mistake again", and Vulkan is like "indeed, let's improve upon OpenGL's notation".😶 If you have the following pixel format...
...how would you name it? (I know you said your library doesn't support high channel bit sizes, but nonetheless, how would you?) How would you name this one? 🤔
You already support 95% of the interesting formats. So unless you want retro formats and older PC's and video game consoles (particularly bitplane graphics, tiled graphics), I don't see any more to add.
It can be used for masks in video games with the gray channel multiplied with a mask color for effects (bright lights, decals, clouds, dirt, bullet holes...), used for fonts (prebaked glyph atlases), and video subtitles, but again, I typically see games just upcast to 32-bpp or use one of the BC formats rather than actual alpha+luminance (which isn't as widely supported).