VirtualBox

Changeset 52958 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Oct 6, 2014 5:57:01 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
96400
Message:

Main: merged IMachine::readSavedThumbnailToArray and readSavedThumbnailPNGToArray

Location:
trunk/src/VBox/Main
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r52924 r52958  
    42494249  <interface
    42504250    name="IMachine" extends="$unknown"
    4251     uuid="96ae59d6-fecd-4a32-b051-23643eb4cd56"
     4251    uuid="2280b3f8-0c33-4641-8bd5-ccecd1071b49"
    42524252    wsmap="managed"
    42534253    wrap-hint-server-addinterfaces="IInternalMachineControl"
     
    71287128    <method name="readSavedThumbnailToArray">
    71297129      <desc>
    7130         Thumbnail is retrieved to an array of bytes in uncompressed 32-bit BGRA or RGBA format.
     7130        Thumbnail is retrieved to an array of bytes in the requested format.
    71317131      </desc>
    71327132      <param name="screenId" type="unsigned long" dir="in">
     
    71357135        </desc>
    71367136      </param>
    7137       <param name="BGR" type="boolean" dir="in">
    7138         <desc>
    7139           How to order bytes in the pixel. A pixel consists of 4 bytes. If this parameter is true, then
    7140           bytes order is: B, G, R, 0xFF. If this parameter is false, then bytes order is: R, G, B, 0xFF.
     7137      <param name="bitmapFormat" type="BitmapFormat" dir="in">
     7138        <desc>
     7139          The requested format.
    71417140        </desc>
    71427141      </param>
     
    71547153        <desc>
    71557154          Array with resulting bitmap data.
    7156         </desc>
    7157       </param>
    7158     </method>
    7159 
    7160     <method name="readSavedThumbnailPNGToArray">
    7161       <desc>
    7162         Thumbnail in PNG format is retrieved to an array of bytes.
    7163       </desc>
    7164       <param name="screenId" type="unsigned long" dir="in">
    7165         <desc>
    7166           Saved guest screen to read from.
    7167         </desc>
    7168       </param>
    7169       <param name="width" type="unsigned long" dir="out">
    7170         <desc>
    7171           Image width.
    7172         </desc>
    7173       </param>
    7174       <param name="height" type="unsigned long" dir="out">
    7175         <desc>
    7176           Image height.
    7177         </desc>
    7178       </param>
    7179       <param name="data" type="octet" dir="return" safearray="yes">
    7180         <desc>
    7181           Array with resulting PNG data.
    71827155        </desc>
    71837156      </param>
  • trunk/src/VBox/Main/include/MachineImpl.h

    r52801 r52958  
    11031103                                    ULONG *aHeight);
    11041104    HRESULT readSavedThumbnailToArray(ULONG aScreenId,
    1105                                       BOOL aBGR,
     1105                                      BitmapFormat_T aBitmapFormat,
    11061106                                      ULONG *aWidth,
    11071107                                      ULONG *aHeight,
    11081108                                      std::vector<BYTE> &aData);
    1109     HRESULT readSavedThumbnailPNGToArray(ULONG aScreenId,
    1110                                          ULONG *aWidth,
    1111                                          ULONG *aHeight,
    1112                                          std::vector<BYTE> &aData);
    11131109    HRESULT querySavedScreenshotPNGSize(ULONG aScreenId,
    11141110                                        ULONG *aSize,
  • trunk/src/VBox/Main/src-server/MachineImpl.cpp

    r52934 r52958  
    63066306}
    63076307
    6308 
    6309 HRESULT Machine::readSavedThumbnailToArray(ULONG aScreenId, BOOL aBGR, ULONG *aWidth, ULONG *aHeight, std::vector<BYTE> &aData)
     6308HRESULT Machine::readSavedThumbnailToArray(ULONG aScreenId, BitmapFormat_T aBitmapFormat,
     6309                                          ULONG *aWidth, ULONG *aHeight, std::vector<BYTE> &aData)
    63106310{
    63116311    if (aScreenId != 0)
    63126312        return E_NOTIMPL;
     6313
     6314    if (   aBitmapFormat != BitmapFormat_BGR0
     6315        && aBitmapFormat != BitmapFormat_BGRA
     6316        && aBitmapFormat != BitmapFormat_RGBA
     6317        && aBitmapFormat != BitmapFormat_PNG)
     6318        return setError(E_NOTIMPL,
     6319                        tr("Unsupported saved thumbnail format 0x%08X"), aBitmapFormat);
    63136320
    63146321    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     
    63236330    if (RT_FAILURE(vrc))
    63246331        return setError(VBOX_E_IPRT_ERROR,
    6325                         tr("Saved screenshot data is not available (%Rrc)"),
     6332                        tr("Saved thumbnail data is not available (%Rrc)"),
    63266333                        vrc);
     6334
     6335    HRESULT hr = S_OK;
    63276336
    63286337    *aWidth = u32Width;
    63296338    *aHeight = u32Height;
    63306339
    6331     aData.resize(cbData);
    6332     /* Convert pixels to format expected by the API caller. */
    6333     if (aBGR)
    6334     {
    6335         /* [0] B, [1] G, [2] R, [3] A. */
    6336         for (unsigned i = 0; i < cbData; i += 4)
    6337         {
    6338             aData[i]     = pu8Data[i];
    6339             aData[i + 1] = pu8Data[i + 1];
    6340             aData[i + 2] = pu8Data[i + 2];
    6341             aData[i + 3] = 0xff;
    6342         }
    6343     }
    6344     else
    6345     {
    6346         /* [0] R, [1] G, [2] B, [3] A. */
    6347         for (unsigned i = 0; i < cbData; i += 4)
    6348         {
    6349             aData[i]     = pu8Data[i + 2];
    6350             aData[i + 1] = pu8Data[i + 1];
    6351             aData[i + 2] = pu8Data[i];
    6352             aData[i + 3] = 0xff;
     6340    if (cbData > 0)
     6341    {
     6342        /* Convert pixels to the format expected by the API caller. */
     6343        if (aBitmapFormat == BitmapFormat_BGR0)
     6344        {
     6345            /* [0] B, [1] G, [2] R, [3] 0. */
     6346            aData.resize(cbData);
     6347            memcpy(&aData.front(), pu8Data, cbData);
     6348        }
     6349        else if (aBitmapFormat == BitmapFormat_BGRA)
     6350        {
     6351            /* [0] B, [1] G, [2] R, [3] A. */
     6352            aData.resize(cbData);
     6353            for (uint32_t i = 0; i < cbData; i += 4)
     6354            {
     6355                aData[i]     = pu8Data[i];
     6356                aData[i + 1] = pu8Data[i + 1];
     6357                aData[i + 2] = pu8Data[i + 2];
     6358                aData[i + 3] = 0xff;
     6359            }
     6360        }
     6361        else if (aBitmapFormat == BitmapFormat_RGBA)
     6362        {
     6363            /* [0] R, [1] G, [2] B, [3] A. */
     6364            aData.resize(cbData);
     6365            for (uint32_t i = 0; i < cbData; i += 4)
     6366            {
     6367                aData[i]     = pu8Data[i + 2];
     6368                aData[i + 1] = pu8Data[i + 1];
     6369                aData[i + 2] = pu8Data[i];
     6370                aData[i + 3] = 0xff;
     6371            }
     6372        }
     6373        else if (aBitmapFormat == BitmapFormat_PNG)
     6374        {
     6375            uint8_t *pu8PNG = NULL;
     6376            uint32_t cbPNG = 0;
     6377            uint32_t cxPNG = 0;
     6378            uint32_t cyPNG = 0;
     6379
     6380            vrc = DisplayMakePNG(pu8Data, u32Width, u32Height, &pu8PNG, &cbPNG, &cxPNG, &cyPNG, 0);
     6381
     6382            if (RT_SUCCESS(vrc))
     6383            {
     6384                aData.resize(cbPNG);
     6385                if (cbPNG)
     6386                    memcpy(&aData.front(), pu8PNG, cbPNG);
     6387            }
     6388            else
     6389                hr = setError(VBOX_E_IPRT_ERROR,
     6390                              tr("Could not convert saved thumbnail to PNG (%Rrc)"),
     6391                              vrc);
     6392
     6393            RTMemFree(pu8PNG);
    63536394        }
    63546395    }
     
    63566397    freeSavedDisplayScreenshot(pu8Data);
    63576398
    6358     return S_OK;
    6359 }
    6360 
    6361 HRESULT Machine::readSavedThumbnailPNGToArray(ULONG aScreenId, ULONG *aWidth, ULONG *aHeight, std::vector<BYTE> &aData)
    6362 {
    6363     if (aScreenId != 0)
    6364         return E_NOTIMPL;
    6365 
    6366     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    6367 
    6368     uint8_t *pu8Data = NULL;
    6369     uint32_t cbData = 0;
    6370     uint32_t u32Width = 0;
    6371     uint32_t u32Height = 0;
    6372 
    6373     int vrc = readSavedDisplayScreenshot(mSSData->strStateFilePath, 0 /* u32Type */, &pu8Data, &cbData, &u32Width, &u32Height);
    6374 
    6375     if (RT_FAILURE(vrc))
    6376         return setError(VBOX_E_IPRT_ERROR,
    6377                         tr("Saved screenshot data is not available (%Rrc)"),
    6378                         vrc);
    6379 
    6380     *aWidth = u32Width;
    6381     *aHeight = u32Height;
    6382 
    6383     HRESULT rc = S_OK;
    6384     uint8_t *pu8PNG = NULL;
    6385     uint32_t cbPNG = 0;
    6386     uint32_t cxPNG = 0;
    6387     uint32_t cyPNG = 0;
    6388 
    6389     vrc = DisplayMakePNG(pu8Data, u32Width, u32Height, &pu8PNG, &cbPNG, &cxPNG, &cyPNG, 0);
    6390 
    6391     if (RT_SUCCESS(vrc))
    6392     {
    6393         aData.resize(cbPNG);
    6394         if (cbPNG)
    6395             memcpy(&aData.front(), pu8PNG, cbPNG);
    6396         if (pu8PNG)
    6397             RTMemFree(pu8PNG);
    6398     }
    6399     else
    6400     {
    6401         if (pu8PNG)
    6402             RTMemFree(pu8PNG);
    6403         return setError(VBOX_E_IPRT_ERROR,
    6404                         tr("Could not convert screenshot to PNG (%Rrc)"),
    6405                         vrc);
    6406     }
    6407 
    6408     freeSavedDisplayScreenshot(pu8Data);
    6409 
    6410     return rc;
     6399    return hr;
    64116400}
    64126401
Note: See TracChangeset for help on using the changeset viewer.

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