fix some problems

This commit is contained in:
Kulikova Svetlana
2021-10-04 15:02:16 +03:00
parent e3fa8c53bf
commit d9217329eb
18 changed files with 229 additions and 243 deletions

View File

@ -89,10 +89,10 @@ void CDjVuFile::DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* p
if (m_pImplementation)
m_pImplementation->DrawPageOnRenderer(pRenderer, nPageIndex, pBreak);
}
BYTE* CDjVuFile::ConvertToPixels(int nPageIndex, int nRasterW, int nRasterH)
BYTE* CDjVuFile::ConvertToPixels(int nPageIndex, int nRasterW, int nRasterH, bool bIsFlip)
{
if (m_pImplementation)
return m_pImplementation->ConvertToPixels(nPageIndex, nRasterW, nRasterH);
return m_pImplementation->ConvertToPixels(nPageIndex, nRasterW, nRasterH, bIsFlip);
return NULL;
}
void CDjVuFile::ConvertToRaster(int nPageIndex, const std::wstring& wsDstPath, int nImageType, const int nRasterW, const int nRasterH)
@ -112,13 +112,13 @@ BYTE* CDjVuFile::GetStructure()
return m_pImplementation->GetStructure();
return NULL;
}
BYTE* CDjVuFile::GetPageGlyphs(int nPageIndex, int nRasterW, int nRasterH)
BYTE* CDjVuFile::GetGlyphs(int nPageIndex, int nRasterW, int nRasterH)
{
if (m_pImplementation)
return m_pImplementation->GetPageGlyphs(nPageIndex, nRasterW, nRasterH);
return NULL;
}
BYTE* CDjVuFile::GetPageLinks (int nPageIndex, int nRasterW, int nRasterH)
BYTE* CDjVuFile::GetLinks (int nPageIndex, int nRasterW, int nRasterH)
{
if (m_pImplementation)
return m_pImplementation->GetPageLinks(nPageIndex, nRasterW, nRasterH);

View File

@ -67,13 +67,13 @@ public:
virtual int GetPagesCount();
virtual void GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY);
virtual void DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak);
virtual BYTE* ConvertToPixels(int nPageIndex, int nRasterW, int nRasterH);
virtual BYTE* ConvertToPixels(int nPageIndex, int nRasterW, int nRasterH, bool bIsFlip = false);
virtual void ConvertToRaster(int nPageIndex, const std::wstring& path, int nImageType, const int nRasterW = -1, const int nRasterH = -1);
void ConvertToPdf(const std::wstring& path);
#ifdef WASM_MODE
BYTE* GetStructure();
BYTE* GetPageGlyphs(int nPageIndex, int nRasterW, int nRasterH);
BYTE* GetPageLinks (int nPageIndex, int nRasterW, int nRasterH);
#ifdef BUILDING_WASM_MODULE
virtual BYTE* GetStructure();
virtual BYTE* GetGlyphs(int nPageIndex, int nRasterW, int nRasterH);
virtual BYTE* GetLinks (int nPageIndex, int nRasterW, int nRasterH);
#endif
};

View File

@ -223,7 +223,7 @@ void CDjVuFileImplementation::DrawPageOnRenderer(IRenderer* pRende
// белая страница
}
}
BYTE* CDjVuFileImplementation::ConvertToPixels(int nPageIndex, const int& nRasterW, const int& nRasterH)
BYTE* CDjVuFileImplementation::ConvertToPixels(int nPageIndex, const int& nRasterW, const int& nRasterH, bool bIsFlip)
{
if (!m_pApplicationFonts)
return NULL;
@ -252,7 +252,7 @@ BYTE* CDjVuFileImplementation::ConvertToPixels(int nPageIndex, cons
oFrame.put_Data(pBgraData);
oFrame.put_Width(nWidth);
oFrame.put_Height(nHeight);
oFrame.put_Stride(-4 * nWidth);
oFrame.put_Stride((bIsFlip ? 4 : -4) * nWidth);
pRenderer->CreateFromBgraFrame(&oFrame);
pRenderer->SetSwapRGB(true);

View File

@ -76,7 +76,7 @@ public:
int GetPagesCount() const;
void GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY) const;
void DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak);
BYTE* ConvertToPixels(int nPageIndex, const int& nRasterW = -1, const int& nRasterH = -1);
BYTE* ConvertToPixels(int nPageIndex, const int& nRasterW = -1, const int& nRasterH = -1, bool bIsFlip = false);
void ConvertToRaster(int nPageIndex, const std::wstring& wsDstPath, int nImageType, const int& nRasterW = -1, const int& nRasterH = -1);
void ConvertToPdf(const std::wstring& wsDstPath);
#ifdef WASM_MODE

View File

@ -97,7 +97,7 @@
var data = new Uint8Array(arrayBuffer);
var _stream = Module["_malloc"](data.length);
Module["HEAP8"].set(data, _stream);
this.nativeFile = Module["_DJVU_Load"](_stream, data.length);
this.nativeFile = Module["_Open"](_stream, data.length);
Module["_free"](_stream);
return this.getInfo();
};
@ -106,7 +106,7 @@
if (!this.nativeFile)
return false;
var _info = Module["_XPS_GetInfo"](this.nativeFile);
var _info = Module["_GetInfo"](this.nativeFile);
if (!_info)
return false;
@ -124,11 +124,11 @@
};
CFile.prototype.getPagePixmap = function(pageIndex, width, height)
{
return Module["_XPS_GetPixmap"](this.nativeFile, pageIndex, width, height);
return Module["_GetPixmap"](this.nativeFile, pageIndex, width, height);
};
CFile.prototype.getGlyphs = function(pageIndex, width, height)
{
var glyphs = Module["_DJVU_GetGlyphs"](this.nativeFile, pageIndex, width, height);
var glyphs = Module["_GetGlyphs"](this.nativeFile, pageIndex, width, height);
if (glyphs == null)
return;
var lenArray = new Int32Array(Module["HEAP8"].buffer, glyphs, 4);
@ -176,12 +176,12 @@
this.pages[pageIndex].Lines[Line].Glyphs[0].Y = _Y + _H;
this.pages[pageIndex].Lines[Line].Glyphs[0].fontSize = _H;
}
Module["_XPS_Delete"](glyphs);
Module["_free"](glyphs);
};
CFile.prototype.getLinks = function(pageIndex, width, height)
{
var res = [];
var ext = Module["_DJVU_GetLinks"](this.nativeFile, pageIndex, width, height);
var ext = Module["_GetLinks"](this.nativeFile, pageIndex, width, height);
var lenArray = new Int32Array(Module["HEAP8"].buffer, ext, 4);
if (lenArray == null)
return res;
@ -218,13 +218,13 @@
res.push({ X : _X, Y : _Y, W : _W, H : _H, Link : _Link});
}
Module["_XPS_Delete"](ext);
Module["_free"](ext);
return res;
};
CFile.prototype.structure = function()
{
var res = [];
var str = Module["_DJVU_GetStructure"](this.nativeFile);
var str = Module["_GetStructure"](this.nativeFile);
var lenArray = new Int32Array(Module["HEAP8"].buffer, str, 4);
if (lenArray == null)
return res;
@ -253,12 +253,12 @@
res.push({ page : _Page, level : _Level, Y : 0, description : _Description});
}
Module["_XPS_Delete"](str);
Module["_free"](str);
return res;
};
CFile.prototype.close = function()
{
Module["_XPS_Close"](this.nativeFile);
Module["_Close"](this.nativeFile);
this.nativeFile = 0;
this.pages = [];
};
@ -268,7 +268,7 @@
};
CFile.prototype.free = function(pointer)
{
Module["_XPS_Delete"](pointer);
Module["_free"](pointer);
};
window["AscViewer"].DjVuFile = CFile;

View File

@ -14,11 +14,11 @@ base.create_dir("./deploy")
base.cmd_in_dir("./../../DesktopEditor/graphics/pro/js", "python", ["make.py"])
# finalize
if base.is_exist("./../../DesktopEditor/graphics/pro/js/deploy/xps_djvu_pdf.wasm"):
if base.is_exist("./../../DesktopEditor/graphics/pro/js/deploy/drawingfile.wasm"):
base.copy_file("./../../DesktopEditor/graphics/pro/js/deploy/xps.js", "./deploy/xps.js")
base.copy_file("./../../DesktopEditor/graphics/pro/js/deploy/djvu.js", "./deploy/djvu.js")
base.copy_file("./../../DesktopEditor/graphics/pro/js/deploy/pdf.js", "./deploy/pdf.js")
base.copy_file("./../../DesktopEditor/graphics/pro/js/deploy/xps_djvu_pdf.wasm", "./deploy/xps_djvu_pdf.wasm")
base.copy_file("./../../DesktopEditor/graphics/pro/js/deploy/drawingfile.wasm", "./deploy/drawingfile.wasm")
else:
print("make.py error")
base.copy_dir("./all_files_test/xps_djvu", "./deploy")