TGAlib.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /****************************************************************************
  2. Copyright (c) 2010-2012 cocos2d-x.org
  3. Copyright (c) 2013-2016 Chukong Technologies Inc.
  4. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  5. http://www.cocos2d-x.org
  6. Permission is hereby granted, free of charge, to any person obtaining a copy
  7. of this software and associated documentation files (the "Software"), to deal
  8. in the Software without restriction, including without limitation the rights
  9. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. copies of the Software, and to permit persons to whom the Software is
  11. furnished to do so, subject to the following conditions:
  12. The above copyright notice and this permission notice shall be included in
  13. all copies or substantial portions of the Software.
  14. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. THE SOFTWARE.
  21. ****************************************************************************/
  22. #ifndef __SUPPORT_DATA_SUPPORT_TGALIB_H__
  23. #define __SUPPORT_DATA_SUPPORT_TGALIB_H__
  24. /// @cond DO_NOT_SHOW
  25. namespace cocos2d {
  26. enum {
  27. TGA_OK,
  28. TGA_ERROR_FILE_OPEN,
  29. TGA_ERROR_READING_FILE,
  30. TGA_ERROR_INDEXED_COLOR,
  31. TGA_ERROR_MEMORY,
  32. TGA_ERROR_COMPRESSED_FILE,
  33. };
  34. /** TGA format */
  35. typedef struct sImageTGA {
  36. int status;
  37. unsigned char type, pixelDepth;
  38. /** map width */
  39. signed short width;
  40. /** map height */
  41. signed short height;
  42. /** raw data */
  43. unsigned char *imageData;
  44. int flipped;
  45. } tImageTGA;
  46. /// load the image header fields. We only keep those that matter!
  47. bool tgaLoadHeader(unsigned char *buffer, unsigned long bufSize, tImageTGA *info);
  48. /// loads the image pixels. You shouldn't call this function directly
  49. bool tgaLoadImageData(unsigned char *buffer, unsigned long bufSize, tImageTGA *info);
  50. /// this is the function to call when we want to load an image buffer.
  51. tImageTGA* tgaLoadBuffer(unsigned char* buffer, long size);
  52. /// this is the function to call when we want to load an image
  53. tImageTGA * tgaLoad(const char *filename);
  54. // /converts RGB to grayscale
  55. void tgaRGBtogreyscale(tImageTGA *info);
  56. /// releases the memory used for the image
  57. void tgaDestroy(tImageTGA *info);
  58. }//namespace cocos2d
  59. /// @endcond
  60. #endif // __SUPPORT_DATA_SUPPORT_TGALIB_H__