mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Fix bugs
This commit is contained in:
@ -313,6 +313,75 @@
|
||||
this.engine = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get image type
|
||||
* @returns {Number}
|
||||
*/
|
||||
ZLib.prototype.getImageType = function(path)
|
||||
{
|
||||
let fileData = this.getFile(path);
|
||||
return Module["_Image_GetFormat"](this.files[path].p + 4, fileData.length);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get image in needed format
|
||||
* @returns {Uint8Array}
|
||||
*/
|
||||
ZLib.prototype.getImageAsFormat = function(path, format)
|
||||
{
|
||||
let fileData = this.getFile(path);
|
||||
let encodedData = Module["_Raster_Encode"](this.files[path].p + 4, fileData.length, format);
|
||||
let encodedSize = Module["_Raster_GetEncodedSize"](encodedData);
|
||||
let encodedBuffer = Module["_Raster_GetEncodedBuffer"](encodedData);
|
||||
|
||||
let copyData = new Uint8Array(encodedSize);
|
||||
copyData.set(new Uint8Array(Module["HEAP8"].buffer, encodedBuffer, encodedSize));
|
||||
|
||||
Module["_Raster_DestroyEncodedData"](encodedData);
|
||||
|
||||
return copyData;
|
||||
};
|
||||
/**
|
||||
* Get image as svg (for simple test)
|
||||
* @returns {string}
|
||||
*/
|
||||
ZLib.prototype.getImageAsSvg = function(path)
|
||||
{
|
||||
let fileData = this.getFile(path);
|
||||
let encodedData = Module["_Raster_Encode"](this.files[path].p + 4, fileData.length, 24);
|
||||
let encodedSize = Module["_Raster_GetEncodedSize"](encodedData);
|
||||
let encodedBuffer = Module["_Raster_GetEncodedBuffer"](encodedData);
|
||||
|
||||
let string = String.prototype.fromUtf8(new Uint8Array(Module["HEAP8"].buffer, encodedBuffer, encodedSize));
|
||||
|
||||
Module["_Raster_DestroyEncodedData"](encodedData);
|
||||
|
||||
return string;
|
||||
};
|
||||
/**
|
||||
* Get image blob for browser
|
||||
* @returns {Blob}
|
||||
*/
|
||||
ZLib.prototype.getImageBlob = function(path)
|
||||
{
|
||||
let imageType = this.getImageType(path);
|
||||
if (imageType != 10 && imageType != 21)
|
||||
{
|
||||
return new Blob([this.getFile(path)], {type:AscCommon.openXml.GetMimeType(AscCommon.GetFileExtension(path))});
|
||||
}
|
||||
|
||||
let fileData = this.getFile(path);
|
||||
let encodedData = Module["_Raster_Encode"](this.files[path].p + 4, fileData.length, 24);
|
||||
let encodedSize = Module["_Raster_GetEncodedSize"](encodedData);
|
||||
let encodedBuffer = Module["_Raster_GetEncodedBuffer"](encodedData);
|
||||
|
||||
let blob = new Blob([new Uint8Array(Module["HEAP8"].buffer, encodedBuffer, encodedSize)], {type : AscCommon.openXml.GetMimeType("svg")});
|
||||
|
||||
Module["_Raster_DestroyEncodedData"](encodedData);
|
||||
|
||||
return blob;
|
||||
};
|
||||
|
||||
window.AscCommon = window.AscCommon || {};
|
||||
window.AscCommon.CZLibEngineJS = ZLib;
|
||||
window.onZlibEngineInit = function()
|
||||
|
||||
Reference in New Issue
Block a user