MonoGame/MonoGame · error · ContentLoadException

Unsupported RGB pixel format

Error message

Unsupported RGB pixel format

What it means

Thrown by DdsLoader.GetSurfaceFormat when a DDS file declares an RGB-only pixel format (DDPF.RGB without AlphaPixels) whose dwRgbBitCount is not 16, 24, or 32. The importer supports 16-bit Bgr565, 24-bit, and 32-bit Color uncompressed RGB formats only.

Source

Thrown at MonoGame.Framework.Content.Pipeline/DdsLoader.cs:167

                        rbSwap = pixelFormat.dwBBitMask == 0xFF;
                        return SurfaceFormat.Color;
                    }
                    throw new ContentLoadException("Unsupported RGBA pixel format");
                }
                else
                {
                    switch (pixelFormat.dwRgbBitCount)
                    {
                        // Format contains RGB only
                        case 16:
                            rbSwap = pixelFormat.dwBBitMask == 0x1F;
                            return SurfaceFormat.Bgr565;
                        case 24:
                        case 32:
                            rbSwap = pixelFormat.dwBBitMask == 0xFF;
                            return SurfaceFormat.Color;
                        default:
                            throw new ContentLoadException("Unsupported RGB pixel format");
                    }
                }
            }
            //else if (pixelFormat.dwFlags.HasFlag(Ddpf.Luminance))
            //{
            //    return SurfaceFormat.Alpha8;
            //}
            throw new ContentLoadException("Unsupported pixel format");
        }

        private static BitmapContent CreateBitmapContent(SurfaceFormat format, int width, int height) => format switch
            {
                SurfaceFormat.Color => new PixelBitmapContent<Color>(width, height),
                SurfaceFormat.Bgra4444 => new PixelBitmapContent<Bgra4444>(width, height),
                SurfaceFormat.Bgra5551 => new PixelBitmapContent<Bgra5551>(width, height),
                SurfaceFormat.Bgr565 => new PixelBitmapContent<Bgr565>(width, height),
                SurfaceFormat.Dxt1 => new Dxt1BitmapContent(width, height),
                SurfaceFormat.Dxt3 => new Dxt3BitmapContent(width, height),

View on GitHub (pinned to 1d71bbd0ff)

Solutions

  1. Re-export the texture at 32-bit B8G8R8X8 or to a supported block-compressed format.
  2. Run texconv -f B8G8R8A8_UNORM input.dds to normalize to a supported uncompressed format.
  3. Inspect the DDS header to confirm dwRgbBitCount and bit masks are consistent.

Example fix

// before: RGB DDS with unsupported bit depth (e.g. 8-bit)
// after:
//   texconv -f B8G8R8A8_UNORM texture.dds
Defensive patterns

Strategy: validation

Validate before calling

// Normalize RGB DDS files to a supported depth:
//   texconv -f B8G8R8A8_UNORM asset.dds
// Or for opaque textures, ensure dwRgbBitCount is 16, 24, or 32.

Try / catch

try
{
    texture = DdsLoader.Import(filename, context);
}
catch (ContentLoadException ex) when (ex.Message.Contains("Unsupported RGB pixel format"))
{
    logger.LogMessage($"{filename} has an unsupported RGB bit depth; re-export as 24/32-bit.");
    throw;
}

Prevention

When it happens

Trigger: Importing an uncompressed RGB DDS with a dwRgbBitCount value outside {16, 24, 32}, e.g. 8-bit paletted or other non-standard depth.

Common situations: Legacy paletted DDS exports; DDS files generated by unusual toolchains producing non-standard RGB depths; corrupted DDS headers.

Related errors


AI-assisted analysis of MonoGame/MonoGame@1d71bbd0ff (2026-08-13). Data as JSON: /api/errors/8aaa0656dfc137fc. Report an issue: GitHub.