/[enigma]/enigma/lib-src/oxydlib/extractbitmaps.cpp
ViewVC logotype

Diff of /enigma/lib-src/oxydlib/extractbitmaps.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by mhawlisch, Tue Apr 1 09:47:05 2003 UTC revision 1.3 by reallysoft, Wed Jun 25 19:31:59 2003 UTC
# Line 25  Line 25 
25  #include "Bitmap.h"  #include "Bitmap.h"
26    
27  using namespace std;  using namespace std;
28    using namespace OxydLib;
29    
30  void usage()  void usage()
31  {  {
# Line 117  int main(int argc, char *argv[]) Line 118  int main(int argc, char *argv[])
118      if (pChunk) {      if (pChunk) {
119        Bitmap bitmap;        Bitmap bitmap;
120        Palette palette;        Palette palette;
121        if (parseBitmap(*pChunk, ver, &bitmap, &palette)) {        if (parseBitmap(*pChunk, &bitmap, &palette)) {
122          goodPalette = palette;          goodPalette = palette;
123        }        }
124      }      }
125    }    }
# Line 133  int main(int argc, char *argv[]) Line 134  int main(int argc, char *argv[])
134      if (dotPos >= 0) {      if (dotPos >= 0) {
135        string ext = chunkName.substr(dotPos);        string ext = chunkName.substr(dotPos);
136        if (ext.compare(".PIB") == 0) {        if (ext.compare(".PIB") == 0) {
137          Bitmap bitmap;          Bitmap bitmap;
138          Palette palette;          Palette palette;
139          success = parseBitmap(chunk, ver, &bitmap, &palette, &msg);          success = parseBitmap(chunk, &bitmap, &palette, &msg);
140          if (!success) {          if (!success) {
141            printf("Error parsing bitmap %s:\n", chunkName.c_str());            printf("Error parsing bitmap %s:\n", chunkName.c_str());
142            printf("%s\n", msg.c_str());            printf("%s\n", msg.c_str());
143          } else {          } else {
144            const Palette *pPalette = &palette;            const Palette *pPalette = &palette;
145            if (bitmap.getBitDepth() == 1) {            if (bitmap.getBitDepth() == 1) {
146              pPalette = &twoColorPalette;              pPalette = &twoColorPalette;
147            } else {            } else {
148              bool allBlack = true;              bool allBlack = true;
149              for (int nColor = 0; nColor < 16; nColor++) {              for (int nColor = 0; nColor < 16; nColor++) {
150                unsigned int red, green, blue;                unsigned int red, green, blue;
151                palette.getColor(nColor, &red, &green, &blue);                palette.getColor(nColor, &red, &green, &blue);
152                if (red != 0x0000 || green != 0x0000 || blue != 0x0000) {                if (red != 0x0000 || green != 0x0000 || blue != 0x0000) {
153                  allBlack = false;                  allBlack = false;
154                  break;                  break;
155                }                }
156              }              }
157              if (allBlack) {              if (allBlack) {
158                pPalette = &goodPalette;                pPalette = &goodPalette;
159              }              }
160            }            }
161            ByteVec ppm;            ByteVec ppm;
162            bitmapToPPM(bitmap, *pPalette, &ppm);            bitmapToPPM(bitmap, *pPalette, &ppm);
163    
164            string outFileName;            string outFileName;
165            if (bGotDir) {            if (bGotDir) {
166              outFileName.append(strDir);              outFileName.append(strDir);
167              outFileName.append("/");              outFileName.append("/");
168            }            }
169            outFileName.append(chunkName);            outFileName.append(chunkName);
170            outFileName.append(".ppm");            outFileName.append(".ppm");
171            success = writeFile(outFileName, ppm);            success = writeFile(outFileName, ppm);
172            if (!success) {            if (!success) {
173              printf("Error writing bitmap '%s'.\n", outFileName.c_str());              printf("Error writing bitmap '%s'.\n", outFileName.c_str());
174            }            }
175          }          }
176        }        }
177      }      }
178    }    }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26