CBitmapHandler.h 961 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #pragma once
  2. #include "../global.h"
  3. struct SDL_Surface;
  4. class CLodHandler;
  5. enum Epcxformat {PCX8B, PCX24B};
  6. struct BMPPalette
  7. {
  8. unsigned char R,G,B,F;
  9. };
  10. struct BMPHeader
  11. {
  12. int fullSize, _h1, _h2, _h3, _c1, _c2, _c3, _c4, x, y,
  13. dataSize1, dataSize2; //DataSize=X*Y+2*Y
  14. unsigned char _c5[8];
  15. void print(std::ostream & out);
  16. BMPHeader(){_h1=_h2=0;for(int i=0;i<8;i++)_c5[i]=0;};
  17. };
  18. class CPCXConv
  19. {
  20. public:
  21. unsigned char * pcx, *bmp;
  22. int pcxs, bmps;
  23. void fromFile(std::string path);
  24. void saveBMP(std::string path);
  25. void openPCX(char * PCX, int len);
  26. void openPCX();
  27. void convert();
  28. SDL_Surface * getSurface(); //for standard H3 PCX
  29. //SDL_Surface * getSurfaceZ(); //for ZSoft PCX
  30. CPCXConv(){pcx=bmp=NULL;pcxs=bmps=0;};
  31. ~CPCXConv(){if (pcxs) delete[] pcx; if(bmps) delete[] bmp;}
  32. };
  33. namespace BitmapHandler
  34. {
  35. extern CLodHandler *bitmaph;
  36. SDL_Surface * loadBitmap(std::string fname, bool setKey=false);
  37. };