Changeset 85856 in vbox
- Timestamp:
- Aug 21, 2020 9:06:50 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/GuestHost/clipboard-helper.h
r85845 r85856 165 165 int ShClConvLatin1LFToUtf16CRLF(const char *pcszSrc, size_t cbSrc, PRTUTF16 *ppwszDst, size_t *pcwDst); 166 166 167 #pragma pack(1)168 /** @todo r=bird: Why duplicate these structures here, we've got them in169 * DevVGA.cpp already! */170 /**171 * Bitmap File Header. Official win32 name is BITMAPFILEHEADER172 * Always Little Endian.173 */174 typedef struct BMFILEHEADER175 {176 uint16_t uType;177 uint32_t uSize;178 uint16_t uReserved1;179 uint16_t uReserved2;180 uint32_t uOffBits;181 } BMFILEHEADER;182 #pragma pack()183 184 /** Pointer to a BMFILEHEADER structure. */185 typedef BMFILEHEADER *PBMFILEHEADER;186 /** BMP file magic number */187 #define BITMAPHEADERMAGIC (RT_H2LE_U16_C(0x4d42))188 189 /**190 * Bitmap Info Header. Official win32 name is BITMAPINFOHEADER191 * Always Little Endian.192 */193 typedef struct BMINFOHEADER194 {195 uint32_t uSize;196 uint32_t uWidth;197 uint32_t uHeight;198 uint16_t uPlanes;199 uint16_t uBitCount;200 uint32_t uCompression;201 uint32_t uSizeImage;202 uint32_t uXBitsPerMeter;203 uint32_t uYBitsPerMeter;204 uint32_t uClrUsed;205 uint32_t uClrImportant;206 } BMINFOHEADER;207 /** Pointer to a BMINFOHEADER structure. */208 typedef BMINFOHEADER *PBMINFOHEADER;209 210 167 /** 211 168 * Convert CF_DIB data to full BMP data by prepending the BM header. -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-info.cpp
r85121 r85856 29 29 #include <iprt/mem.h> 30 30 #include <iprt/path.h> 31 #ifdef RT_OS_WINDOWS 32 # include <iprt/formats/bmp.h> 33 #endif 31 34 32 35 #include <VBox/vmm/pgm.h> /* required by DevVGA.h */ … … 1799 1802 #endif /* VMSVGA3D_DIRECT3D */ 1800 1803 1801 #ifndef RT_OS_WINDOWS1802 typedef uint16_t WORD;1803 typedef uint32_t DWORD;1804 typedef int32_t LONG;1805 1806 #pragma pack(2)1807 typedef struct1808 {1809 WORD bfType;1810 DWORD bfSize;1811 WORD bfReserved1;1812 WORD bfReserved2;1813 DWORD bfOffBits;1814 } BITMAPFILEHEADER, *PBITMAPFILEHEADER, *LPBITMAPFILEHEADER;1815 1816 typedef struct1817 {1818 DWORD biSize;1819 LONG biWidth;1820 LONG biHeight;1821 WORD biPlanes;1822 WORD biBitCount;1823 DWORD biCompression;1824 DWORD biSizeImage;1825 LONG biXPelsPerMeter;1826 LONG biYPelsPerMeter;1827 DWORD biClrUsed;1828 DWORD biClrImportant;1829 } BITMAPINFOHEADER, *PBITMAPINFOHEADER, *LPBITMAPINFOHEADER;1830 #pragma pack()1831 #endif1832 1833 1804 static int vmsvga3dInfoBmpWrite(const char *pszFilename, const void *pvBits, int w, int h, uint32_t cbPixel, uint32_t u32Mask) 1834 1805 { … … 1871 1842 // bh.bV4GammaBlue = 0; 1872 1843 1873 BITMAPFILEHEADER bf; 1874 bf.bfType = 'MB'; 1875 bf.bfSize = sizeof(bf) + sizeof(bh) + cbBitmap; 1876 bf.bfReserved1 = 0; 1877 bf.bfReserved2 = 0; 1878 bf.bfOffBits = sizeof(bf) + sizeof(bh); 1844 BMPINFO bf; 1845 RT_ZERO(bf); 1846 bf.Type = BMP_HDR_MAGIC; 1847 bf.FileSize = sizeof(bf) + sizeof(bh) + cbBitmap; 1848 bf.Offset = sizeof(bf) + sizeof(bh); 1879 1849 1880 1850 fwrite(&bf, 1, sizeof(bf), f); … … 1884 1854 #endif 1885 1855 { 1886 BITMAPFILEHEADER bf; 1887 bf.bfType = 0x4D42; //'MB' 1888 bf.bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + cbBitmap; 1889 bf.bfReserved1 = 0; 1890 bf.bfReserved2 = 0; 1891 bf.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER); 1892 1893 BITMAPINFOHEADER bi; 1894 bi.biSize = sizeof(bi); 1895 bi.biWidth = w; 1896 bi.biHeight = -h; 1897 bi.biPlanes = 1; 1898 bi.biBitCount = 32; 1899 bi.biCompression = 0; 1900 bi.biSizeImage = cbBitmap; 1901 bi.biXPelsPerMeter = 0; 1902 bi.biYPelsPerMeter = 0; 1903 bi.biClrUsed = 0; 1904 bi.biClrImportant = 0; 1856 BMPINFO bf; 1857 RT_ZERO(bf); 1858 bf.Type = BMP_HDR_MAGIC; 1859 bf.FileSize = sizeof(BMPINFO) + sizeof(WINHDR) + cbBitmap; 1860 bf.Offset = sizeof(BMPINFO) + sizeof(WINHDR); 1861 1862 WINHDR bi; 1863 RT_ZERO(bi); 1864 bi.Size = sizeof(bi); 1865 bi.Width = w; 1866 bi.Height = -h; 1867 bi.Planes = 1; 1868 bi.BitCount = 32; 1869 bi.SizeImage = cbBitmap; 1905 1870 1906 1871 fwrite(&bf, 1, sizeof(bf), f); -
trunk/src/VBox/Devices/Graphics/DevVGA.cpp
r85368 r85856 83 83 #include <iprt/uuid.h> 84 84 85 #include <iprt/formats/bmp.h> 86 85 87 #include <VBox/VMMDev.h> 86 88 #include <VBoxVideo.h> … … 106 108 * Structures and Typedefs * 107 109 *********************************************************************************************************************************/ 108 #pragma pack(1)109 110 /** BMP File Format Bitmap Header. */111 typedef struct112 {113 uint16_t Type; /* File Type Identifier */114 uint32_t FileSize; /* Size of File */115 uint16_t Reserved1; /* Reserved (should be 0) */116 uint16_t Reserved2; /* Reserved (should be 0) */117 uint32_t Offset; /* Offset to bitmap data */118 } BMPINFO;119 120 /** Pointer to a bitmap header*/121 typedef BMPINFO *PBMPINFO;122 123 /** OS/2 1.x Information Header Format. */124 typedef struct125 {126 uint32_t Size; /* Size of Remaining Header */127 uint16_t Width; /* Width of Bitmap in Pixels */128 uint16_t Height; /* Height of Bitmap in Pixels */129 uint16_t Planes; /* Number of Planes */130 uint16_t BitCount; /* Color Bits Per Pixel */131 } OS2HDR;132 133 /** Pointer to a OS/2 1.x header format */134 typedef OS2HDR *POS2HDR;135 136 /** OS/2 2.0 Information Header Format. */137 typedef struct138 {139 uint32_t Size; /* Size of Remaining Header */140 uint32_t Width; /* Width of Bitmap in Pixels */141 uint32_t Height; /* Height of Bitmap in Pixels */142 uint16_t Planes; /* Number of Planes */143 uint16_t BitCount; /* Color Bits Per Pixel */144 uint32_t Compression; /* Compression Scheme (0=none) */145 uint32_t SizeImage; /* Size of bitmap in bytes */146 uint32_t XPelsPerMeter; /* Horz. Resolution in Pixels/Meter */147 uint32_t YPelsPerMeter; /* Vert. Resolution in Pixels/Meter */148 uint32_t ClrUsed; /* Number of Colors in Color Table */149 uint32_t ClrImportant; /* Number of Important Colors */150 uint16_t Units; /* Resolution Measurement Used */151 uint16_t Reserved; /* Reserved FIelds (always 0) */152 uint16_t Recording; /* Orientation of Bitmap */153 uint16_t Rendering; /* Halftone Algorithm Used on Image */154 uint32_t Size1; /* Halftone Algorithm Data */155 uint32_t Size2; /* Halftone Algorithm Data */156 uint32_t ColorEncoding; /* Color Table Format (always 0) */157 uint32_t Identifier; /* Misc. Field for Application Use */158 } OS22HDR;159 160 /** Pointer to a OS/2 2.0 header format */161 typedef OS22HDR *POS22HDR;162 163 /** Windows 3.x Information Header Format. */164 typedef struct165 {166 uint32_t Size; /* Size of Remaining Header */167 uint32_t Width; /* Width of Bitmap in Pixels */168 uint32_t Height; /* Height of Bitmap in Pixels */169 uint16_t Planes; /* Number of Planes */170 uint16_t BitCount; /* Bits Per Pixel */171 uint32_t Compression; /* Compression Scheme (0=none) */172 uint32_t SizeImage; /* Size of bitmap in bytes */173 uint32_t XPelsPerMeter; /* Horz. Resolution in Pixels/Meter */174 uint32_t YPelsPerMeter; /* Vert. Resolution in Pixels/Meter */175 uint32_t ClrUsed; /* Number of Colors in Color Table */176 uint32_t ClrImportant; /* Number of Important Colors */177 } WINHDR;178 179 /** Pointer to a Windows 3.x header format */180 typedef WINHDR *PWINHDR;181 182 #pragma pack()183 184 #define BMP_ID 0x4D42185 186 /** @name BMP compressions.187 * @{ */188 #define BMP_COMPRESS_NONE 0189 #define BMP_COMPRESS_RLE8 1190 #define BMP_COMPRESS_RLE4 2191 /** @} */192 193 /** @name BMP header sizes.194 * @{ */195 #define BMP_HEADER_OS21 12196 #define BMP_HEADER_OS22 64197 #define BMP_HEADER_WIN3 40198 /** @} */199 110 200 111 /** The BIOS boot menu text position, X. */ … … 3963 3874 PWINHDR pWinHdr = (PWINHDR)(pThisCC->pbLogo + sizeof(LOGOHDR) + sizeof(BMPINFO)); 3964 3875 3965 if (pBmpInfo->Type == BMP_ ID)3876 if (pBmpInfo->Type == BMP_HDR_MAGIC) 3966 3877 { 3967 3878 switch (pWinHdr->Size) -
trunk/src/VBox/GuestHost/SharedClipboard/clipboard-common.cpp
r85845 r85856 26 26 #include <iprt/rand.h> 27 27 #include <iprt/utf16.h> 28 29 #include <iprt/formats/bmp.h> 28 30 29 31 #include <iprt/errcore.h> … … 899 901 AssertPtrReturn(pcbDest, VERR_INVALID_POINTER); 900 902 901 P BMINFOHEADER pBitmapInfoHeader = (PBMINFOHEADER)pvSrc;903 PWINHDR pBmpWinHdr = (PWINHDR)pvSrc; 902 904 /** @todo Support all the many versions of the DIB headers. */ 903 if ( cbSrc < sizeof( BMINFOHEADER)904 || RT_LE2H_U32(pB itmapInfoHeader->uSize) < sizeof(BMINFOHEADER)905 || RT_LE2H_U32(pB itmapInfoHeader->uSize) != sizeof(BMINFOHEADER))905 if ( cbSrc < sizeof(WINHDR) 906 || RT_LE2H_U32(pBmpWinHdr->Size) < sizeof(WINHDR) 907 || RT_LE2H_U32(pBmpWinHdr->Size) != sizeof(WINHDR)) 906 908 { 907 909 return VERR_INVALID_PARAMETER; 908 910 } 909 911 910 size_t offPixel = sizeof(BM FILEHEADER)911 + RT_LE2H_U32(pB itmapInfoHeader->uSize)912 + RT_LE2H_U32(pB itmapInfoHeader->uClrUsed) * sizeof(uint32_t);912 size_t offPixel = sizeof(BMPINFO) 913 + RT_LE2H_U32(pBmpWinHdr->Size) 914 + RT_LE2H_U32(pBmpWinHdr->ClrUsed) * sizeof(uint32_t); 913 915 if (cbSrc < offPixel) 914 916 return VERR_INVALID_PARAMETER; 915 917 916 size_t cbDst = sizeof(BM FILEHEADER) + cbSrc;918 size_t cbDst = sizeof(BMPINFO) + cbSrc; 917 919 918 920 void *pvDest = RTMemAlloc(cbDst); … … 920 922 return VERR_NO_MEMORY; 921 923 922 PBM FILEHEADER pFileHeader = (PBMFILEHEADER)pvDest;923 924 p FileHeader->uType = BITMAPHEADERMAGIC;925 p FileHeader->uSize= (uint32_t)RT_H2LE_U32(cbDst);926 p FileHeader->uReserved1 = pFileHeader->uReserved2 = 0;927 p FileHeader->uOffBits= (uint32_t)RT_H2LE_U32(offPixel);928 929 memcpy((uint8_t *)pvDest + sizeof(BM FILEHEADER), pvSrc, cbSrc);924 PBMPINFO pBmpHdr = (PBMPINFO)pvDest; 925 926 pBmpHdr->Type = BMP_HDR_MAGIC; 927 pBmpHdr->FileSize = (uint32_t)RT_H2LE_U32(cbDst); 928 pBmpHdr->Reserved1 = pBmpHdr->Reserved2 = 0; 929 pBmpHdr->Offset = (uint32_t)RT_H2LE_U32(offPixel); 930 931 memcpy((uint8_t *)pvDest + sizeof(BMPINFO), pvSrc, cbSrc); 930 932 931 933 *ppvDest = pvDest; … … 943 945 AssertPtrReturn(pcbDest, VERR_INVALID_POINTER); 944 946 945 PBM FILEHEADER pFileHeader = (PBMFILEHEADER)pvSrc;946 if ( cbSrc < sizeof(BM FILEHEADER)947 || p FileHeader->uType != BITMAPHEADERMAGIC948 || RT_LE2H_U32(p FileHeader->uSize) != cbSrc)947 PBMPINFO pBmpHdr = (PBMPINFO)pvSrc; 948 if ( cbSrc < sizeof(BMPINFO) 949 || pBmpHdr->Type != BMP_HDR_MAGIC 950 || RT_LE2H_U32(pBmpHdr->FileSize) != cbSrc) 949 951 { 950 952 return VERR_INVALID_PARAMETER; 951 953 } 952 954 953 *ppvDest = ((uint8_t *)pvSrc) + sizeof(BM FILEHEADER);954 *pcbDest = cbSrc - sizeof(BM FILEHEADER);955 *ppvDest = ((uint8_t *)pvSrc) + sizeof(BMPINFO); 956 *pcbDest = cbSrc - sizeof(BMPINFO); 955 957 956 958 return VINF_SUCCESS; -
trunk/src/VBox/Main/src-client/RecordingStream.cpp
r82968 r85856 24 24 #include <iprt/path.h> 25 25 26 #if VBOX_RECORDING_DUMP 27 # include <iprt/formats/bmp.h> 28 #endif 29 26 30 #include "Recording.h" 27 31 #include "RecordingUtils.h" 28 32 #include "WebMWriter.h" 29 33 30 #ifdef VBOX_RECORDING_DUMP31 #pragma pack(push)32 #pragma pack(1)33 typedef struct34 {35 uint16_t uMagic;36 uint32_t uSize;37 uint16_t uReserved1;38 uint16_t uReserved2;39 uint32_t uOffBits;40 } RECORDINGBMPHDR, *PRECORDINGBMPHDR;41 AssertCompileSize(RECORDINGBMPHDR, 14);42 43 typedef struct44 {45 uint32_t uSize;46 uint32_t uWidth;47 uint32_t uHeight;48 uint16_t uPlanes;49 uint16_t uBitCount;50 uint32_t uCompression;51 uint32_t uSizeImage;52 uint32_t uXPelsPerMeter;53 uint32_t uYPelsPerMeter;54 uint32_t uClrUsed;55 uint32_t uClrImportant;56 } RECORDINGBMPDIBHDR, *PRECORDINGBMPDIBHDR;57 AssertCompileSize(RECORDINGBMPDIBHDR, 40);58 59 #pragma pack(pop)60 #endif /* VBOX_RECORDING_DUMP */61 34 62 35 RecordingStream::RecordingStream(RecordingContext *a_pCtx) … … 664 637 665 638 #ifdef VBOX_RECORDING_DUMP 666 RECORDINGBMPHDRbmpHdr;639 BMPINFO bmpHdr; 667 640 RT_ZERO(bmpHdr); 668 641 669 RECORDINGBMPDIBHDR bmpDIBHdr;642 WINHDR bmpDIBHdr; 670 643 RT_ZERO(bmpDIBHdr); 671 644 672 bmpHdr. uMagic = 0x4d42; /* Magic */673 bmpHdr. uSize = (uint32_t)(sizeof(RECORDINGBMPHDR) + sizeof(RECORDINGBMPDIBHDR) + (w * h * uBytesPerPixel));674 bmpHdr. uOffBits = (uint32_t)(sizeof(RECORDINGBMPHDR) + sizeof(RECORDINGBMPDIBHDR));675 676 bmpDIBHdr. uSize = sizeof(RECORDINGBMPDIBHDR);677 bmpDIBHdr. uWidth = w;678 bmpDIBHdr. uHeight = h;679 bmpDIBHdr. uPlanes = 1;680 bmpDIBHdr. uBitCount = uBPP;681 bmpDIBHdr. uXPelsPerMeter = 5000;682 bmpDIBHdr. uYPelsPerMeter = 5000;645 bmpHdr.Type = BMP_HDR_MAGIC; 646 bmpHdr.FileSize = (uint32_t)(sizeof(BMPINFO) + sizeof(WINHDR) + (w * h * uBytesPerPixel)); 647 bmpHdr.Offset = (uint32_t)(sizeof(BMPINFO) + sizeof(WINHDR)); 648 649 bmpDIBHdr.Size = sizeof(WINHDR); 650 bmpDIBHdr.Width = w; 651 bmpDIBHdr.Height = h; 652 bmpDIBHdr.Planes = 1; 653 bmpDIBHdr.BitCount = uBPP; 654 bmpDIBHdr.XPelsPerMeter = 5000; 655 bmpDIBHdr.YPelsPerMeter = 5000; 683 656 684 657 char szFileName[RTPATH_MAX];
Note:
See TracChangeset
for help on using the changeset viewer.