I have a project where I need to display djvu schemas in browser.
I found this old library on Github which, as far as I understood, converts djvu files to bmp and then puts them into canvas element.
As I said, library is old(last commit was 5 years ago), so I need to make some corrections. Main problem is that lib uses obsolete BlobBuilder.
Steps I made to solve this problem:
- Decompress this library via Chrome DevTools
- Initial error is at line 3774
var c = "undefined" != typeof MozBlobBuilder ? MozBlobBuilder : "undefined" != typeof WebKitBlobBuilder ? WebKitBlobBuilder : console.log("warning: cannot build blobs") - I commented out this line
- Next, I commented out line
c = new c;and some of following lines too.
So, now it looks this way(variable I is array buffer, and ololo1 and ololo2 are some kind of offset and limit)
var c = new Blob(new Uint8Array(new Uint8Array(I,ololo1,ololo2))) , b = b.createObjectURL(c) , c = document.getElementById(kb) , f = c.getContext("2d") , h = new Image , g = a[Ea >> 2] , i = a[Fa >> 2] , j = c.width , k = Math.round(i * j / g); h.onload = function() { var a = g / j; 4 < a && (a = 4); 1 > a && (a = 1); f.globalAlpha = 1; for (N = 0; N < a; N++) f.drawImage(h, N, N, g - a + N, i - a + N, 0, 0, j, k), f.globalAlpha *= 1 - 1 / a; R(h.complete, "Image /bmp.bmp could not be decoded") } ; h.onerror = function(errorMsg, url, lineNumber, column, errorObj) { console.log(errorMsg, url, lineNumber, column, errorObj); console.log("Image /bmp.bmp could not be decoded!") } ; And now I stuck at error "Image /bmp.bmp could not be decoded!"(throwed in h.onerror handler).
So, my question is: what I am doing wrong?
c.append((new Uint8Array(new Uint8Array(I,ololo1,ololo2))).buffer). I don't see why the author nested his Uint8array inside an new one... You should be fine with just newBlob([new Uint8Array(I,ololo1,ololo2)]);