本文整理汇总了C++中decompress函数的典型用法代码示例。如果您正苦于以下问题:C++ decompress函数的具体用法?C++ decompress怎么用?C++ decompress使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了decompress函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: decompressResource
void decompressResource()
{
for(bool bDone = false;!bDone;) //Loop until we're done
{
ThreadConvertHelper dh;
wstring sFilename;
std::lock_guard<std::mutex> lock(g_Mutex);
if(!g_lThreadedResources.size()) //Done
{
bDone = true;
}
else
{
//Grab the top item off the list
dh = g_lThreadedResources.front();
sFilename = getName(dh.id); //Mutex on this too, since getName() isn't really threadsafe
makeFolder(dh.id); //Also create folder (not threadsafe, either)
g_lThreadedResources.pop_front(); //Done with this element
}
//Let user know which resource we're converting now
if(!bDone)
{
g_iCurResource++;
if(!(sFilename == RESIDMAP_NAME && g_iCurResource == 1))
{
if(g_bProgressOverwrite)
{
cout << "\rDecompressing file " << g_iCurResource << " out of " << g_iNumResources;
cout.flush();
}
else
cout << "Decompressing file " << g_iCurResource << " out of " << g_iNumResources << ": " << ws2s(sFilename) << endl;
}
}
// Release ownership of the mutex object
if(sFilename == RESIDMAP_NAME && g_iCurResource == 1) //Don't release residmap.dat mutex until we've read in all the filenames
{
g_iNumResources--;
}
if(bDone)
{
continue; //Stop here if done
}
if(dh.bCompressed) //Compressed
{
uint8_t* tempData = decompress(&dh.data);
if(tempData == NULL)
{
cout << "Error decompressing file " << ws2s(sFilename) << endl;
return;
}
free(dh.data.data); //Free this compressed memory
dh.data.data = tempData; //Now we have the decompressed data
}
//See if this was a PNG image. Convert PNG images from the data in RAM
if(sFilename.find(L".png") != wstring::npos ||
sFilename.find(L".PNG") != wstring::npos ||
sFilename.find(L"coloritemicon") != wstring::npos ||
sFilename.find(L"colorbgicon") != wstring::npos ||
sFilename.find(L"greybgicon") != wstring::npos) //Also would include .png.normal files as well
{
convertToPNG(sFilename.c_str(), dh.data.data, dh.data.decompressedSize); //Do the conversion to PNG
}
else //For other file types, go ahead and write to the file before converting
{
//Write this out to the file
FILE* fOut = fopen(ws2s(sFilename).c_str(), "wb");
if(fOut == NULL)
{
cout << "Unable to open output file " << ws2s(sFilename) << endl;
return;
}
fwrite(dh.data.data, 1, dh.data.decompressedSize, fOut);
fclose(fOut);
}
free(dh.data.data); //Free memory from this file
/*
//Convert wordPackDict.dat to XML
if(sFilename.find(L"wordPackDict.dat") != wstring::npos)
{
wordPackToXML(sFilename.c_str());
unlink(ws2s(sFilename).c_str());
}
//Convert sndmanifest.dat to XML
else if(sFilename.find(L"sndmanifest.dat") != wstring::npos)
{
sndManifestToXML(sFilename.c_str());
unlink(ws2s(sFilename).c_str());
}
//Convert itemmanifest.dat to XML
else if(sFilename.find(L"itemmanifest.dat") != wstring::npos)
//.........这里部分代码省略.........
示例2: decompress
bool mvt_tile::decode(std::string &message) {
layers.clear();
std::string src;
if (is_compressed(message)) {
std::string uncompressed;
decompress(message, uncompressed);
src = uncompressed;
} else {
src = message;
}
protozero::pbf_reader reader(src);
while (reader.next()) {
switch (reader.tag()) {
case 3: /* layer */
{
protozero::pbf_reader layer_reader(reader.get_message());
mvt_layer layer;
while (layer_reader.next()) {
switch (layer_reader.tag()) {
case 1: /* name */
layer.name = layer_reader.get_string();
break;
case 3: /* key */
layer.keys.push_back(layer_reader.get_string());
break;
case 4: /* value */
{
protozero::pbf_reader value_reader(layer_reader.get_message());
mvt_value value;
while (value_reader.next()) {
switch (value_reader.tag()) {
case 1: /* string */
value.type = mvt_string;
value.string_value = value_reader.get_string();
break;
case 2: /* float */
value.type = mvt_float;
value.numeric_value.float_value = value_reader.get_float();
break;
case 3: /* double */
value.type = mvt_double;
value.numeric_value.double_value = value_reader.get_double();
break;
case 4: /* int */
value.type = mvt_int;
value.numeric_value.int_value = value_reader.get_int64();
break;
case 5: /* uint */
value.type = mvt_uint;
value.numeric_value.uint_value = value_reader.get_uint64();
break;
case 6: /* sint */
value.type = mvt_sint;
value.numeric_value.sint_value = value_reader.get_sint64();
break;
case 7: /* bool */
value.type = mvt_bool;
value.numeric_value.bool_value = value_reader.get_bool();
break;
default:
value_reader.skip();
break;
}
}
layer.values.push_back(value);
break;
}
case 5: /* extent */
layer.extent = layer_reader.get_uint32();
break;
case 15: /* version */
layer.version = layer_reader.get_uint32();
break;
case 2: /* feature */
{
protozero::pbf_reader feature_reader(layer_reader.get_message());
mvt_feature feature;
std::vector<uint32_t> geoms;
while (feature_reader.next()) {
switch (feature_reader.tag()) {
case 1: /* id */
//.........这里部分代码省略.........
示例3: decompress_as
output_t decompress_as (const compressed_data& in)
{
output_t out;
decompress(in, out);
return out;
}
示例4: databuf_nodelist
void MapBlock::deSerialize_pre22(std::istream &is, u8 version, bool disk)
{
u32 nodecount = MAP_BLOCKSIZE*MAP_BLOCKSIZE*MAP_BLOCKSIZE;
// Initialize default flags
is_underground = false;
m_day_night_differs = false;
m_lighting_expired = false;
m_generated = true;
// Make a temporary buffer
u32 ser_length = MapNode::serializedLength(version);
SharedBuffer<u8> databuf_nodelist(nodecount * ser_length);
// These have no compression
if(version <= 3 || version == 5 || version == 6)
{
char tmp;
is.read(&tmp, 1);
if(is.gcount() != 1)
throw SerializationError
("MapBlock::deSerialize: no enough input data");
is_underground = tmp;
is.read((char*)*databuf_nodelist, nodecount * ser_length);
if(is.gcount() != nodecount * ser_length)
throw SerializationError
("MapBlock::deSerialize: no enough input data");
}
else if(version <= 10)
{
u8 t8;
is.read((char*)&t8, 1);
is_underground = t8;
{
// Uncompress and set material data
std::ostringstream os(std::ios_base::binary);
decompress(is, os, version);
std::string s = os.str();
if(s.size() != nodecount)
throw SerializationError
("MapBlock::deSerialize: invalid format");
for(u32 i=0; i<s.size(); i++)
{
databuf_nodelist[i*ser_length] = s[i];
}
}
{
// Uncompress and set param data
std::ostringstream os(std::ios_base::binary);
decompress(is, os, version);
std::string s = os.str();
if(s.size() != nodecount)
throw SerializationError
("MapBlock::deSerialize: invalid format");
for(u32 i=0; i<s.size(); i++)
{
databuf_nodelist[i*ser_length + 1] = s[i];
}
}
if(version >= 10)
{
// Uncompress and set param2 data
std::ostringstream os(std::ios_base::binary);
decompress(is, os, version);
std::string s = os.str();
if(s.size() != nodecount)
throw SerializationError
("MapBlock::deSerialize: invalid format");
for(u32 i=0; i<s.size(); i++)
{
databuf_nodelist[i*ser_length + 2] = s[i];
}
}
}
// All other versions (newest)
else
{
u8 flags;
is.read((char*)&flags, 1);
is_underground = (flags & 0x01) ? true : false;
m_day_night_differs = (flags & 0x02) ? true : false;
m_lighting_expired = (flags & 0x04) ? true : false;
if(version >= 18)
m_generated = (flags & 0x08) ? false : true;
// Uncompress data
std::ostringstream os(std::ios_base::binary);
decompress(is, os, version);
std::string s = os.str();
if(s.size() != nodecount*3)
throw SerializationError
("MapBlock::deSerialize: decompress resulted in size"
" other than nodecount*3");
// deserialize nodes from buffer
for(u32 i=0; i<nodecount; i++)
{
databuf_nodelist[i*ser_length] = s[i];
//.........这里部分代码省略.........
示例5: main
int main(int argc, char **argv)
{
if (argc < 2)
{
return 1;
}
{
// Queue
fileQueue = new PathQueue();
for (int i = 1; i < argc; ++i)
{
boost::filesystem::path argPath(argv[i]);
if (boost::filesystem::exists(argPath)) // Does the file exist?
{
if (boost::filesystem::is_regular_file(argPath))
{
// TODO: NOT YET IMPLEMENTED
// Execute file process
#ifdef FILEIO
std::cout << std::endl << "Reading file" << argPath << std::endl;
#endif
fileQueue->push(argPath);
}
else if (boost::filesystem::is_directory(argPath))
{
// TODO: NOT YET IMPLEMENTED
// Execute on all files in the directory
recurseProcessor(argPath);
}
else
{
return -1;
}
}
}
}
auto lz4Proc = new LZ4::Processor();
std::ifstream fIn;
std::ofstream fOut;
size_t fBeg, fEnd;
std::string oName;
std::string::size_type pAt;
bool bIsCompressed;
char *data;
while (fileQueue->size() > 0)
{
// FIRST THINGS
oName = fileQueue->accPop().string();
bIsCompressed = boost::algorithm::ends_with(oName,".lz4");
fIn.open(oName,std::ios::binary);
if (!fIn.is_open())
{
continue;
}
fIn.seekg(0, std::ios::end);
fEnd = fIn.tellg();
fIn.seekg(0, std::ios::beg);
fBeg = fIn.tellg();
data = new char[(fEnd - fBeg)];
fIn.read(data, fEnd - fBeg);
fIn.close();
std::cout << "File is " << fEnd - fBeg << std::endl;
if (bIsCompressed)
{
lz4Proc->decompress(data, int(fEnd - fBeg));
pAt = oName.find_last_of('.');
oName = oName.substr(0, pAt);
}
else
{
lz4Proc->compress(data, int(fEnd - fBeg));
oName = oName + ".lz4";
}
delete data;
if (lz4Proc->len() == 0) continue;
std::cout << lz4Proc->len() << std::endl;
fOut.open(oName, std::ios::binary);
if (!fOut.is_open()) continue;
fOut.write(lz4Proc->ptr(), lz4Proc->len());
fOut.close();
}
delete fileQueue;
getchar();
return 0;
}
示例6: main
int main(void)
{
aplist *head = NULL;
aplist *cur;
bool attached = true;
// change this to false if you are only testing servos
bool wifi_scan = true;
// change this for emulator
bool emulate = false;
float pain = 0.9f;
time_t update = 0;
uint8 num;
uint8 servo_pos = 0;
uint8 current_servo = 1;
unsigned char SERVO_PINS[3] = { SERVO_PIN1 ,SERVO_PIN2 ,SERVO_PIN3 } ;
uint16 val[3] = { 0 };
uint8 i;
touchPosition touch;
videoSetMode(MODE_4_2D);
vramSetBankA(VRAM_A_MAIN_BG);
// set up our bitmap background
bgInit(3, BgType_Bmp16, BgSize_B16_256x256, 0,0);
decompress(cclogoBitmap, BG_GFX, LZ77Vram);
// initialise lower screen for textoutput
consoleDemoInit();
if (emulate == false) {
iprintf("Initializing WiFi.. ");
Wifi_InitDefault(false);
while (Wifi_CheckInit() != 1) {
}
Wifi_ScanMode();
iprintf("done\n");
iprintf("Initializing DS brut.. ");
uart_init();
uart_set_spi_rate(1000);
iprintf("done\n\n\n");
iprintf("Using servo pins: %u %u %u\n\n", SERVO_PIN1, SERVO_PIN2, SERVO_PIN3);
iprintf("Default pain multiplier: %.2f\n\n", pain);
swiDelay(60000000);
while (1) {
scanKeys();
touchRead(&touch);
if (keysDown() & KEY_X) {
if (attached) {
servo_detach(SERVO_PIN1);
servo_detach(SERVO_PIN2);
servo_detach(SERVO_PIN3);
attached = false;
} else {
attached = true;
}
}
if (keysDown() & KEY_A) {
if (attached) {
uint8 i = 0;
for (i=0;i<3;i++) {
servo_set(SERVO_PINS[i],0);
}
}
//servo_set(SERVO_PIN1, 180-((rand() % 100)+(rand() % 50)+(rand() % 25)));
//servo_set(SERVO_PIN2, 180-((rand() % 100)+(rand() % 50)+(rand() % 25)));
//servo_set(SERVO_PIN3, 180-((rand() % 100)+(rand() % 50)+(rand() % 25)));
}
if (keysDown() & KEY_B) {
if (wifi_scan == true) {
wifi_scan = false;
}
else {
wifi_scan = true;
}
}
if (keysDown() & KEY_DOWN) {
pain -= 0.1f;
if (pain < 0.0f) {
pain = 0.0f;
}
update = time(NULL);
}
if (keysDown() & KEY_UP) {
pain += 0.1f;
if (2.0f < pain) {
pain = 2.0f;
}
update = time(NULL);
}
if (keysDown() & KEY_L) {
current_servo += 1;
if (current_servo > 3) {
//.........这里部分代码省略.........
示例7: MemoryFile
void ZlibFile::createDecompressedMemoryFile()
{
MemoryFile * memoryFile = new MemoryFile(decompress(), m_uncompressedLength);
close();
m_decompressedMemoryFile = memoryFile;
}
示例8: do_decompress
int do_decompress(u8 *input, int len, u8 *output, void (*error)(char *x))
{
return decompress(input, len, NULL, NULL, output, NULL, error);
}
示例9: main
int main(void)
{
int n,
cport_nr = 4, /* 6 (COM5 on windows) */
bdrate = 38400; /* 9600 baud */
uint8_t buf[BUF_SIZE + 1];
uint8_t data[MAX_DATA_SIZE];
char mode[] = {'8','N','1',0};
if (RS232_OpenComport(cport_nr, bdrate, mode)) {
printf("Can not open comport\n");
return(0);
}
int received_cnt = 0;
while (1) {
n = RS232_PollComport(cport_nr, buf, BUF_SIZE);
if (n > 0) {
/* always put a "null" at the end of a string! */
buf[n] = 0;
printf("Received %i bytes: %s\n", n, (char *) buf);
if (arr_search("TKENDTKENDTKENDTKEND", BUF_SIZE, buf, n) > 0) {
printf("%s\n", "Starting reception...");
memset(data, 0, MAX_DATA_SIZE); /* Initialize the array */
received_cnt = 0;
}
else {
int pos = -1;
/* If receiving the end of current compressed buffer, send & reinitialize */
if ((pos = arr_search("TKENDTKENDTKENDTKE", DELIMITER_LEN, buf, n)) >= 0) {
int eff_len = pos - DELIMITER_LEN + 1;
uint8_t temp[eff_len];
memcpy(temp, buf, eff_len);
memcpy(data + received_cnt, temp, eff_len);
received_cnt += eff_len;
/* Discard the last five bytes of indicators*/
char size_buf[2];
memcpy(size_buf, buf + pos + 1, 2);
int size = size_buf[1] + (size_buf[0] << 4);
printf("Received data total size: %d\n", size);
uint8_t comp[size];
memcpy(comp, data, size);
decompress(comp, size);
/* Clean up */
memset(data, 0, MAX_DATA_SIZE);
received_cnt = 0;
/* Also need to store rest of the data to avoid loss */
// uint8_t lost[n - eff_len - 5];
// memcpy(lost, buf + pos + 1, n - pos - 1);
// memcpy(data, lost, n - pos - 1);
// received_cnt += n - pos - 1;
} else { /* If regular data packets, store it*/
memcpy(data + received_cnt, buf, n);
received_cnt = received_cnt + n;
}
}
}
#ifdef _WIN32
Sleep(100);
#else
usleep(100000); /* sleep for 100 milliSeconds */
#endif
}
return (0);
}
示例10: fread
int PFSLoader::Open(FILE *fp) {
struct_header s3d_header;
struct_directory_header s3d_dir_header;
struct_directory s3d_dir;
struct_data_block s3d_data;
struct_fn_header *s3d_fn_header;
struct_fn_entry *s3d_fn_entry;
uint32 *offsets;
char *temp, *temp2;
int i, j, pos, inf, tmp, running = 0;
fread(&s3d_header, sizeof(struct_header), 1, fp);
if(s3d_header.magicCookie[0] != 'P' || s3d_header.magicCookie[1] != 'F' || s3d_header.magicCookie[2] != 'S' || s3d_header.magicCookie[3] != ' ')
return 0;
this->fp = fp;
fseek(fp, s3d_header.offset, SEEK_SET);
fread(&s3d_dir_header, sizeof(struct_directory_header), 1, fp);
this->count = s3d_dir_header.count - 1;
this->filenames = new char *[s3d_dir_header.count];
this->files = new uint32[s3d_dir_header.count - 1];
offsets = new uint32[s3d_dir_header.count - 1];
for(i = 0; i < (int)s3d_dir_header.count; ++i) {
fread(&s3d_dir, sizeof(struct_directory), 1, fp);
if(s3d_dir.crc == ntohl(0xC90A5861)) {
pos = ftell(fp);
fseek(fp, s3d_dir.offset, SEEK_SET);
temp = new char[s3d_dir.size];
memset(temp, 0, s3d_dir.size);
inf = 0;
while(inf < (int)s3d_dir.size) {
fread(&s3d_data, sizeof(struct_data_block), 1, fp);
temp2 = new char[s3d_data.deflen];
fread(temp2, s3d_data.deflen, 1, fp);
decompress(temp2, temp + inf, s3d_data.deflen, s3d_data.inflen);
delete[] temp2;
inf += s3d_data.inflen;
}
fseek(fp, pos, SEEK_SET);
s3d_fn_header = (struct_fn_header *) temp;
pos = sizeof(struct_fn_header);
for(j = 0; j < (int)s3d_fn_header->fncount; ++j) {
s3d_fn_entry = (struct_fn_entry *) &temp[pos];
this->filenames[j] = new char[s3d_fn_entry->fnlen + 1];
this->filenames[j][s3d_fn_entry->fnlen] = 0;
memcpy(this->filenames[j], &temp[pos + sizeof(struct_fn_entry)], s3d_fn_entry->fnlen);
pos += sizeof(struct_fn_entry) + s3d_fn_entry->fnlen;
}
}
else {
this->files[running] = ftell(fp) - 12;
offsets[running] = s3d_dir.offset;
++running;
}
}
for(i = s3d_dir_header.count - 2; i > 0; i--) {
for(j = 0; j < i; j++) {
if(offsets[j] > offsets[j+1]) {
tmp = offsets[j];
offsets[j] = offsets[j + 1];
offsets[j + 1] = tmp;
tmp = this->files[j];
this->files[j] = this->files[j + 1];
this->files[j + 1] = tmp;
}
}
}
return 1;
}
示例11: decompress
std::vector<uint8_t> decompress(const std::vector<uint8_t>& data)
{
return decompress(&data[0], data.size());
}
示例12: decompress
void BitVector::rleANDnon(BitVector& bv) {
// decompress
// run nonANDnon
decompress();
nonANDnon(bv);
}
示例13: main
/* Entry point for the program. Opens the file, and executes the mode specified by command line args */
int main(int argc, char* argv[])
{
if(argc != 3 || (strcmp(argv[1], "-c") != 0 && strcmp(argv[1], "-d") != 0 && strcmp(argv[1], "-t") != 0))
{
printf("usage: huff [-c | -d | -t] file\n");
return -1;
}
/* Execute the correct mode */
if(strcmp(argv[1], "-c") == 0)
{
//append the extension to the name
const char * extension = ".temp";
char *tempFile = malloc(strlen(argv[2])+strlen(extension) + 1);
strncpy(tempFile, argv[2], strlen(argv[2]));
strcat(tempFile, extension);
//RLE encode the file
rle_encode(argv[2], tempFile);
//create a vairiable to hold hold the file length
unsigned long long fileLength = 0;
//get a buffer of the contents of the file as a unsigned char*
unsigned char *file_pointer = openFile(tempFile, &fileLength);
//huff compress the output.
compress(file_pointer, fileLength, argv[2]);
free(file_pointer);
//free(tempFile);
remove(tempFile);
}
else if(strcmp(argv[1], "-d") == 0)
{
unsigned long long fileLength = 0;
unsigned char *file_pointer = openFile(argv[2], &fileLength);
decompress(file_pointer, fileLength, argv[2]);
//remove the .hurl extension from the fileName;
char *tempFileName = calloc(strlen(argv[2]), sizeof(char));
strncpy(tempFileName, argv[2], strlen(argv[2]) - strlen(".hurl"));
strncat(tempFileName, ".temp", sizeof(".temp"));
char *outputFileName = calloc(sizeof(char), strlen(argv[2]));
strncpy(outputFileName, argv[2], strlen(argv[2]));
outputFileName[strlen(outputFileName) -5] = '\0';
rle_decode(tempFileName, outputFileName);
free(file_pointer);
remove(tempFileName);
}
else if(strcmp(argv[1], "-t") == 0)
{
unsigned long long fileLength = 0;
unsigned char *file_pointer = openFile(argv[2], &fileLength);
print_table(file_pointer, fileLength, argv[2]);
free(file_pointer);
}
// free(file_pointer);
return 0;
}
示例14: next_size
std::pair<char*, size_t> LZ4RunReader::next()
{
// Is there a complete key in the buffer?
if( decomp_.fill() >= sizeof(size_t) &&
decomp_.fill() >= (sizeof(size_t) + next_size()) )
{
auto ret = std::make_pair(decomp_.base() + decomp_.lo() + sizeof(size_t),
next_size());
decomp_.advance_lo(ret.second + sizeof(size_t));
return ret;
}
// No key. Did we hit eof?
else if( eof_ )
{
if( decomp_.fill() )
{
WARNING("Run file had " << decomp_.fill() << " extraneous bytes at end");
}
if( comp_.fill() )
{
WARNING("Run file consumed with " << comp_.fill() << " compressed"
" bytes remaining");
}
return std::pair<char*, size_t>(nullptr, 0);
}
// We need some more data
else
{
// Fill buffer until we have hit the trigger point, and we have a
// a complete key
while( !eof_ &&
( decomp_.fill() < trigger_ ||
decomp_.fill() < (sizeof(size_t) + next_size()) ) )
{
// First try to decompress that which we have
if( comp_.fill() )
{
decompress();
// Skip read if we got enough data
if( decomp_.fill() >= trigger_ &&
decomp_.fill() >= (sizeof(size_t) + next_size()) )
{
continue;
}
}
if( poll(fds_, 1, -1) < 0 )
{
WARNING("poll() failed, input may have terminated prematurely.");
eof_ = true;
}
// Read into the compressed buffer
int bytes_read = read(fds_[0].fd, comp_.base() + comp_.hi(),
comp_.size() - comp_.fill());
if( bytes_read <= 0 )
{
eof_ = true;
if( bytes_read < 0 )
{
WARNING("read() failed, input may have terminated prematurely.");
}
}
else
{
comp_.advance_hi(bytes_read);
decompress();
}
}
// Warn if eof without a complete key
if( eof_ && ( decomp_.fill() < sizeof(size_t) ||
decomp_.fill() < (sizeof(size_t) + next_size()) ) )
{
WARNING("Run file had " << decomp_.fill() << " extraneous bytes at end");
return std::pair<char*, size_t>(nullptr, 0);
}
// We now have at least one key in the buffer. Return the first.
auto ret = std::make_pair(decomp_.base() + decomp_.lo() + sizeof(size_t),
next_size());
decomp_.advance_lo(ret.second + sizeof(size_t));
return ret;
}
}
示例15: assert
void TPC::fixupCubeMap() {
/* Do various fixups to the cube maps. This includes rotating and swapping a
* few sides around. This is done by the original games as well.
*/
if (!isCubeMap())
return;
for (size_t j = 0; j < getMipMapCount(); j++) {
assert(getLayerCount() > 0);
const size_t index0 = 0 * getMipMapCount() + j;
assert(index0 < _mipMaps.size());
const int32 width = _mipMaps[index0]->width;
const int32 height = _mipMaps[index0]->height;
const uint32 size = _mipMaps[index0]->size;
for (size_t i = 1; i < getLayerCount(); i++) {
const size_t index = i * getMipMapCount() + j;
assert(index < _mipMaps.size());
if ((width != _mipMaps[index]->width ) ||
(height != _mipMaps[index]->height) ||
(size != _mipMaps[index]->size ))
throw Common::Exception("Cube map layer dimensions mismatch");
}
}
// Since we need to rotate the individual cube sides, we need to decompress them all
decompress();
// Swap the first two sides of the cube maps
for (size_t j = 0; j < getMipMapCount(); j++) {
const size_t index0 = 0 * getMipMapCount() + j;
const size_t index1 = 1 * getMipMapCount() + j;
assert((index0 < _mipMaps.size()) && (index1 < _mipMaps.size()));
MipMap &mipMap0 = *_mipMaps[index0];
MipMap &mipMap1 = *_mipMaps[index1];
SWAP(mipMap0.data, mipMap1.data);
}
const int bpp = (_formatRaw == kPixelFormatRGB8) ? 3 : ((_formatRaw == kPixelFormatRGBA8) ? 4 : 0);
if (bpp == 0)
return;
// Rotate the cube sides so that they're all oriented correctly
for (size_t i = 0; i < getLayerCount(); i++) {
for (size_t j = 0; j < getMipMapCount(); j++) {
const size_t index = i * getMipMapCount() + j;
assert(index < _mipMaps.size());
MipMap &mipMap = *_mipMaps[index];
static const int rotation[6] = { 1, 3, 0, 2, 2, 0 };
rotate90(mipMap.data, mipMap.width, mipMap.height, bpp, rotation[i]);
}
}
}