/xbmc/guilib/JpegIO.h

http://github.com/xbmc/xbmc · C Header · 64 lines · 35 code · 9 blank · 20 comment · 0 complexity · 68c8cb25fb95cf48a28ead1b56c10946 MD5 · raw file

  1. /*
  2. * Copyright (C) 2005-2013 Team XBMC
  3. * http://xbmc.org
  4. *
  5. * This Program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2, or (at your option)
  8. * any later version.
  9. *
  10. * This Program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with XBMC; see the file COPYING. If not, see
  17. * <http://www.gnu.org/licenses/>.
  18. *
  19. */
  20. #ifndef GUILIB_JPEGIO_H
  21. #define GUILIB_JPEGIO_H
  22. #ifdef TARGET_WINDOWS
  23. #define XMD_H
  24. #pragma comment(lib, "turbojpeg-static.lib")
  25. #endif
  26. #include <jpeglib.h>
  27. #include "utils/StdString.h"
  28. #include "iimage.h"
  29. class CJpegIO : public IImage
  30. {
  31. public:
  32. CJpegIO();
  33. ~CJpegIO();
  34. bool Open(const CStdString& m_texturePath, unsigned int minx=0, unsigned int miny=0, bool read=true);
  35. bool Read(unsigned char* buffer, unsigned int bufSize, unsigned int minx, unsigned int miny);
  36. bool CreateThumbnail(const CStdString& sourceFile, const CStdString& destFile, int minx, int miny, bool rotateExif);
  37. bool CreateThumbnailFromMemory(unsigned char* buffer, unsigned int bufSize, const CStdString& destFile, unsigned int minx, unsigned int miny);
  38. static bool CreateThumbnailFromSurface(unsigned char* buffer, unsigned int width, unsigned int height, unsigned int format, unsigned int pitch, const CStdString& destFile);
  39. void Close();
  40. // methods for the imagefactory
  41. virtual bool Decode(const unsigned char *pixels, unsigned int pitch, unsigned int format);
  42. virtual bool LoadImageFromMemory(unsigned char* buffer, unsigned int bufSize, unsigned int width, unsigned int height);
  43. virtual bool CreateThumbnailFromSurface(unsigned char* bufferin, unsigned int width, unsigned int height, unsigned int format, unsigned int pitch, const CStdString& destFile,
  44. unsigned char* &bufferout, unsigned int &bufferoutSize);
  45. virtual void ReleaseThumbnailBuffer();
  46. protected:
  47. static void jpeg_error_exit(j_common_ptr cinfo);
  48. static unsigned int GetExifOrientation(unsigned char* exif_data, unsigned int exif_data_size);
  49. unsigned char *m_inputBuff;
  50. unsigned int m_inputBuffSize;
  51. struct jpeg_decompress_struct m_cinfo;
  52. CStdString m_texturePath;
  53. unsigned char* m_thumbnailbuffer;
  54. };
  55. #endif