code_app/modules/imgfmt/HGOfdImpl.hpp

61 lines
1.4 KiB
C++

#ifndef __HGOFDIMPL_HPP__
#define __HGOFDIMPL_HPP__
#include "HGOfd.h"
extern "C"
{
#include "zip.h"
};
#include "tinyxml2.h"
#include <vector>
#include <list>
#include <string>
class HGOfdReaderImpl
{
public:
HGOfdReaderImpl();
~HGOfdReaderImpl();
HGResult Open(const HGChar* fileName);
HGResult Close();
HGResult GetPageCount(HGUInt* count);
HGResult GetPageInfo(HGUInt page, HGOfdPageInfo* info);
HGResult LoadImage(HGUInt page, HGFloat xScale, HGFloat yScale,
HGUInt imgType, HGUInt imgOrigin, HGImage* image);
private:
bool ReadXml(const char *name, std::string &content);
bool ReadJpeg(const char* name, HGJpegLoadInfo *info, HGFloat xScale, HGFloat yScale, HGUInt imgType, HGUInt imgOrigin, HGImage* image);
private:
zip* m_zip;
std::vector<std::string> m_contentNames;
};
class HGOfdImageWriterImpl
{
public:
HGOfdImageWriterImpl();
~HGOfdImageWriterImpl();
HGResult Open(const HGChar* fileName);
HGResult Close();
HGResult SaveJpegImage(HGImage image, const HGJpegSaveInfo* info);
private:
bool AddOfdXml();
bool AddDocXml();
bool AddDocResXml();
bool AddPublicResXml();
bool AddXmlFile(tinyxml2::XMLDocument &xmlDoc, const HGChar *name);
bool AddJpegImageFile(HGImage image, const HGJpegSaveInfo* info, const HGChar* name);
bool AddContentXmlFile(HGUInt index, HGFloat physicalWidth, HGFloat physicalHeight);
private:
zip* m_zip;
std::list<std::string> m_tmpFiles;
HGUInt m_curImgIndex;
};
#endif /* __HGOFDIMPL_HPP__ */