!249 tif解析更加智能化 支持被修改的图片格式

Merge pull request !249 from 高雄/N/A
pull/243/MERGE
kailing 1 year ago committed by Gitee
commit a95dda6c20
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

@ -28,6 +28,21 @@
</#if> </#if>
<div id="tiff"></div> <div id="tiff"></div>
<script> <script>
String.prototype.startsWithh = function(str) {
var reg = new RegExp("^" + str);
return reg.test(this);
}
String.prototype.endsWithh = function(str) {
var reg = new RegExp(str + "$");
return reg.test(this);
}
var url = '${finalUrl}';
var baseUrl = '${baseUrl}'.endsWithh('/') ? '${baseUrl}' : '${baseUrl}' + '/';
if (!url.startsWithh(baseUrl)) {
url = baseUrl + 'getCorsFile?urlPath=' + encodeURIComponent(Base64.encode(url));
}
var myp = document.getElementById('tiff');
let pages; let pages;
let p; let p;
let resp; let resp;
@ -42,6 +57,14 @@
try{ try{
imageData = ctx.createImageData(canvas.width, canvas.height); imageData = ctx.createImageData(canvas.width, canvas.height);
} catch(e){ } catch(e){
if (e.message.indexOf("CanvasRenderingContext2D"))
{
var imgObjj = new Image();
imgObjj.src = url;
myp.appendChild(imgObjj);
console.log("错误:" + e);
return;
}
console.log("错误:" + e); console.log("错误:" + e);
var html = ""; var html = "";
html += "<head>"; html += "<head>";
@ -86,9 +109,9 @@ html += " <p>有任何疑问请加入kk开源社区知识星球咨询<a
html += "</div>"; html += "</div>";
html += "</body>"; html += "</body>";
html += "</html>"; html += "</html>";
document.write(html); document.write(html);
document.close(); document.close();
return; return;
} }
for (let i = 0; i < rgba.length; i++) { for (let i = 0; i < rgba.length; i++) {
imageData.data[i] = rgba[i]; imageData.data[i] = rgba[i];
@ -99,7 +122,6 @@ return;
if (++p < pages.length) { if (++p < pages.length) {
imgObj.onload = loadOne; imgObj.onload = loadOne;
} }
var myp = document.getElementById('tiff');
myp.appendChild(imgObj); myp.appendChild(imgObj);
} }
@ -109,22 +131,6 @@ return;
p = 0; p = 0;
loadOne(); loadOne();
} }
String.prototype.startsWithh = function(str) {
var reg = new RegExp("^" + str);
return reg.test(this);
}
String.prototype.endsWithh = function(str) {
var reg = new RegExp(str + "$");
return reg.test(this);
}
var url = '${finalUrl}';
var baseUrl = '${baseUrl}'.endsWithh('/') ? '${baseUrl}' : '${baseUrl}' + '/';
if (!url.startsWithh(baseUrl)) {
url = baseUrl + 'getCorsFile?urlPath=' + encodeURIComponent(Base64.encode(url));
}
const xhr = new XMLHttpRequest(); const xhr = new XMLHttpRequest();
xhr.open('GET', url); xhr.open('GET', url);
xhr.responseType = 'arraybuffer'; xhr.responseType = 'arraybuffer';

Loading…
Cancel
Save