diff options
author | Stijn Buys <ingar@osirion.org> | 2010-09-15 21:29:18 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2010-09-15 21:29:18 +0000 |
commit | e55638d081e2e1ff6fbc06e0e8ac0381a04308e7 (patch) | |
tree | 511ccb478adf2acd3cc93f66d217b09f3e3a06dc /src/render/tgafile.cc | |
parent | f612f19e095b8d0ba49f5bcdec6a582824315d69 (diff) |
updated comments, updated buy menu, info support for map window, added const to target selection
Diffstat (limited to 'src/render/tgafile.cc')
-rw-r--r-- | src/render/tgafile.cc | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/render/tgafile.cc b/src/render/tgafile.cc index db54645..10082e6 100644 --- a/src/render/tgafile.cc +++ b/src/render/tgafile.cc @@ -270,20 +270,20 @@ void TGA::save(const char *filename, Image & image) pixel_data[3] = *image[index+3]; if (block_length == 0) { + // if the block is empty, copy the first pixel memcpy(block_data, pixel_data, image.channels()); block_length++; + // by default, the block is not compressed compress = false; } else { + // if the current block is not compressed if (!compress) { - - // uncompressed block and pixel_data differs from the last pixel + // if the previous pixel differs from the pixel data if (memcmp(&block_data[(block_length-1)*image.channels()], pixel_data, image.channels()) != 0) { // append pixel memcpy(&block_data[block_length*image.channels()], pixel_data, image.channels()); - block_length++; } else { - // uncompressed block and pixel data is identical if (block_length > 1) { // write the uncompressed block @@ -292,17 +292,16 @@ void TGA::save(const char *filename, Image & image) ofs.write((char *)block_data, (block_length - 1) * image.channels()); block_length = 1; } + // create a commpressed block memcpy(block_data, pixel_data, image.channels()); block_length++; compress = true; } - + // if the current block is compressed } else { - - // compressed block and pixel data are identical + // if the previous pixel and the pixel data are identical if (memcmp(block_data, pixel_data, image.channels()) == 0) { block_length++; - } else { // compressed block and pixel data differs |