- Timestamp:
- May 25, 2022 2:16:27 PM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 151580
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA-cmd.cpp
r95085 r95101 1466 1466 static int vmsvga3dBmpWrite(const char *pszFilename, VMSVGA3D_MAPPED_SURFACE const *pMap) 1467 1467 { 1468 if (pMap->cbBlock != 4 && pMap->cbBlock != 1 && pMap->format != SVGA3D_R16G16B16A16_FLOAT) 1468 if ( pMap->cbBlock != 4 && pMap->cbBlock != 1 1469 && pMap->format != SVGA3D_R16G16B16A16_FLOAT 1470 && pMap->format != SVGA3D_R32G32B32A32_FLOAT) 1469 1471 return VERR_NOT_SUPPORTED; 1470 1472 … … 1498 1500 } 1499 1501 1500 if (pMap->cbBlock == 4) 1501 { 1502 const uint8_t *s = (uint8_t *)pMap->pvData; 1503 for (uint32_t iRow = 0; iRow < pMap->cRows; ++iRow) 1504 { 1505 fwrite(s, 1, pMap->cbRow, f); 1506 1507 s += pMap->cbRowPitch; 1508 } 1509 } 1510 else if (pMap->cbBlock == 1) 1511 { 1512 const uint8_t *s = (uint8_t *)pMap->pvData; 1513 for (uint32_t iRow = 0; iRow < pMap->cRows; ++iRow) 1514 { 1515 for (int32_t x = 0; x < w; ++x) 1516 { 1517 uint32_t u32Pixel = s[x]; 1518 fwrite(&u32Pixel, 1, 4, f); 1519 } 1520 1521 s += pMap->cbRowPitch; 1522 } 1523 } 1524 else if (pMap->format == SVGA3D_R16G16B16A16_FLOAT) 1502 if (pMap->format == SVGA3D_R16G16B16A16_FLOAT) 1525 1503 { 1526 1504 const uint8_t *s = (uint8_t *)pMap->pvData; … … 1541 1519 } 1542 1520 } 1521 else if (pMap->format == SVGA3D_R32G32B32A32_FLOAT) 1522 { 1523 const uint8_t *s = (uint8_t *)pMap->pvData; 1524 for (int32_t y = 0; y < h; ++y) 1525 { 1526 for (int32_t x = 0; x < w; ++x) 1527 { 1528 float const *pPixel = (float *)(s + x * 8); 1529 uint8_t r = (uint8_t)(255.0 * pPixel[0]); 1530 uint8_t g = (uint8_t)(255.0 * pPixel[1]); 1531 uint8_t b = (uint8_t)(255.0 * pPixel[2]); 1532 uint8_t a = (uint8_t)(255.0 * pPixel[3]); 1533 uint32_t u32Pixel = b + (g << 8) + (r << 16) + (a << 24); 1534 fwrite(&u32Pixel, 1, 4, f); 1535 } 1536 1537 s += pMap->cbRowPitch; 1538 } 1539 } 1540 else if (pMap->cbBlock == 4) 1541 { 1542 const uint8_t *s = (uint8_t *)pMap->pvData; 1543 for (uint32_t iRow = 0; iRow < pMap->cRows; ++iRow) 1544 { 1545 fwrite(s, 1, pMap->cbRow, f); 1546 1547 s += pMap->cbRowPitch; 1548 } 1549 } 1550 else if (pMap->cbBlock == 1) 1551 { 1552 const uint8_t *s = (uint8_t *)pMap->pvData; 1553 for (uint32_t iRow = 0; iRow < pMap->cRows; ++iRow) 1554 { 1555 for (int32_t x = 0; x < w; ++x) 1556 { 1557 uint32_t u32Pixel = s[x]; 1558 fwrite(&u32Pixel, 1, 4, f); 1559 } 1560 1561 s += pMap->cbRowPitch; 1562 } 1563 } 1543 1564 1544 1565 fclose(f); … … 1553 1574 char *pszFilename = RTStrAPrintf2("bmp\\%s%d.bmp", pszPrefix, idxBitmap++); 1554 1575 int rc = vmsvga3dBmpWrite(pszFilename, pMap); 1555 Log(("WriteBmpFile %s %Rrc\n", pszFilename, rc)); RT_NOREF(rc);1576 Log(("WriteBmpFile %s format %d %Rrc\n", pszFilename, pMap->format, rc)); RT_NOREF(rc); 1556 1577 RTStrFree(pszFilename); 1557 1578 }
Note:
See TracChangeset
for help on using the changeset viewer.