Changeset 24539 in vbox
- Timestamp:
- Nov 10, 2009 11:59:03 AM (15 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/DisplayImpl.cpp
r24490 r24539 666 666 AssertRCReturn(rc, rc); 667 667 668 #if 0669 668 /* uInstance is an arbitrary value greater than 1024. Such a value will ensure a quick seek in saved state file. */ 670 669 rc = SSMR3RegisterExternal(pVM, "DisplayScreenshot", 1100 /*uInstance*/, sSSMDisplayScreenshotVer, 0 /*cbGuess*/, … … 674 673 675 674 AssertRCReturn(rc, rc); 676 #endif677 675 678 676 return VINF_SUCCESS; -
trunk/src/VBox/Main/MachineImpl.cpp
r24528 r24539 3923 3923 static int readSavedDisplayScreenshot(Utf8Str *pStateFilePath, uint32_t u32Type, uint8_t **ppu8Data, uint32_t *pcbData, uint32_t *pu32Width, uint32_t *pu32Height) 3924 3924 { 3925 LogFlowFunc(("u32Type = %d [%s]\n", u32Type, pStateFilePath->raw())); 3926 3925 3927 /* @todo cache read data */ 3926 3928 if (pStateFilePath->isEmpty()) … … 3984 3986 /* No saved state data. */ 3985 3987 rc = VERR_NOT_SUPPORTED; 3986 break;3987 3988 } 3989 3990 break; 3988 3991 } 3989 3992 else … … 4021 4024 *pu32Width = u32Width; 4022 4025 *pu32Height = u32Height; 4023 } 4024 4026 LogFlowFunc(("cbData %d, u32Width %d, u32Height %d\n", cbData, u32Width, u32Height)); 4027 } 4028 4029 LogFlowFunc(("rc %Rrc\n", rc)); 4025 4030 return rc; 4026 4031 } … … 4056 4061 tr("Saved screenshot data is not available (%Rrc)"), vrc); 4057 4062 4063 *aSize = cbData; 4064 *aWidth = u32Width; 4065 *aHeight = u32Height; 4066 4058 4067 freeSavedDisplayScreenshot(pu8Data); 4059 4068 … … 4061 4070 } 4062 4071 4063 STDMETHODIMP Machine::ReadSavedThumbnail (BYTE *aAddress, ULONG aSize)4072 STDMETHODIMP Machine::ReadSavedThumbnailToArray(BOOL aBGR, ULONG *aWidth, ULONG *aHeight, ComSafeArrayOut(BYTE, aData)) 4064 4073 { 4065 4074 LogFlowThisFunc(("\n")); 4066 4075 4067 CheckComArgNotNull(aAddress); 4076 CheckComArgNotNull(aWidth); 4077 CheckComArgNotNull(aHeight); 4078 CheckComArgExpr(aData, !ComSafeArrayOutIsNull(aData)); 4068 4079 4069 4080 AutoCaller autoCaller(this); … … 4082 4093 return setError (VBOX_E_IPRT_ERROR, 4083 4094 tr("Saved screenshot data is not available (%Rrc)"), vrc); 4084 if (aSize != cbData) 4085 return setError (E_INVALIDARG, 4086 tr("Invalid size of data buffer: %d"), aSize); 4087 4088 memcpy(aAddress, pu8Data, cbData); 4095 4096 *aWidth = u32Width; 4097 *aHeight = u32Height; 4098 4099 com::SafeArray<BYTE> bitmap(cbData); 4100 /* Convert pixels to format expected by the API caller. */ 4101 if (aBGR) 4102 { 4103 /* [0] B, [1] G, [2] R, [3] A. */ 4104 for (unsigned i = 0; i < cbData; i += 4) 4105 { 4106 bitmap[i] = pu8Data[i]; 4107 bitmap[i + 1] = pu8Data[i + 1]; 4108 bitmap[i + 2] = pu8Data[i + 2]; 4109 bitmap[i + 3] = 0xff; 4110 } 4111 } 4112 else 4113 { 4114 /* [0] R, [1] G, [2] B, [3] A. */ 4115 for (unsigned i = 0; i < cbData; i += 4) 4116 { 4117 bitmap[i] = pu8Data[i + 2]; 4118 bitmap[i + 1] = pu8Data[i + 1]; 4119 bitmap[i + 2] = pu8Data[i]; 4120 bitmap[i + 3] = 0xff; 4121 } 4122 } 4123 bitmap.detachTo(ComSafeArrayOutArg(aData)); 4089 4124 4090 4125 freeSavedDisplayScreenshot(pu8Data); … … 4093 4128 } 4094 4129 4095 STDMETHODIMP Machine:: ReadSavedThumbnailToArray(ULONG *aWidth, ULONG *aHeight, ComSafeArrayOut(BYTE, aData))4130 STDMETHODIMP Machine::QuerySavedScreenshotPNGSize(ULONG *aSize, ULONG *aWidth, ULONG *aHeight) 4096 4131 { 4097 4132 LogFlowThisFunc(("\n")); 4098 4133 4134 CheckComArgNotNull(aSize); 4099 4135 CheckComArgNotNull(aWidth); 4100 4136 CheckComArgNotNull(aHeight); 4101 CheckComArgSafeArrayNotNull(aData);4102 4137 4103 4138 AutoCaller autoCaller(this); … … 4111 4146 uint32_t u32Height = 0; 4112 4147 4113 int vrc = readSavedDisplayScreenshot(&mSSData->mStateFilePath, 0/* u32Type */, &pu8Data, &cbData, &u32Width, &u32Height);4148 int vrc = readSavedDisplayScreenshot(&mSSData->mStateFilePath, 1 /* u32Type */, &pu8Data, &cbData, &u32Width, &u32Height); 4114 4149 4115 4150 if (RT_FAILURE(vrc)) … … 4117 4152 tr("Saved screenshot data is not available (%Rrc)"), vrc); 4118 4153 4154 *aSize = cbData; 4119 4155 *aWidth = u32Width; 4120 4156 *aHeight = u32Height; 4121 4157 4122 com::SafeArray<BYTE> bitmap(cbData);4123 /* Convert pixels to format expected by the API caller: [0] R, [1] G, [2] B, [3] A. */4124 for (unsigned i = 0; i < cbData; i += 4)4125 {4126 bitmap[i] = pu8Data[i + 2];4127 bitmap[i + 1] = pu8Data[i + 1];4128 bitmap[i + 2] = pu8Data[i];4129 bitmap[i + 3] = 0xff;4130 }4131 bitmap.detachTo(ComSafeArrayOutArg(aData));4132 4133 4158 freeSavedDisplayScreenshot(pu8Data); 4134 4159 … … 4136 4161 } 4137 4162 4138 STDMETHODIMP Machine:: QuerySavedScreenshotPNGSize(ULONG *aSize, ULONG *aWidth, ULONG *aHeight)4163 STDMETHODIMP Machine::ReadSavedScreenshotPNGToArray(ULONG *aWidth, ULONG *aHeight, ComSafeArrayOut(BYTE, aData)) 4139 4164 { 4140 4165 LogFlowThisFunc(("\n")); 4141 4166 4142 CheckComArgNotNull(aSize);4143 4167 CheckComArgNotNull(aWidth); 4144 4168 CheckComArgNotNull(aHeight); 4145 4146 AutoCaller autoCaller(this); 4147 CheckComRCReturnRC(autoCaller.rc()); 4148 4149 AutoReadLock alock(this); 4150 4151 uint8_t *pu8Data = NULL; 4152 uint32_t cbData = 0; 4153 uint32_t u32Width = 0; 4154 uint32_t u32Height = 0; 4155 4156 int vrc = readSavedDisplayScreenshot(&mSSData->mStateFilePath, 1 /* u32Type */, &pu8Data, &cbData, &u32Width, &u32Height); 4157 4158 if (RT_FAILURE(vrc)) 4159 return setError (VBOX_E_IPRT_ERROR, 4160 tr("Saved screenshot data is not available (%Rrc)"), vrc); 4161 4162 freeSavedDisplayScreenshot(pu8Data); 4163 4164 return S_OK; 4165 } 4166 4167 STDMETHODIMP Machine::ReadSavedScreenshotPNG(BYTE *aAddress, ULONG aSize) 4168 { 4169 LogFlowThisFunc(("\n")); 4170 4171 CheckComArgNotNull(aAddress); 4172 4173 AutoCaller autoCaller(this); 4174 CheckComRCReturnRC(autoCaller.rc()); 4175 4176 AutoReadLock alock(this); 4177 4178 uint8_t *pu8Data = NULL; 4179 uint32_t cbData = 0; 4180 uint32_t u32Width = 0; 4181 uint32_t u32Height = 0; 4182 4183 int vrc = readSavedDisplayScreenshot(&mSSData->mStateFilePath, 1 /* u32Type */, &pu8Data, &cbData, &u32Width, &u32Height); 4184 4185 if (RT_FAILURE(vrc)) 4186 return setError (VBOX_E_IPRT_ERROR, 4187 tr("Saved screenshot data is not available (%Rrc)"), vrc); 4188 if (aSize != cbData) 4189 return setError (E_INVALIDARG, 4190 tr("Invalid size of data buffer: %d"), aSize); 4191 4192 memcpy(aAddress, pu8Data, cbData); 4193 4194 freeSavedDisplayScreenshot(pu8Data); 4195 4196 return S_OK; 4197 } 4198 4199 STDMETHODIMP Machine::ReadSavedScreenshotPNGToArray(ULONG *aWidth, ULONG *aHeight, ComSafeArrayOut(BYTE, aData)) 4200 { 4201 LogFlowThisFunc(("\n")); 4202 4203 CheckComArgNotNull(aWidth); 4204 CheckComArgNotNull(aHeight); 4205 CheckComArgSafeArrayNotNull(aData); 4169 CheckComArgExpr(aData, !ComSafeArrayOutIsNull(aData)); 4206 4170 4207 4171 AutoCaller autoCaller(this); -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r24526 r24539 4105 4105 <interface 4106 4106 name="IMachine" extends="$unknown" 4107 uuid=" c5669e1a-491a-4367-99c6-28110dd474c6"4107 uuid="99404f50-dd10-40d3-889b-dd2f79f1e95e" 4108 4108 wsmap="managed" 4109 4109 > … … 5796 5796 </method> 5797 5797 5798 <method name="readSavedThumbnail">5799 <desc>5800 Reads a saved thumbnail bitmap from saved state.5801 A pixel consists of 4 bytes in order: B, G, R, 0.5802 5803 <note>This API can be used only by the COM/XPCOM C++ API as it5804 requires pointer support. Use <link to="#readSavedThumbnailToArray" />5805 with other language bindings.5806 </note>5807 </desc>5808 <param name="address" type="octet" mod="ptr" dir="in">5809 <desc>5810 Buffer allocated by caller. Size must be at least equal5811 to value returned by querySavedThumbnailSize.5812 </desc>5813 </param>5814 <param name="size" type="unsigned long" dir="in">5815 <desc>5816 Size of buffer allocated by caller. If the buffer is too small,5817 the method fails.5818 </desc>5819 </param>5820 </method>5821 5822 5798 <method name="readSavedThumbnailToArray"> 5823 5799 <desc> 5824 Thumbnail is retrieved to an array of bytes in uncompressed 32-bit RGBA format. 5825 A pixel consists of 4 bytes in order: R, G, B, 0xFF. 5826 5827 This API is slow, but could be the only option to get image 5828 for scriptable languages not allowed to manipulate with addresses 5829 directly. 5830 </desc> 5800 Thumbnail is retrieved to an array of bytes in uncompressed 32-bit BGRA or RGBA format. 5801 </desc> 5802 <param name="BGR" type="boolean" dir="in"> 5803 <desc> 5804 How to order bytes in the pixel. A pixel consists of 4 bytes. If this parameter is true, then 5805 bytes order is: B, G, R, 0xFF. If this parameter is false, then bytes order is: R, G, B, 0xFF. 5806 </desc> 5807 </param> 5831 5808 <param name="width" type="unsigned long" dir="out"> 5832 5809 <desc> … … 5867 5844 </method> 5868 5845 5869 <method name="readSavedScreenshotPNG">5870 <desc>5871 Reads a saved screenshot in PNG format from saved state.5872 5873 <note>This API can be used only by the COM/XPCOM C++ API as it5874 requires pointer support. Use <link to="#readSavedScreenshotPNGToArray" />5875 with other language bindings.5876 </note>5877 </desc>5878 <param name="address" type="octet" mod="ptr" dir="in">5879 <desc>5880 Buffer allocated by caller. Size must be at least equal5881 to value returned by querySavedScreenshotPNGSize.5882 </desc>5883 </param>5884 <param name="size" type="unsigned long" dir="in">5885 <desc>5886 Size of buffer allocated by caller. If the buffer is too small,5887 the method fails.5888 </desc>5889 </param>5890 </method>5891 5892 5846 <method name="readSavedScreenshotPNGToArray"> 5893 5847 <desc> 5894 5848 Screenshot in PNG format is retrieved to an array of bytes. 5895 5896 This API is slow, but could be the only option to get image5897 for scriptable languages not allowed to manipulate with addresses5898 directly.5899 5849 </desc> 5900 5850 <param name="width" type="unsigned long" dir="out"> -
trunk/src/VBox/Main/include/MachineImpl.h
r24493 r24539 630 630 631 631 STDMETHOD(QuerySavedThumbnailSize)(ULONG *aSize, ULONG *aWidth, ULONG *aHeight); 632 STDMETHOD(ReadSavedThumbnail)(BYTE *aAddress, ULONG aSize); 633 STDMETHOD(ReadSavedThumbnailToArray)(ULONG *aWidth, ULONG *aHeight, ComSafeArrayOut(BYTE, aData)); 632 STDMETHOD(ReadSavedThumbnailToArray)(BOOL aBGR, ULONG *aWidth, ULONG *aHeight, ComSafeArrayOut(BYTE, aData)); 634 633 STDMETHOD(QuerySavedScreenshotPNGSize)(ULONG *aSize, ULONG *aWidth, ULONG *aHeight); 635 STDMETHOD(ReadSavedScreenshotPNG)(BYTE *aAddress, ULONG aSize);636 634 STDMETHOD(ReadSavedScreenshotPNGToArray)(ULONG *aWidth, ULONG *aHeight, ComSafeArrayOut(BYTE, aData)); 637 635
Note:
See TracChangeset
for help on using the changeset viewer.