MCPcopy Create free account
hub / github.com/DentonW/DevIL / Decompress3Dc

Function Decompress3Dc

DevIL/src-IL/src/il_dds.cpp:1239–1327  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1237
1238
1239ILboolean Decompress3Dc()
1240{
1241 int x, y, z, i, j, k, t1, t2;
1242 ILubyte *Temp, *Temp2;
1243 ILubyte XColours[8], YColours[8];
1244 ILuint bitmask, bitmask2, Offset, CurrOffset;
1245
1246 if (!CompData)
1247 return IL_FALSE;
1248
1249 Temp = CompData;
1250 Offset = 0;
1251 for (z = 0; z < Depth; z++) {
1252 for (y = 0; y < Height; y += 4) {
1253 for (x = 0; x < Width; x += 4) {
1254 Temp2 = Temp + 8;
1255
1256 //Read Y palette
1257 t1 = YColours[0] = Temp[0];
1258 t2 = YColours[1] = Temp[1];
1259 Temp += 2;
1260 if (t1 > t2)
1261 for (i = 2; i < 8; ++i)
1262 YColours[i] = t1 + ((t2 - t1)*(i - 1))/7;
1263 else {
1264 for (i = 2; i < 6; ++i)
1265 YColours[i] = t1 + ((t2 - t1)*(i - 1))/5;
1266 YColours[6] = 0;
1267 YColours[7] = 255;
1268 }
1269
1270 // Read X palette
1271 t1 = XColours[0] = Temp2[0];
1272 t2 = XColours[1] = Temp2[1];
1273 Temp2 += 2;
1274 if (t1 > t2)
1275 for (i = 2; i < 8; ++i)
1276 XColours[i] = t1 + ((t2 - t1)*(i - 1))/7;
1277 else {
1278 for (i = 2; i < 6; ++i)
1279 XColours[i] = t1 + ((t2 - t1)*(i - 1))/5;
1280 XColours[6] = 0;
1281 XColours[7] = 255;
1282 }
1283
1284 //decompress pixel data
1285 CurrOffset = Offset;
1286 for (k = 0; k < 4; k += 2) {
1287 // First three bytes
1288 bitmask = ((ILuint)(Temp[0]) << 0) | ((ILuint)(Temp[1]) << 8) | ((ILuint)(Temp[2]) << 16);
1289 bitmask2 = ((ILuint)(Temp2[0]) << 0) | ((ILuint)(Temp2[1]) << 8) | ((ILuint)(Temp2[2]) << 16);
1290 for (j = 0; j < 2; j++) {
1291 // only put pixels out < height
1292 if ((y + k + j) < Height) {
1293 for (i = 0; i < 4; i++) {
1294 // only put pixels out < width
1295 if (((x + i) < Width)) {
1296 ILint t, tx, ty;

Callers 1

DdsDecompressFunction · 0.85

Calls 1

iSqrtFunction · 0.85

Tested by

no test coverage detected