MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / GetPalette

Method GetPalette

Source/Amiga/Graphics_Amiga2.cpp:91–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89}
90
91tSharedBuffer cGraphics_Amiga2::GetPalette(const std::string pFilename) {
92 tSharedBuffer PaletteFinal = std::make_shared<std::vector<uint8>>();
93 std::string Filename = pFilename;
94
95 if (Filename.find('.') == std::string::npos)
96 Filename.append(".PAL");
97
98 auto Palette = g_Resource->fileGet(Filename);
99
100 auto a0 = Palette->data();
101 for (; a0 < Palette->data() + Palette->size(); ++a0) {
102
103 uint16 d0 = *a0++;
104 uint16 d1 = *a0++;
105
106 d0 &= 0xF0;
107 d0 <<= 4;
108
109 d1 &= 0xF0;
110 d0 |= d1;
111
112 d1 = *a0;
113 d1 &= 0xF0;
114 d1 >>= 4;
115 d0 |= d1;
116
117 // push as little endian
118 PaletteFinal->push_back(d0 >> 8);
119 PaletteFinal->push_back(d0 & 0xFFFF);
120 }
121
122 return PaletteFinal;
123}
124
125sImage cGraphics_Amiga2::GetImage(const std::string& pFilename, const size_t pPaletteIndex) {
126 auto Palette = GetPalette(pFilename);

Callers

nothing calls this directly

Calls 4

findMethod · 0.80
fileGetMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected