---
name: "SDL_BYTESPERPIXEL"
section: "3"
platform: "linux"
package: "libsdl3-doc"
version: "3.2.10+ds-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/SDL_BYTESPERPIXEL"
---

# SDL\_BYTESPERPIXEL(3)

A macro to determine an SDL\_PixelFormat

## NAME

SDL\_BYTESPERPIXEL - A macro to determine an  **SDL\_PixelFormat**

## HEADER FILE

Defined in SDL3/SDL\_pixels.h

## SYNOPSIS

```
#include "SDL3/SDL.h"
```

**#define SDL\_BYTESPERPIXEL(format) .BI** *(SDL\_ISPIXELFORMAT\_FOURCC(format)***?***.BI*        **((((format) == SDL\_PIXELFORMAT\_YUY2) \|\| .BI** *((format)***==***SDL\_PIXELFORMAT\_UYVY)***\|\|***.BI*          **((format) == SDL\_PIXELFORMAT\_YVYU) \|\| .BI** *((format)***==***SDL\_PIXELFORMAT\_P010))***?***2***:***1)***:***(((format)***\>\>***0)***&***0xFF))*

## DESCRIPTION

Note that this macro double-evaluates its parameter, so do not use expressions with side-effects here.

FourCC formats do their best here, but many of them don't have a meaningful measurement of bytes per pixel.

## RETURN VALUE

Returns the bytes-per-pixel of **format** .

## THREAD SAFETY

It is safe to call this macro from any thread.

## AVAILABILITY

This macro is available since SDL 3.2.0.

## SEE ALSO

**•**(3), [**SDL\_BITSPERPIXEL**(3)](/SDL_BITSPERPIXEL/3.md)
