> ## Documentation Index
> Fetch the complete documentation index at: https://docs.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.

## Sintaxis

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

### Miembros

Esta estructura no contiene miembros de datos.

## Comentarios

Use esta estructura para recopilar capturas de pantalla.

Puede realizar una captura de pantalla del juego llamando a [XAppCaptureTakeScreenshot](https://docs.xbox.com/es/reference/system/xappcapture/functions/xappcapturetakescreenshot.md).

`XAppCaptureTakeScreenshot` devuelve uno o varios id. locales, que puede usar para recuperar una captura de pantalla pasándolos en una llamada a [XAppCaptureOpenScreenshotStream](https://docs.xbox.com/es/reference/system/xappcapture/functions/xappcaptureopenscreenshotstream.md). 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](https://docs.xbox.com/es/reference/system/xappcapture/functions/xappcapturereadscreenshotstream.md).

Cuando haya terminado, cierre el identificador llamando a [XAppCaptureCloseScreenshotStream](https://docs.xbox.com/es/reference/system/xappcapture/functions/xappcaptureclosescreenshotstream.md).

## 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);

}

```

## Requisitos

**Encabezado:** XAppCapture.h

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

## Consulte también

[Miembros de XAppCapture](https://docs.xbox.com/es/reference/system/xappcapture/xappcapture_members.md)\
[XAppCaptureTakeScreenshot](https://docs.xbox.com/es/reference/system/xappcapture/functions/xappcapturetakescreenshot.md)\
[xappcapturescreenshotformatflag](https://docs.xbox.com/es/reference/system/xappcapture/enums/xappcapturescreenshotformatflag.md)


## Related topics

- [XAppCapture (contenido de la API)](https://docs.xbox.com/es/reference/system/xappcapture/xappcapture_members.md)
- [XAppCaptureOpenScreenshotStream](https://docs.xbox.com/es/reference/system/xappcapture/functions/xappcaptureopenscreenshotstream.md)
- [XAppCaptureReadScreenshotStream](https://docs.xbox.com/es/reference/system/xappcapture/functions/xappcapturereadscreenshotstream.md)
- [XAppCaptureCloseScreenshotStream](https://docs.xbox.com/es/reference/system/xappcapture/functions/xappcaptureclosescreenshotstream.md)
- [XAppCaptureTakeScreenshot](https://docs.xbox.com/es/reference/system/xappcapture/functions/xappcapturetakescreenshot.md)
