MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / OnSaveAsPcx

Method OnSaveAsPcx

editor/TerrainDialog.cpp:1614–1677  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1612}
1613
1614void CTerrainDialog::OnSaveAsPcx() {
1615
1616 char filename[255];
1617
1618 CString filter = "PCX files (*.pcx)|*.pcx||";
1619
1620 if (!SaveFileDialog(this, (LPCSTR)filter, filename, Current_bitmap_dir, sizeof(Current_bitmap_dir)))
1621 return;
1622
1623 CFILE *outfile;
1624
1625 outfile = (CFILE *)cfopen(filename, "wb");
1626 if (!outfile) {
1627 OutrageMessageBox("Couldn't open that filename to save to!");
1628 return;
1629 }
1630
1631 // Header info
1632 cf_WriteByte(outfile, 10);
1633 cf_WriteByte(outfile, 5);
1634 cf_WriteByte(outfile, 1);
1635 cf_WriteByte(outfile, 8);
1636
1637 // Dimensions of image
1638 cf_WriteShort(outfile, 0);
1639 cf_WriteShort(outfile, 0);
1640 cf_WriteShort(outfile, 255);
1641 cf_WriteShort(outfile, 255);
1642
1643 // Display adapter dimensions (bash to 256)
1644 cf_WriteShort(outfile, 256);
1645 cf_WriteShort(outfile, 256);
1646
1647 for (int i = 0; i < 48; i++)
1648 cf_WriteByte(outfile, 0);
1649
1650 cf_WriteByte(outfile, 0);
1651 cf_WriteByte(outfile, 1);
1652 cf_WriteShort(outfile, 256);
1653 cf_WriteShort(outfile, 2);
1654
1655 for (i = 0; i < 58; i++)
1656 cf_WriteByte(outfile, 0);
1657
1658 for (i = 0; i < TERRAIN_DEPTH; i++) {
1659 for (int t = 0; t < TERRAIN_WIDTH; t++) {
1660 uint8_t val = Terrain_seg[(((TERRAIN_DEPTH - 1) - i) * TERRAIN_WIDTH) + t].ypos;
1661 uint8_t runlen = 0xc1;
1662
1663 cf_WriteByte(outfile, runlen);
1664 cf_WriteByte(outfile, val);
1665 }
1666 }
1667
1668 cf_WriteByte(outfile, 12);
1669 for (i = 0; i < 256; i++) {
1670 cf_WriteByte(outfile, i);
1671 cf_WriteByte(outfile, i);

Callers

nothing calls this directly

Calls 6

SaveFileDialogFunction · 0.85
cfopenFunction · 0.85
OutrageMessageBoxFunction · 0.85
cf_WriteByteFunction · 0.85
cf_WriteShortFunction · 0.85
cfcloseFunction · 0.85

Tested by

no test coverage detected