Quick answer: Clipboard image data is OS-specific (DIB/BMP on Windows, PNG/TIFF on macOS). Call scrap.get_types(), pick a format you can decode, and feed the bytes through pygame.image.load with a BytesIO.

A level editor lets users paste a reference image. scrap.get(SCRAP_BMP) returns bytes that won’t decode — the OS put a different format on the clipboard.

Inspect Available Types

pygame.scrap.init()
for t in pygame.scrap.get_types():
    print(t)
# Windows: "image/bmp", "CF_DIB", ...
# macOS:   "public.png", "public.tiff", ...

Don’t assume a format — ask the clipboard what it actually holds.

Decode the Matching Format

import io

def paste_image():
    types = pygame.scrap.get_types()
    for fmt in ("image/png", "public.png", "image/bmp"):
        if fmt in types:
            data = pygame.scrap.get(fmt)
            if data:
                return pygame.image.load(io.BytesIO(data))
    return None

Try formats in priority order; load the first one that’s present. pygame.image.load handles a BytesIO stream directly.

Windows DIB Caveat

Windows often offers CF_DIB — a headerless device-independent bitmap. It needs a 14-byte BMP file header prepended before pygame.image.load will accept it. Prefer image/png if the clipboard offers it.

Verifying

Copy an image in a browser, a paint app, and a screenshot tool. Each pastes into the editor correctly. Unsupported clipboard contents fail gracefully (return None).

“Clipboard image formats are OS-specific. Enumerate types, decode the one you support.”

For cross-platform tools, PNG is the most reliable common denominator — prefer it whenever the clipboard offers it.