CBitmapHandler.h 987 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #ifndef __CBITMAPHANDLER_H__
  2. #define __CBITMAPHANDLER_H__
  3. #include "../global.h"
  4. struct SDL_Surface;
  5. class CLodHandler;
  6. enum Epcxformat {PCX8B, PCX24B};
  7. struct BMPPalette
  8. {
  9. unsigned char R,G,B,F;
  10. };
  11. struct BMPHeader
  12. {
  13. int fullSize, _h1, _h2, _h3, _c1, _c2, _c3, _c4, x, y,
  14. dataSize1, dataSize2; //DataSize=X*Y+2*Y
  15. unsigned char _c5[8];
  16. void print(std::ostream & out);
  17. BMPHeader(){_h1=_h2=0;for(int i=0;i<8;i++)_c5[i]=0;};
  18. };
  19. class CPCXConv
  20. {
  21. public:
  22. unsigned char * pcx, *bmp;
  23. int pcxs, bmps;
  24. void fromFile(std::string path);
  25. void saveBMP(std::string path);
  26. void openPCX(char * PCX, int len);
  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. };
  38. #endif // __CBITMAPHANDLER_H__