CBitmapHandler.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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()
  27. {
  28. _h1=_h2=0;
  29. for(int i=0;i<8;i++)
  30. _c5[i]=0;
  31. }
  32. };
  33. class CPCXConv
  34. {
  35. public:
  36. unsigned char * pcx, *bmp;
  37. int pcxs, bmps;
  38. void fromFile(std::string path);
  39. void saveBMP(std::string path);
  40. void openPCX(char * PCX, int len);
  41. SDL_Surface * getSurface() const; //for standard H3 PCX
  42. //SDL_Surface * getSurfaceZ(); //for ZSoft PCX
  43. CPCXConv() //c-tor
  44. : pcx(NULL), bmp(NULL), pcxs(0), bmps(0)
  45. {}
  46. ~CPCXConv() //d-tor
  47. {
  48. if (pcxs) delete[] pcx;
  49. if (bmps) delete[] bmp;
  50. }
  51. };
  52. namespace BitmapHandler
  53. {
  54. SDL_Surface * loadBitmap(std::string fname, bool setKey=true);
  55. };
  56. #endif // __CBITMAPHANDLER_H__