CBitmapHandler.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #ifndef __CBITMAPHANDLER_H__
  2. #define __CBITMAPHANDLER_H__
  3. #include "../global.h"
  4. struct SDL_Surface;
  5. class CLodHandler;
  6. /*
  7. * CBitmapHandler.h, part of VCMI engine
  8. *
  9. * Authors: listed in file AUTHORS in main folder
  10. *
  11. * License: GNU General Public License v2.0 or later
  12. * Full text of license available in license.txt file, in main folder
  13. *
  14. */
  15. enum Epcxformat {PCX8B, PCX24B};
  16. struct BMPPalette
  17. {
  18. unsigned char R,G,B,F;
  19. };
  20. struct BMPHeader
  21. {
  22. int fullSize, _h1, _h2, _h3, _c1, _c2, _c3, _c4, x, y,
  23. dataSize1, dataSize2; //DataSize=X*Y+2*Y
  24. unsigned char _c5[8];
  25. void print(std::ostream & out);
  26. BMPHeader(){_h1=_h2=0;for(int i=0;i<8;i++)_c5[i]=0;};
  27. };
  28. class CPCXConv
  29. {
  30. public:
  31. unsigned char * pcx, *bmp;
  32. int pcxs, bmps;
  33. void fromFile(std::string path);
  34. void saveBMP(std::string path);
  35. void openPCX(char * PCX, int len);
  36. void convert();
  37. SDL_Surface * getSurface(); //for standard H3 PCX
  38. //SDL_Surface * getSurfaceZ(); //for ZSoft PCX
  39. CPCXConv(){pcx=bmp=NULL;pcxs=bmps=0;}; //c-tor
  40. ~CPCXConv(){if (pcxs) delete[] pcx; if(bmps) delete[] bmp;} //d-tor
  41. };
  42. namespace BitmapHandler
  43. {
  44. SDL_Surface * loadBitmap(std::string fname, bool setKey=false);
  45. };
  46. #endif // __CBITMAPHANDLER_H__