Gooden Posted December 19, 2007 at 10:34 AM Report Share #155167 Posted December 19, 2007 at 10:34 AM BOm eu tou a tentar fazer 1 coisita em vb.net que le um ficheiro spr. arranjei 1 codigo para descompactar mas isto em c++ n茫o entendo. :S se algum me poder explicar o codigo agradecia. 馃檪 aqui vai ele unsigned char* Sprites::UnpackSprite(int which) { 聽 unsigned char* OutputData; 聽 if (which == 0) 聽 { 聽 聽 OutputData = new unsigned char[32*32*4]; memset(OutputData, 0, 32*32*4); return OutputData; 聽 } 聽 std::map<unsigned short, Sprite*>::iterator it = SpriteCollection.find(which); 聽 if ((it != SpriteCollection.end()) && (it->second != NULL)) 聽 { 聽 聽 unsigned char r, g ,b; 聽 聽 int pos = 0; 聽 聽 int pix = 0; 聽 聽 OutputData = new unsigned char[it->second->width*it->second->height*4]; memset(OutputData, 0xFF, it->second->width*it->second->height*4); while(true) { 聽 if(pix >= it->second->width*it->second->height) 聽 聽 break; r = it->second->data[pos]; g = it->second->data[pos+1]; b = it->second->data[pos+2]; pos += 3; if(r == 0xFE) r++; if(g == 0xFE) g++; if(b == 0xFE) b++; OutputData[pix*4] = r; OutputData[pix*4+1] = g; OutputData[pix*4+2] = b; if((r == 0xFF) && (g == 0x00) && (b == 0xFF)) { OutputData[pix*4] = 0; 聽 聽 聽 聽 聽 聽 OutputData[pix*4+2] = 0; OutputData[pix*4+3] = 0; } pix++; if(it->second->data[pos] == 0xFF) { 聽 聽 聽 聽 聽 for(unsigned char sp = 0; sp < it->second->data[pos+1]; sp++) 聽 { 聽 聽 聽 聽 if(pix >= it->second->width*it->second->height) 聽 聽 聽 聽 聽 break; 聽 聽 OutputData[pix*4] = r; OutputData[pix*4+1] = g; OutputData[pix*4+2] = b; if((r == 0xFF) && (g == 0x00) && (b == 0xFF)) { OutputData[pix*4] = 0; OutputData[pix*4+2] = 0; OutputData[pix*4+3] = 0; 聽 聽 } pix++; 聽 } 聽 聽 聽 聽 聽 pos += 2; } } return OutputData; 聽 聽 } 聽 return NULL; } Link to comment Share on other sites More sharing options...
mogers Posted December 19, 2007 at 05:51 PM Report Share #155257 Posted December 19, 2007 at 05:51 PM 脡 um pouco dificil de perceber o c贸digo sem conhecer o formato da imagem. Tu conheces? Pelo que vejo, para cada pixel da imagem, o ficheiro tem os valores rgb (red,green,blue) da cor do pixel e valor de intensidade da cor. Agora os "porqu锚s" de ele comparar com intensidades 255 (0xFF) ou 0, s贸 vendo o tal formato de codifica莽茫o da imagem... "What we do for ourselves dies with us. What we do for others and the world, remains and is immortal.", Albert Pine Blog pessoal : cont茅m alguns puzzles, algoritmos e problemas para se resolver com programa莽茫o. Link to comment Share on other sites More sharing options...
Gooden Posted December 19, 2007 at 07:01 PM Author Report Share #155272 Posted December 19, 2007 at 07:01 PM isto 茅 um ficheiro spr que contem 2000 imagens + este codigo descripta o ficheiro spr e apresenta-as numa pasta. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now