| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- #ifndef JPEGIMAGE_H
- #define JPEGIMAGE_H
- #include <string>
- #include <vector>
- #include <jpeglib.h>
- namespace Image {
- class JpegImage
- {
- public:
- JpegImage();
- void SetImageData(const std::string& data);
- unsigned int Width() const;
- unsigned int Height() const;
- unsigned int StrideX() const;
- unsigned int StrideY() const;
- const std::vector<char>& Data() const;
- private:
- struct SourceMgr
- {
- struct jpeg_source_mgr pub;
- const JOCTET *data;
- size_t len;
- };
- typedef SourceMgr* SourceMgrPtr;
- private:
- static void InitSource(j_decompress_ptr pCinfo);
- static boolean FillInputBuffer(j_decompress_ptr pCinfo);
- static void SkipInputData(j_decompress_ptr pCinfo, long numBytes);
- static void TermSource(j_decompress_ptr pCinfo);
- void SetSourceMgr(j_decompress_ptr pCinfo, const char* pData, size_t len) const;
- void DecompressImage(const char* pData, size_t len);
- private:
- unsigned int m_width;
- unsigned int m_height;
- unsigned int m_strideX;
- unsigned int m_strideY;
- std::vector<char> m_data;
- };
- } // namespace Image
- #endif // JPEGIMAGE_H
|