File size: 1,223 Bytes
7c6501b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | #include "decompress.h"
//--------------------DECOMPRESSION FUNCTION----------------------------------//
void decompressImage(qtNode *node, pixels ***imageMatrix, int startX, int startY, int blockSize)
{
int i, j;
// already optimized tree
if (node->topLeft == NULL && node->topRight == NULL && node->bottomLeft == NULL && node->bottomRight == NULL)
{
for (i = startY; i < startY + blockSize; i++)
{
for (j = startX; j < startX + blockSize; j++)
{
(*imageMatrix)[i][j].red = node->p.red;
(*imageMatrix)[i][j].green = node->p.green;
(*imageMatrix)[i][j].blue = node->p.blue;
}
}
}
// decompress till tree is optimized
else
{
decompressImage(node->topLeft, imageMatrix, startX, startY, blockSize / 2);
decompressImage(node->topRight, imageMatrix, startX + (blockSize / 2), startY, blockSize / 2);
decompressImage(node->bottomRight, imageMatrix, startX + (blockSize / 2), startY + (blockSize / 2), blockSize / 2);
decompressImage(node->bottomLeft, imageMatrix, startX, startY + (blockSize / 2), blockSize / 2);
}
}
|