Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

C has no portable screenshot function. A C program must call the capture API supplied by its operating system (or desktop session), obtain pixels, and encode or save them. Choose the target first: a complete display, a window, or a rectangular region. Then choose whether you need one still image or a continuous stream.

The implementation and permission model differ substantially between Windows, macOS, Linux sessions, and QNX. The examples below identify those boundaries instead of pretending that one ISO C snippet works everywhere.

Choose the capture path before writing code

Target Best-supported path Important considerations
Windows, user selects a display or window Windows.Graphics.Capture Uses a system picker; translate the documented projection to your C/COM interop layer.
Windows, basic one-off bitmap Win32 GDI Compatible device context and bitmap; suitable for a still BMP, not a portable API.
Windows, repeated frames DXGI Desktop Duplication BGRA surfaces, dirty/moved regions, rotation, frame and pointer handling.
macOS display, app, or window ScreenCaptureKit Screen Recording permission; C callers need Objective-C interoperability.
Linux on Wayland XDG Desktop Portal route Desktop/session policy controls what can be shared; do not assume X11 access.
Linux on X11 X11 and related display libraries Code is session-specific and is not a Wayland recipe.
QNX display QNX Screen API Display capture requires a privileged display-manager context and effective user ID root.

Windows: select a window or display with Windows.Graphics.Capture

For a user-driven still screenshot, Windows.Graphics.Capture presents a picker so the user explicitly chooses an application window or display. Your program creates a capture item and session, receives a frame, copies the surface into an image buffer, and writes the result. Microsoft documents this workflow for Windows desktop devices and Windows Mixed Reality headsets; check support before showing the feature.

Implementation boundary for C

The official picker example is written in C#, and the API is exposed through Windows Runtime types. A C program therefore needs the Windows Runtime/COM projection or a C-compatible interop layer for its SDK, plus a graphics device and a pixel-copy path. Do not paste C# syntax into a C compiler and expect it to work.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
LAPGEAR Home Office Pro Lap Desk - Black Carbon, Fits 15.6” Laptops
  • Spacious Design: Measuring 21.1" wide and 14.1" deep, our lap desk comfortably fits most laptops up to 15.6". Extra room for accessories ensures convenience.
  • Enhanced Functionality: Packed with handy features, including a 5x9" precision tracking mouse pad and a built-in phone slot for seamless work or video calls. Plus, enjoy ergonomic support with the integrated cushioned wrist rest.
  • Cool Comfort: Enjoy a stable surface with our lap desk's dual bolster cushion, designed for comfort and airflow, keeping your lap cool during extended use.
  • Durable Surface: Work with confidence on our lap desk's solid surface, featuring a sleek black carbon color, ensuring optimal air circulation to prevent your laptop from overheating.
  • On-the-Go Convenience: With an integrated handle and lightweight design (2.8 lbs), our lap desk is portable for travel or moving around the house, offering flexibility in any space.
  1. Initialize COM/Windows Runtime on the thread that creates the capture objects.
  2. Create the picker and initialize its host window when the API requires one.
  3. Let the user select a display or window.
  4. Create the capture session and a frame pool with a format your renderer can consume.
  5. Acquire a frame, copy its texture to CPU-readable memory, and encode PNG, JPEG, or BMP with a Windows imaging component or your own encoder.
  6. Close the frame, session, pool, and graphics resources on every success and error path.

For a minimal one-off bitmap, Win32 GDI’s documented “Capturing an Image” pattern creates a compatible device context and bitmap, selects the bitmap into the context, performs a bit-block transfer, and saves a BMP. This is a GDI solution for Windows, not a C standard-library facility.

Windows: use DXGI Desktop Duplication for continuous frames

Desktop Duplication is intended for collaboration, recording, remote assistance, and other frame-by-frame workloads. After creating a duplication object, call AcquireNextFrame, process the returned surface, and release the frame before acquiring the next one.

Details that commonly break captures

  • The surface is normally BGRA. Convert channel order if your encoder expects RGB.
  • Metadata describes dirty rectangles and moved rectangles. Applying only those regions can reduce copying, but your compositor must preserve the previous frame correctly.
  • The pointer may be separate from the desktop image. Read pointer-shape/position information and draw it yourself when it is not already included.
  • Rotated displays require rotating the captured image to the intended orientation.
  • Handle timeouts, access loss, mode changes, and device removal by releasing the duplication object and recreating it.

Duplication is substantially more complex than a single screenshot. If the user only needs one image, the picker workflow or GDI is usually easier to maintain.

macOS: ScreenCaptureKit and Screen Recording permission

Apple’s ScreenCaptureKit represents shareable displays, applications, and windows. It provides SCScreenshotManager for a single frame and SCStream for ongoing capture. Apple recommends the system content-sharing picker when the user should choose the source.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Permission and C interoperability

The app must request Screen Recording permission. A denied permission can produce an empty or failed capture even when your pixel-copy code is correct. The framework documentation is Objective-C/Swift oriented, so plain ISO C cannot call it directly without a bridge: compile an Objective-C or Objective-C++ translation unit, expose a C-callable wrapper, and pass opaque handles or copied pixel buffers to the C portion of your program.

Apple’s current capture sample states macOS 15 or later and Xcode 16 or later. Those are sample prerequisites, not a universal minimum for every ScreenCaptureKit use; verify the deployment target and API availability for your application.

  1. Enable the Screen Recording usage/entitlement configuration appropriate to your app type.
  2. Request access and direct the user to System Settings when access is denied.
  3. Use the content-sharing picker or enumerate shareable content according to your UX.
  4. For one image, use the screenshot manager; for a stream, configure an SCStream output.
  5. Convert the delivered pixel buffer to your C image structure and encode it.

Linux: Wayland and X11 are different implementations

First identify the session. A legacy X11 capture snippet is not a universal Linux solution: Wayland intentionally restricts direct clients from reading the entire desktop.

Wayland

A C-written project such as snapx demonstrates using the XDG Desktop Portal screenshot path on Wayland. The portal asks the desktop environment to mediate capture and user consent. Exact behavior depends on the desktop and session, so treat that project as an example backend rather than a universal API contract. Test window, display, and region selection on each desktop environment you support.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Yilador Webcam Cover 3 Pack, 0.03 inch Ultra Thin Laptop Camera Cover Slide
  • Note: Not suitable for MacBooks released after 2023 or devices with a protruding front camera; Not applicable to full-screen or notch-style tempered glass screen protectors; Do not use on the rear camera of the phone.
  • 💻 Why Do You Need a Webcam Cover Slide? — Safeguard your privacy by covering your webcam with our reliable webcam cover when not in use. Don't let anyone secretly watch you. Stay protected!
  • ✅ Thin & Stylish — Enhance your laptop's functionality and aesthetics with our 0.027" ultra-thin webcam covers. Seamlessly close your laptop while adding a touch of sophistication.
  • ✅ Fits Most Devices — Compatible with laptops, phones, tablets, desktops! Keep your privacy intact on Ap/ple, Mac/Book, iPh/one, iP/ad, H/P, L/novo, De/ll, Ac/er, As/us, Sa/msung devices.
  • ✅ 365 Days Protection — Our upgraded 3.0 adhesive ensures a strong hold that won't damage your equipment. Experience reliable, long-term privacy protection day in and day out.

X11

On X11, applications commonly use X11 display APIs and related XRandR functionality to identify screens and copy pixels. This can work for a full-screen image, but multi-monitor geometry, scaling, compositing, and permissions vary by server. Keep the X11 backend separate from the Wayland backend and detect the session before initialization.

QNX: a privileged embedded-display path

QNX’s Screen API copies display or window pixels into a suitably configured pixmap or window buffer. Display screenshots are privileged: the process needs a display-manager context and an effective user ID of root. This requirement is specific to QNX embedded systems and must not be presented as a Linux desktop instruction.

Pixel buffers, encoding, and file output

Capture APIs usually return raw pixels, not a finished PNG. Record width, height, stride, channel order, and alpha semantics with every frame. A BGRA buffer cannot safely be written as RGB without swapping channels, and a stride may be larger than width × bytes_per_pixel.

  • PNG: lossless and appropriate for text or interface screenshots.
  • JPEG: smaller for photographic content but introduces loss.
  • BMP: simple for Windows experiments, usually much larger.
  • WebP: useful when your encoder and downstream tools support it.

For repeated capture, avoid encoding on the frame-acquisition thread. Copy or reference the frame, enqueue work, release the operating-system frame promptly, and let a worker perform conversion and compression. Bound the queue so a slow disk or encoder cannot exhaust memory.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
AboveTEK Portable Laptop Lap Desk w/Retractable Left/Right Mouse Pad Tray, Non-Slip Heat Shield Tablet Notebook Computer Stand Table w/Sturdy Stable Work Surface for Bed Sofa Couch or Travel
  • Anti-Slip Surface - Transform your laptop into a mobile workstation with the AboveTEK portable laptop lap desk. The anti-slip surface provides a strong grip for laptops up to 15.6 inches(Diagonal), while the double rubber strip on the bottom ensures a stable display or typing experience on your lap, couch, or bed.
  • Retractable Mouse Pad - Retractable laptop mouse pad extends on both directions for the left/right handed with elevation along the edges for stopping mouse from falling off. The size of laptop tray is 14" X 9.7" and the size of mouse pad is 7.4" X 6.1".
  • Effective Heat Shield - The effective heat shield made of sturdy and thick material protects your laptop from overheating. Prioritizes your comfort and safety, an ideal lap pad or board for working anywhere.
  • EASY to Carry and Store - With an ergonomic and simplistic design, the lap desk is portable to store in a backpack. Only 15" in size, 2.2 lb of weight and with slim 0.6 inch thickness, it is ready to be easily carried around.
  • Widely Applicable - The smooth platform accommodates laptops and tablets up to 15.6 inches(Diagonal), making it a versatile accessory and one of the best gifts for mom, dad, students and professionals. Perfect for use as a laptop bed tray or tablet holder anywhere at home, library, or park.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common failures and fixes

“There is no screenshot function in C”

That is expected. Select a platform backend or use a cross-platform library that already supplies those backends. Keep the public part of your program in C and isolate Windows, Apple, Wayland, and X11 code behind a small interface.

Black, blank, or transparent output

  • On macOS, confirm Screen Recording permission and restart the app after changing it.
  • On Wayland, use the portal rather than trying to read the compositor’s buffers directly.
  • Check that the graphics surface was copied to CPU-visible memory before encoding.
  • Verify stride, pixel format, alpha, and color-channel order.

Only part of a monitor appears

Inspect virtual-desktop coordinates, per-monitor scaling, and rotated-display metadata. DXGI clients must account for rotation; X11 clients must account for the server’s monitor geometry.

Frames stop arriving on Windows

Release each acquired frame, handle timeout and access-loss results, and recreate duplication after display-mode or device changes. Do not continue using a stale duplication object.

Permission works during development but fails for users

Make permission denial a normal branch: explain why capture is needed, direct the user to the operating system’s privacy settings, and show a retry control. A hidden or unsigned permission request is not a substitute for user consent.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Sale
LAPGEAR Home Office Lap Desk – Pink, Fits 15.6” Laptops
  • Spacious Design: Measuring 21.1" wide and 12" deep, our lap desk comfortably fits most laptops up to 15.6". Extra room for accessories ensures convenience.
  • Enhanced Functionality: Packed with handy features, including a 5x9" precision tracking mouse pad and a built-in phone slot for seamless work or video calls. Plus, enjoy laptop support with the integrated device ledge.
  • Cool Comfort: Enjoy a stable surface with our lap desk's dual bolster cushion, designed for comfort and airflow, keeping your lap cool during extended use.
  • Durable Surface: Work with confidence on our lap desk's solid surface, featuring a blush pink color, ensuring optimal air circulation to prevent your laptop from overheating.
  • On-the-Go Convenience: With an integrated handle and lightweight design (2.14 lbs), our lap desk is portable for travel or moving around the house, offering flexibility in any space.

Testing checklist

  • Test one display, multiple displays, a window, and a region where the platform supports each target.
  • Test light and dark desktop themes, display scaling, rotation, and a changed monitor layout.
  • Test permission denied, permission revoked while running, minimized windows, and protected or unavailable content.
  • Validate image dimensions, stride, channels, alpha, and file decoding independently of the capture code.
  • Measure capture latency, encoder time, memory use, and queue depth for streams.

Or skip the browser setup

If your real goal is to obtain a website image rather than capture the user’s desktop, ScreenshotNeo provides a single HTTP request. It accepts the cookie or consent banner like a visitor, removes more than 60 known consent platforms plus newsletter popups and chat widgets, and lets you turn each step off. Bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing; response headers identify the page verdict and whether it was billed.

It also offers an MCP server for AI agents (including Claude and Cursor), with take_screenshot, get_page_info, and capture_pdf. Features include full-page lazy-image loading, CSS-selector element capture, dark mode, device presets and arbitrary viewports, retina scale, PDF controls, custom CSS/JavaScript, clicks, waits, blocked resources, headers/cookies/user agents, timezone and geolocation, transparent backgrounds, resizing, chosen-TTL caching, signed links, asynchronous webhooks, bulk capture of 100 URLs per call, usage data, and an OpenAPI specification. Parameters used by other screenshot APIs also work.

See the ScreenshotNeo documentation for the complete option list. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Try the free ScreenshotNeo account.

cURL

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Node.js

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

Frequently Asked Questions

Can ISO C take a screenshot without operating-system code?

No. ISO C supplies no desktop capture API; use an OS backend or a library that supplies platform-specific backends.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Should I use a still-image API or a frame stream?

Use a picker or still-image path for one screenshot. Choose DXGI Desktop Duplication or ScreenCaptureKit streaming only when you need ongoing frames.

Why is my Linux screenshot code unreliable across computers?

Linux desktops may run Wayland or X11, with different permissions and capture mechanisms. Detect the session and maintain separate backends.

The Bottom Line

Implement screenshots as a platform backend: Windows.Graphics.Capture, GDI, or DXGI on Windows; ScreenCaptureKit on macOS; a portal or X11 path on Linux; and the privileged Screen API on QNX. There is no portable C call that replaces those choices.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.