VirtualBox

Changeset 36720 in vbox


Ignore:
Timestamp:
Apr 18, 2011 5:17:07 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
71237
Message:

Frontends/VBoxManage: support taking screenshots

Location:
trunk/src/VBox/Frontends/VBoxManage
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageControlVM.cpp

    r35907 r36720  
    55
    66/*
    7  * Copyright (C) 2006-2010 Oracle Corporation
     7 * Copyright (C) 2006-2011 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3636#include <iprt/string.h>
    3737#include <iprt/uuid.h>
     38#include <iprt/file.h>
    3839#include <VBox/log.h>
    3940
     
    10251026            }
    10261027        }
     1028        else if (!strcmp(a->argv[1], "screenshotpng"))
     1029        {
     1030            if (a->argc <= 2 || a->argc > 4)
     1031            {
     1032                errorSyntax(USAGE_CONTROLVM, "Incorrect number of parameters");
     1033                rc = E_FAIL;
     1034                break;
     1035            }
     1036            int vrc;
     1037            uint32_t displayIdx = 0;
     1038            if (a->argc == 4)
     1039            {
     1040                vrc = RTStrToUInt32Ex(a->argv[3], NULL, 0, &displayIdx);
     1041                if (vrc != VINF_SUCCESS)
     1042                {
     1043                    errorArgument("Error parsing display number '%s'", a->argv[3]);
     1044                    rc = E_FAIL;
     1045                    break;
     1046                }
     1047            }
     1048            ComPtr<IDisplay> pDisplay;
     1049            CHECK_ERROR_BREAK(console, COMGETTER(Display)(pDisplay.asOutParam()));
     1050            ULONG width, height, bpp;
     1051            CHECK_ERROR_BREAK(pDisplay, GetScreenResolution(displayIdx, &width, &height, &bpp));
     1052            com::SafeArray<BYTE> saScreenshot;
     1053            CHECK_ERROR_BREAK(pDisplay, TakeScreenShotPNGToArray(displayIdx, width, height, ComSafeArrayAsOutParam(saScreenshot)));
     1054            RTFILE pngFile = NIL_RTFILE;
     1055            vrc = RTFileOpen(&pngFile, a->argv[2], RTFILE_O_OPEN_CREATE | RTFILE_O_WRITE | RTFILE_O_TRUNCATE);
     1056            if (RT_FAILURE(vrc))
     1057            {
     1058                RTMsgError("Failed to create file '%s'. rc=%Rrc", a->argv[2], vrc);
     1059                rc = E_FAIL;
     1060                break;
     1061            }
     1062            vrc = RTFileWrite(pngFile, saScreenshot.raw(), saScreenshot.size(), NULL);
     1063            if (RT_FAILURE(vrc))
     1064            {
     1065                RTMsgError("Failed to write screenshot to file '%s'. rc=%Rrc", a->argv[2], vrc);
     1066                rc = E_FAIL;
     1067            }
     1068            RTFileClose(pngFile);
     1069        }
    10271070        else
    10281071        {
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp

    r36657 r36720  
    399399        RTStrmPrintf(pStrm,
    400400                     "                            setvideomodehint <xres> <yres> <bpp> [display] |\n"
     401                     "                            screenshotpng <file> [display] |\n"
    401402                     "                            setcredentials <username> <password> <domain>\n"
    402403                     "                                           [--allowlocallogon <yes|no>] |\n"
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette