Changeset 52958 in vbox for trunk/src/VBox/Main
- Timestamp:
- Oct 6, 2014 5:57:01 PM (10 years ago)
- svn:sync-xref-src-repo-rev:
- 96400
- Location:
- trunk/src/VBox/Main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/idl/VirtualBox.xidl
r52924 r52958 4249 4249 <interface 4250 4250 name="IMachine" extends="$unknown" 4251 uuid=" 96ae59d6-fecd-4a32-b051-23643eb4cd56"4251 uuid="2280b3f8-0c33-4641-8bd5-ccecd1071b49" 4252 4252 wsmap="managed" 4253 4253 wrap-hint-server-addinterfaces="IInternalMachineControl" … … 7128 7128 <method name="readSavedThumbnailToArray"> 7129 7129 <desc> 7130 Thumbnail is retrieved to an array of bytes in uncompressed 32-bit BGRA or RGBAformat.7130 Thumbnail is retrieved to an array of bytes in the requested format. 7131 7131 </desc> 7132 7132 <param name="screenId" type="unsigned long" dir="in"> … … 7135 7135 </desc> 7136 7136 </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. 7141 7140 </desc> 7142 7141 </param> … … 7154 7153 <desc> 7155 7154 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.7182 7155 </desc> 7183 7156 </param> -
trunk/src/VBox/Main/include/MachineImpl.h
r52801 r52958 1103 1103 ULONG *aHeight); 1104 1104 HRESULT readSavedThumbnailToArray(ULONG aScreenId, 1105 B OOL aBGR,1105 BitmapFormat_T aBitmapFormat, 1106 1106 ULONG *aWidth, 1107 1107 ULONG *aHeight, 1108 1108 std::vector<BYTE> &aData); 1109 HRESULT readSavedThumbnailPNGToArray(ULONG aScreenId,1110 ULONG *aWidth,1111 ULONG *aHeight,1112 std::vector<BYTE> &aData);1113 1109 HRESULT querySavedScreenshotPNGSize(ULONG aScreenId, 1114 1110 ULONG *aSize, -
trunk/src/VBox/Main/src-server/MachineImpl.cpp
r52934 r52958 6306 6306 } 6307 6307 6308 6309 HRESULT Machine::readSavedThumbnailToArray(ULONG aScreenId, BOOL aBGR,ULONG *aWidth, ULONG *aHeight, std::vector<BYTE> &aData)6308 HRESULT Machine::readSavedThumbnailToArray(ULONG aScreenId, BitmapFormat_T aBitmapFormat, 6309 ULONG *aWidth, ULONG *aHeight, std::vector<BYTE> &aData) 6310 6310 { 6311 6311 if (aScreenId != 0) 6312 6312 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); 6313 6320 6314 6321 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); … … 6323 6330 if (RT_FAILURE(vrc)) 6324 6331 return setError(VBOX_E_IPRT_ERROR, 6325 tr("Saved screenshotdata is not available (%Rrc)"),6332 tr("Saved thumbnail data is not available (%Rrc)"), 6326 6333 vrc); 6334 6335 HRESULT hr = S_OK; 6327 6336 6328 6337 *aWidth = u32Width; 6329 6338 *aHeight = u32Height; 6330 6339 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); 6353 6394 } 6354 6395 } … … 6356 6397 freeSavedDisplayScreenshot(pu8Data); 6357 6398 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; 6411 6400 } 6412 6401
Note:
See TracChangeset
for help on using the changeset viewer.