From 89afb631323666090a147ed7c07f61f008e31f1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bojan=20=C5=A0ernek?= Date: Mon, 29 Jan 2018 20:43:46 +0100 Subject: [PATCH] added support for writing of `double` tag types doubles: big endian 64-bit floating point values --- UTIF.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/UTIF.js b/UTIF.js index 28cc55c..72a50b5 100644 --- a/UTIF.js +++ b/UTIF.js @@ -524,7 +524,7 @@ UTIF._writeIFD = function(bin, data, offset, ifd) bin.writeUshort(data, offset, type); offset+=2; bin.writeUint (data, offset, num ); offset+=4; - var dlen = [-1, 1,1,2,4,8][type] * num; + var dlen = [-1, 1, 1, 2, 4, 8, 0, 0, 0, 0, 0, 0, 8][type] * num; var toff = offset; if(dlen>4) { bin.writeUint(data, offset, eoff); toff=eoff; } @@ -532,6 +532,7 @@ UTIF._writeIFD = function(bin, data, offset, ifd) if(type==3) { for(var i=0; i4) { dlen += (dlen&1); eoff += dlen; } offset += 4; @@ -626,6 +627,12 @@ UTIF._binBE = { writeUshort: function(buff, p, n) { buff[p] = (n>> 8)&255; buff[p+1] = n&255; }, writeUint : function(buff, p, n) { buff[p] = (n>>24)&255; buff[p+1] = (n>>16)&255; buff[p+2] = (n>>8)&255; buff[p+3] = (n>>0)&255; }, writeASCII : function(buff, p, s) { for(var i = 0; i < s.length; i++) buff[p+i] = s.charCodeAt(i); } + writeDouble: function(buff, p, n) { + UTIF._binBE.fl64[0] = n; + for (var i = 0; i < 8; i++) { + buff[p + i] = UTIF._binBE.ui8[7 - i]; + } + } } UTIF._binBE.ui8 = new Uint8Array (8); UTIF._binBE.i16 = new Int16Array (UTIF._binBE.ui8.buffer); @@ -658,4 +665,4 @@ UTIF._copyTile = function(tb, tw, th, b, w, h, xoff, yoff) } })(UTIF, pako); -})(); \ No newline at end of file +})();