> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# XAppCaptureScreenshotStream

> XAppCaptureScreenshotStream

# XAppCaptureScreenshotStream

Representa una secuencia de captura de pantalla.

<a id="syntaxSection" />

## Sintaxis

```cpp theme={null}
typedef struct XAppCaptureScreenshotStream {  
} XAppCaptureScreenshotStream  
```

<a id="membersSection" />

### Miembros

Esta estructura no contiene miembros de datos.

<a id="remarksSection" />

## Comentarios

Use esta estructura para recopilar capturas de pantalla.

Puede realizar una captura de pantalla del juego llamando a [XAppCaptureTakeScreenshot](/reference/system/xappcapture/functions/xappcapturetakescreenshot).

`XAppCaptureTakeScreenshot` devuelve uno o varios id. locales, que puede usar para recuperar una captura de pantalla pasándolos en una llamada a [XAppCaptureOpenScreenshotStream](/reference/system/xappcapture/functions/xappcaptureopenscreenshotstream). Obtendrá dos id. locales si realiza una captura de pantalla de una pantalla HDR: uno para la versión SDR y otro para la versión HDR.

`XAppCaptureOpenScreenshotStream` devuelve un identificador del objeto `XAppCaptureScreenshotStream`. Puede usar este identificador para leer el contenido de la secuencia pasándolo en una llamada a [XAppCaptureReadScreenshotStream](/reference/system/xappcapture/functions/xappcapturereadscreenshotstream).

Cuando haya terminado, cierre el identificador llamando a [XAppCaptureCloseScreenshotStream](/reference/system/xappcapture/functions/xappcaptureclosescreenshotstream).

<a id="exampleSection" />

## Ejemplo

El siguiente ejemplo de código muestra cómo escribir el contenido de la secuencia de captura de pantalla en un archivo local.

```cpp theme={null}
void WriteScreenshotStreamToFile(_In_ const char* screenshotLocalId, _In_ XAppCaptureScreenshotFormatFlag screenshotFormat, _In_ const char* filePath)
{
    const int MAX_DATA = 1024;
    XAppCaptureScreenshotStreamHandle handle = nullptr;
    BYTE buffer[MAX_DATA];
    HANDLE file = INVALID_HANDLE_VALUE;
    UINT64 totalBytesRead = 0;
    UINT64 totalBytesToRead = 0;

    if (FAILED_LOG(XAppCaptureOpenScreenshotStream(screenshotLocalId, screenshotFormat, &handle, &totalBytesToRead)))
    {
        return;
    }

    appLog.AddLog("%I64d bytes returned\n", totalBytesToRead);

    file = CreateFileA(filePath, GENERIC_READ | GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
    if (file == INVALID_HANDLE_VALUE)
    {
        appLog.AddLog("Could not create %s\n", filePath);
        goto Cleanup;
    }

    while (totalBytesRead < totalBytesToRead)
    {
        uint32_t bytesRead = 0;
        DWORD bytesWritten = 0;

        if (FAILED_LOG(XAppCaptureReadScreenshotStream(handle, totalBytesRead, sizeof(buffer), buffer, &bytesRead)))
        {
            goto Cleanup;
        }

        BOOL result = WriteFile(file, buffer, bytesRead, &bytesWritten, NULL );
        if (!result)
        {
            appLog.AddLog("Failed to write to %s\n", filePath);
            goto Cleanup;
        }

        totalBytesRead += bytesRead;
    }

Cleanup:
    if (handle != nullptr)
    {
        FAILED_LOG(XAppCaptureCloseScreenshotStream(handle));
    }
    if (file != INVALID_HANDLE_VALUE)
    {
        CloseHandle(file);
    }
    appLog.AddLog("Wrote out %I64d bytes to %s\n", totalBytesRead, filePath);

}

```

<a id="requirementsSection" />

## Requisitos

**Encabezado:** XAppCapture.h

**Plataformas compatibles:** Windows, consolas de la familia XBOX One y consolas XBOX Series

## Consulte también

[Miembros de XAppCapture](/reference/system/xappcapture/xappcapture_members)\
[XAppCaptureTakeScreenshot](/reference/system/xappcapture/functions/xappcapturetakescreenshot)\
[xappcapturescreenshotformatflag](/reference/system/xappcapture/enums/xappcapturescreenshotformatflag)
