Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
1.7 KiB

  1. //
  2. // mxToolKit (c) 1999 by Mete Ciragan
  3. //
  4. // file: mxImage.h
  5. // implementation: all
  6. // last modified: Apr 15 1999, Mete Ciragan
  7. // copyright: The programs and associated files contained in this
  8. // distribution were developed by Mete Ciragan. The programs
  9. // are not in the public domain, but they are freely
  10. // distributable without licensing fees. These programs are
  11. // provided without guarantee or warrantee expressed or
  12. // implied.
  13. //
  14. #ifndef INCLUDED_MXIMAGE
  15. #define INCLUDED_MXIMAGE
  16. #ifndef byte
  17. typedef unsigned char byte;
  18. #endif // byte
  19. #ifndef word
  20. typedef unsigned short word;
  21. #endif // word
  22. class mxImage
  23. {
  24. public:
  25. int width;
  26. int height;
  27. int bpp;
  28. void *data;
  29. void *palette;
  30. // CREATORS
  31. mxImage () : width (0), height (0), bpp (0), data (0), palette (0)
  32. {
  33. }
  34. mxImage (int w, int h, int bpp)
  35. {
  36. create (w, h, bpp);
  37. }
  38. virtual ~mxImage ()
  39. {
  40. destroy ();
  41. }
  42. // MANIPULATORS
  43. bool create (int w, int h, int pixelSize)
  44. {
  45. if (data)
  46. delete[] data;
  47. if (palette)
  48. delete[] palette;
  49. data = new byte[w * h * pixelSize / 8];
  50. if (!data)
  51. return false;
  52. // allocate a palette for 8-bit images
  53. if (pixelSize == 8)
  54. {
  55. palette = new byte[768];
  56. if (!palette)
  57. {
  58. delete[] data;
  59. return false;
  60. }
  61. }
  62. else
  63. palette = 0;
  64. width = w;
  65. height = h;
  66. bpp = pixelSize;
  67. return true;
  68. }
  69. void destroy ()
  70. {
  71. if (data)
  72. delete[] data;
  73. if (palette)
  74. delete[] palette;
  75. data = palette = 0;
  76. width = height = bpp = 0;
  77. }
  78. private:
  79. // NOT IMPLEMENTED
  80. mxImage (const mxImage&);
  81. mxImage& operator= (const mxImage&);
  82. };
  83. #endif // INCLUDED_MXIMAGE