CBitmapHandler.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #pragma once
  2. struct SDL_Surface;
  3. class CLodHandler;
  4. /*
  5. * CBitmapHandler.h, part of VCMI engine
  6. *
  7. * Authors: listed in file AUTHORS in main folder
  8. *
  9. * License: GNU General Public License v2.0 or later
  10. * Full text of license available in license.txt file, in main folder
  11. *
  12. */
  13. enum Epcxformat {PCX8B, PCX24B};
  14. /// Struct which stands for a simple rgba palette
  15. struct BMPPalette
  16. {
  17. ui8 R,G,B,F;
  18. };
  19. /// Class which converts pcx to bmp images
  20. class CPCXConv
  21. {
  22. public:
  23. ui8 * pcx, *bmp;
  24. int pcxs, bmps;
  25. void fromFile(std::string path);
  26. void saveBMP(std::string path) const;
  27. void openPCX(char * PCX, int len);
  28. SDL_Surface * getSurface() const; //for standard H3 PCX
  29. //SDL_Surface * getSurfaceZ(); //for ZSoft PCX
  30. CPCXConv() //c-tor
  31. : pcx(NULL), bmp(NULL), pcxs(0), bmps(0)
  32. {}
  33. ~CPCXConv() //d-tor
  34. {
  35. if (pcxs) delete[] pcx;
  36. if (bmps) delete[] bmp;
  37. }
  38. };
  39. namespace BitmapHandler
  40. {
  41. //Load file from specific LOD
  42. SDL_Surface * loadBitmapFromLod(CLodHandler *lod, std::string fname, bool setKey=true);
  43. //Load file from any LODs
  44. SDL_Surface * loadBitmap(std::string fname, bool setKey=true);
  45. };