| 392 | |
| 393 | |
| 394 | char *iff_decompress_tile_rle(ILushort width, ILushort height, ILushort depth, |
| 395 | char *compressedData, ILuint compressedDataSize) |
| 396 | { |
| 397 | |
| 398 | char *channels[4]; |
| 399 | char *data; |
| 400 | int i, k, row, column; |
| 401 | ILuint compressedStart = 0; |
| 402 | |
| 403 | // Decompress only in RGBA. |
| 404 | if (depth != 4) { |
| 405 | ilSetError(IL_ILLEGAL_FILE_VALUE); |
| 406 | return NULL; |
| 407 | } |
| 408 | |
| 409 | for (i = depth-1; i >= 0; --i) { |
| 410 | channels[i] = iff_decompress_rle(width * height, compressedData, |
| 411 | compressedDataSize, &compressedStart); |
| 412 | if (channels[i] == NULL) |
| 413 | return NULL; |
| 414 | } |
| 415 | |
| 416 | // Build all the channels from the decompression into an RGBA array. |
| 417 | data = (char*)ialloc(width * height * depth * sizeof(char)); |
| 418 | if (data == NULL) |
| 419 | return NULL; |
| 420 | |
| 421 | for (row = 0; row < height; row++) |
| 422 | for (column = 0; column < width; column++) |
| 423 | for (k = 0; k < depth; k++) |
| 424 | data[depth*(row*width + column) + k] = |
| 425 | channels[k][row*width + column]; |
| 426 | |
| 427 | ifree(channels[0]); ifree(channels[1]); |
| 428 | ifree(channels[2]); ifree(channels[3]); |
| 429 | |
| 430 | return data; |
| 431 | } |
| 432 | |
| 433 | char *iff_decompress_rle(ILuint numBytes, char *compressedData, |
| 434 | ILuint compressedDataSize, |
no test coverage detected