MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / savePal

Method savePal

src/Engine/Palette.cpp:105–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103}
104
105void Palette::savePal(const std::string &file) const
106{
107 std::ofstream out(file.c_str(), std::ios::out | std::ios::binary);
108 short count = _count;
109
110 // RIFF header
111 out << "RIFF";
112 int length = 4 + 4 + 4 + 4 + 2 + 2 + count * 4;
113 out.write((char*) &length, sizeof(length));
114 out << "PAL ";
115
116 // Data chunk
117 out << "data";
118 int data = count * 4 + 4;
119 out.write((char*) &data, sizeof(data));
120 short version = 0x0300;
121 out.write((char*) &version, sizeof(version));
122 out.write((char*) &count, sizeof(count));
123
124 // Colors
125 SDL_Color *color = getColors();
126 for (short i = 0; i < count; ++i)
127 {
128 char c = 0;
129 out.write((char*) &color->r, 1);
130 out.write((char*) &color->g, 1);
131 out.write((char*) &color->b, 1);
132 out.write(&c, 1);
133 color++;
134 }
135 out.close();
136}
137
138}

Callers

nothing calls this directly

Calls 1

closeMethod · 0.45

Tested by

no test coverage detected