extern "C" void TakeScreenshot(int iFrameNumber)
{
    char *filename;

    // look for an unused screenshot filename
    filename = GetNextScreenshotPath();
    if (filename == NULL)
        return;

    // get the width and height
    int width = 640;
    int height = 480;
    gfx.readScreen(NULL, &width, &height, 0);

    // allocate memory for the image
    unsigned char *pucFrame = (unsigned char *) malloc(width * height * 3);
    if (pucFrame == NULL)
    {
        free(filename);
        return;
    }

    // grab the back image from OpenGL by calling the video plugin
    gfx.readScreen(pucFrame, &width, &height, 0);

    // write the image to a PNG
    SaveRGBBufferToFile(filename, pucFrame, width, height, width * 3);
    // free the memory
    free(pucFrame);
    free(filename);
    // print message -- this allows developers to capture frames and use them in the regression test
    main_message(M64MSG_INFO, OSD_BOTTOM_LEFT, "Captured screenshot for frame %i.", iFrameNumber);
}
Esempio n. 2
0
extern "C" void TakeScreenshot(int iFrameNumber)
{
    char filepath[PATH_MAX], filename[PATH_MAX];

    // get screenshot directory and base filename (based on ROM header)
    GetBaseFilepath(filepath, PATH_MAX - 10);

    // look for an unused screenshot filename
    for (; CurrentShotIndex < 1000; CurrentShotIndex++)
    {
        sprintf(filename, "%s-%03i.png", filepath, CurrentShotIndex);
        FILE *pFile = fopen(filename, "r");
        if (pFile == NULL)
            break;
        fclose(pFile);
    }
    if (CurrentShotIndex >= 1000)
    {
        DebugMessage(M64MSG_ERROR, "Can't save screenshot; folder already contains 1000 screenshots for this ROM");
        return;
    }
    CurrentShotIndex++;

    // get the width and height
    int width = 640;
    int height = 480;
    readScreen(NULL, &width, &height, 0);

    // allocate memory for the image
    unsigned char *pucFrame = (unsigned char *) malloc(width * height * 3);
    if (pucFrame == 0)
        return;

    // grab the back image from OpenGL by calling the video plugin
    readScreen(pucFrame, &width, &height, 0);

    // write the image to a PNG
    SaveRGBBufferToFile(filename, pucFrame, width, height, width * 3);
    // free the memory
    free(pucFrame);
    // print message -- this allows developers to capture frames and use them in the regression test
    main_message(M64MSG_INFO, OSD_BOTTOM_LEFT, "Captured screenshot for frame %i.", iFrameNumber);
}