-
Notifications
You must be signed in to change notification settings - Fork 0
/
xface.js
619 lines (577 loc) · 28 KB
/
xface.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mnenhy.
*
* The Initial Developer of the Original Code is Karsten Düsterloh <mnenhy@tprac.de>.
*
* Portions created by the Initial Developer are Copyright (C) 2002-2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* James Ashton <jaa@cs.su.oz.au> (author of the original C source of 'uncompface')
* Andrew Taylor <ataylor@its.to> (author of the Javascript version of 'uncompface')
* Karsten Düsterloh <mnenhy@tprac.de> (optimizations for use with Mnenhy)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
// +-
// | the contents of this file will be loaded into the Mnenhy.headers.xface.* context!
// | ie. foo() is available as goMnenhy.headers.xface.foo()
// +-
// What is an X-Face?
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
// An X-Face is a black/white icon of 48*48 pixels whose compressed data will be
// transported as a text header in mails or news postings.
//
// How to compress an X-Face? (XXX not quite complete yet)
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
// The icon is divided into 9 areas of 16*16 pixels that will be compressed independently.
// Each area can be entirely black or entirely white or some shade of grey. If grey, it will
// be divided into 4 squares of 8*8 pixels that, again, can be black, white or grey.
// This will be iterated until such a block is either black or white or 2*2.
//
// How to encode the X-Face?
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
// The compressed X-Face needs at most 288 bytes (48*48/8), but due to compression, the size
// is usually much smaller. Nevertheless, this binary data will not pass certain servers
// unharmed, so it needs to be recoded into 7-bit data, using only the 94 printable characters
// from '!' (0x21) to '~' (0x7E). To achieve this, the binary data can be regarded as a single,
// large number with a representation to base 256. This representation will then be converted
// to use base 94, i.e. each 'digit' now has values from 0 to 93. To become printable, each
// digit is added an offset of '!' (0x21).
// The resulting string is set as the X-Face header.
var LENGTH=48;
var PIXELS=(LENGTH * LENGTH);
var FIRSTPRINT = '!'.charCodeAt(0);
var LASTPRINT = '~'.charCodeAt(0);
var NUMPRINTS = (LASTPRINT - FIRSTPRINT + 1);
var BITSPERWORD=8;
var WORDCARRY=(1 << BITSPERWORD);
var WORDMASK=(WORDCARRY - 1);
var MAXWORDS=Math.floor(((PIXELS * 2 + BITSPERWORD - 1) / BITSPERWORD));
var BLACK=0;
var GREY =1;
var WHITE=2;
var B = {b_first: 0, b_words: 0, b_word: new Array(MAXWORDS)};
var F = new Array(PIXELS);
var levels =
[ /* BLACK GREY WHITE */
[{p_offset:255, p_range:1 }, {p_offset:0, p_range:251}, {p_offset:251, p_range:4 }],/* Top of tree almost always grey */
[{p_offset:255, p_range:1 }, {p_offset:0, p_range:200}, {p_offset:200, p_range:55 }],
[{p_offset:223, p_range:33 }, {p_offset:0, p_range:159}, {p_offset:159, p_range:64 }],
[{p_offset:0, p_range:131}, {p_offset:0, p_range:0 }, {p_offset:131, p_range:125}] /* Grey disallowed at bottom */
];
/* At the bottom of the octree 2x2 elements are considered black if any
* pixel is black. The probabilities below give the distribution of the
* 16 possible 2x2 patterns. All white is not really a possibility and
* has a probability range of zero. Again, experimentally derived data */
var freqs =
[
{p_offset:0, p_range:0 }, {p_offset:0, p_range:38}, {p_offset:38, p_range:38}, {p_offset:152, p_range:13},
{p_offset:76, p_range:38}, {p_offset:165, p_range:13}, {p_offset:178, p_range:13}, {p_offset:230, p_range:6 },
{p_offset:114, p_range:38}, {p_offset:191, p_range:13}, {p_offset:204, p_range:13}, {p_offset:236, p_range:6 },
{p_offset:217, p_range:13}, {p_offset:242, p_range:6 }, {p_offset:248, p_range:5 }, {p_offset:253, p_range:3 }
];
// table for Gen()
var G =
{
g_00:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,1,1,0,0,0,1,1,1,1,0,1,1,1,1,1,0,0,0,0,0,1,0,1,0,0,0,1,0,1,1,1,0,0,0,0,0,1,0,1,0,0,0,0,1,1,1,1,
0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,1,0,0,0,0,1,1,1,1,1,1,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,1,1,0,1,1,1,1,1,1,1,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,
0,1,0,0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1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,
0,0,0,0,0,1,0,1,0,1,1,1,1,1,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,1,0,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,
0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,1,0,0,0,0,0,0,1,1,1,1,
0,0,0,0,0,1,1,1,0,0,0,1,1,1,1,1,0,0,0,0,0,1,1,1,0,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,0,1,1,1,1,1,1,
0,0,0,0,1,1,0,1,0,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,0,1,1,0,1,0,1,1,1,1,1,0,1,
0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1],
g_11:[0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,1,0,0,0,0,0,0,1,1,0,1,1,1,1,1,1,1],
g_21:[0,0,0,1,0,1,1,1],
g_31:[0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,1,0,1,0,1,0,1,1,1,0,1,1,1,1,1,1,1],
g_41:[0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,1,1,1,1,1,0,0,0,0,0,0,1,1,0,0,0,1,1,1,1,1,
0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
g_12:[0,1],
g_22:[0],
g_32:[0,0,0,1],
g_42:[0,0,0,1]
};
function BigMul(a) { // multiply B.b_word by a (B.b_word[0]=LSB)
var i;
if (a == 1 || !B.b_words)
return;
/* Treat this as a == WORDCARRY and just shift everything left a WORD */
if (!a) {
B.b_words++;
if (B.b_first > 0)
B.b_first--;
else
{
for (i = B.b_words - 1; i >= 1; i--)
B.b_word[i] = B.b_word[i - 1];
}
B.b_word[B.b_first] = 0;
return;
}
var c = 0;
var last = B.b_words + B.b_first - 1;
var word = B.b_word;
for (i = B.b_first; i <= last; i++) {
c += word[i] * a;
word[i] = (c & WORDMASK);
c >>= BITSPERWORD;
}
if (c)
word[B.b_first + B.b_words++] = c & WORDMASK;
}
function BigAdd(a) { // add a to B.b_word
var i;
a &= WORDMASK;
if (!a)
return;
var c = a;
var last = B.b_words + B.b_first - 1;
for(i = B.b_first; i <= last; i++) {
c += B.b_word[i];
B.b_word[i] = c & WORDMASK;
c >>= BITSPERWORD;
if (!c)
break;
}
if ((i > last) && c) {
B.b_word[i] = c & WORDMASK;
B.b_words++;
}
}
function BigPop(p) { // p is freqs oder levels[lev]
var r = B.b_word[B.b_first]; // r = LSB; B >> 8
B.b_first++;
B.b_words--;
var i = 0;
while ((r < p[i].p_offset) || (r >= p[i].p_range + p[i].p_offset))
i++;
BigMul(p[i].p_range);
BigAdd(r - p[i].p_offset);
return i;
}
function PopGreys(off, len) {
if (len > 3) {
len /= 2;
PopGreys(off, len);
PopGreys(off + len, len);
PopGreys(off + LENGTH * len, len);
PopGreys(off + LENGTH * len + len, len);
} else {
len = BigPop(freqs);
if (len & 1)
F[off] = 1;
if (len & 2)
F[off + 1] = 1;
if (len & 4)
F[off + LENGTH] = 1;
if (len & 8)
F[off + LENGTH + 1] = 1;
}
}
function UnCompress(off, len, lev) {
switch (BigPop(levels[lev])) {
case WHITE:
return;
case BLACK:
PopGreys(off, len);
return;
default :
len /= 2;
lev++;
UnCompress(off, len, lev);
UnCompress(off + len, len, lev);
UnCompress(off + len * LENGTH, len, lev);
UnCompress(off + len * LENGTH + len, len, lev);
return;
}
}
function UnCompAll(fbuf) {
var i;
B.b_words = B.b_first = 0;
// convert base 94 to base 256
var kl = fbuf.length;
for (i = 0; i < kl; ++i) {
BigMul(NUMPRINTS);
BigAdd(fbuf.charCodeAt(i) - FIRSTPRINT);
}
// empty icon
for (i = 0; i < PIXELS; i++)
F[i] = 0;
// uncompress
UnCompress(0, 16, 0);
UnCompress(16, 16, 0);
UnCompress(32, 16, 0);
UnCompress(768, 16, 0);
UnCompress(784, 16, 0);
UnCompress(800, 16, 0);
UnCompress(1536, 16, 0);
UnCompress(1552, 16, 0);
UnCompress(1568, 16, 0);
}
function Gen() {
var m, l, k, j, i, h=0;
for (j = 0; j < LENGTH; j++) {
for (i = 0; i < LENGTH; i++) {
k = 0;
for (l = i - 2; l <= i + 2; l++)
for (m = j - 2; m <= j; m++) {
if ((l >= i) && (m == j))
continue;
if ((l > 0) && (l <= LENGTH) && (m > 0))
k = F[l + m * LENGTH] ? k * 2 + 1 : k * 2;
}
switch (i) {
case 1 :
switch (j) {
case 1 : F[h] ^= G.g_22[k]; break;
case 2 : F[h] ^= G.g_21[k]; break;
default: F[h] ^= G.g_20[k]; break;
}
break;
case 2 :
switch (j) {
case 1 : F[h] ^= G.g_12[k]; break;
case 2 : F[h] ^= G.g_11[k]; break;
default: F[h] ^= G.g_10[k]; break;
}
break;
case LENGTH - 1 :
switch (j) {
case 1 : F[h] ^= G.g_42[k]; break;
case 2 : F[h] ^= G.g_41[k]; break;
default: F[h] ^= G.g_40[k]; break;
}
break;
case LENGTH :
switch (j) {
case 1 : F[h] ^= G.g_32[k]; break;
case 2 : F[h] ^= G.g_31[k]; break;
default: F[h] ^= G.g_30[k]; break;
}
break;
default :
switch (j) {
case 1 : F[h] ^= G.g_02[k]; break;
case 2 : F[h] ^= G.g_01[k]; break;
default: F[h] ^= G.g_00[k]; break;
}
break;
}
++h;
}
}
}
/*
function FaceURL(face) {
var i;
UnCompAll(face.replace(/[^!-~]/g, "")); // eliminate illegal chars
Gen();
var bmp = "BM\xBE\1\0\0\0\0\0\0>\0\0\0(\0\0\0\x30\0\0\0\x30\0\0\0\1\0\1\0\0\0\0\0\x80\1\0\0\xC4\x0E\0\0\xC4\x0E\0\0\0\0\0\0\0\0\0\0\xFF\xFF\xFF\0\0\0\0\0";
var ff = F.join("").replace(/(.{48})/g, "$1,").split(",").reverse().join("")
.replace(/(.{8})(.{8})(.{8})(.{8})(.{8})(.{8})/g,
function(s,a,b,c,d,e,f) {
return String.fromCharCode(parseInt(a,2))
+ String.fromCharCode(parseInt(b,2))
+ String.fromCharCode(parseInt(c,2))
+ String.fromCharCode(parseInt(d,2))
+ String.fromCharCode(parseInt(e,2))
+ String.fromCharCode(parseInt(f,2)) + "\0\0";
});
bmp = "data:image/bmp;base64," + btoa(bmp + ff);
return bmp;
}
*/
//
// PNG transformation
//
// call this only once, just use output with different xfaces!
function PNGFace()
{
// array of one byte strings, initialized to zero bytes
this.png = new Array(2444);
for (let n = 0; n < 2444; n++)
this.png[n] = String.fromCharCode(0);
this.Insert( 0, '\x00\x00\x00\rIHDR\x00\x00\x000\x00\x00\x000\b\x03');
this.Insert( 25, '\x00\x00\x00\x06PLTE');
this.Insert( 43, '\x00\x00\x00\x02tRNS');
this.Insert( 57, '\x00\x00\t;IDATx\xDA\x010\t\xCF\xF6');
this.Insert(2432, '\x00\x00\x00\x00IEND');
/* Table of CRCs of all 8-bit messages. */
this.crc32_table = new Array(256);
for (let n = 0; n < 256; n++)
{
let c = n;
for (let k = 0; k < 8; k++)
{
if (c & 1)
c = -306674912 ^ ((c >> 1) & 0x7fffffff);
else
c = (c >> 1) & 0x7fffffff;
}
this.crc32_table[n] = c;
}
}
// set color in PNG - with alpha in byte format (0-255)!
// index 0 = background
// index 1 = foreground
PNGFace.prototype.Color = function(index, asRGBA)
{
let oRGBA = asRGBA.split(",");
this.png[33+index*3+0] = String.fromCharCode(Number(oRGBA[0]));
this.png[33+index*3+1] = String.fromCharCode(Number(oRGBA[1]));
this.png[33+index*3+2] = String.fromCharCode(Number(oRGBA[2]));
this.png[51+index] = String.fromCharCode(Number(oRGBA[3]) * 255);
}
// insert string into array
PNGFace.prototype.Insert = function(offs, str)
{
for (let j = 0; j < str.length; ++j)
this.png[offs++] = str.charAt(j);
}
PNGFace.prototype.Insert4 = function(offs, w)
{
this.Insert(offs, String.fromCharCode((w>>24)&255, (w>>16)&255, (w>>8)&255, w&255));
}
// compute crc32 of the PNG chunks
PNGFace.prototype.CRC32 = function(offs, size)
{
let crc = -1; // initialize crc
for (let i = 4; i < size - 4; ++i)
crc = this.crc32_table[(crc ^ this.png[offs + i].charCodeAt(0)) & 0xff] ^ ((crc >> 8) & 0x00ffffff);
this.Insert4(offs + size - 4, crc ^ -1);
}
// output a PNG string
PNGFace.prototype.URL = function(xface)
{
// compute adler32 of output pixels + row filter bytes
let BASE = 65521; /* largest prime smaller than 65536 */
let NMAX = 5552; /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
let s1 = 1;
let s2 = 0;
let n = NMAX;
for (let y = 0; y < 48; ++y)
for (let x = -1; x < 48; ++x)
{
let i = y * 49 + x + 73;
if (x >= 0)
this.png[i] = String.fromCharCode(xface[x + y * 48]); // set X-Face dot
s1 += this.png[i].charCodeAt(0);
s2 += s1;
if (!(n -= 1))
{
s1 %= BASE;
s2 %= BASE;
n = NMAX;
}
}
s1 %= BASE;
s2 %= BASE;
this.Insert4(2424, (s2 << 16) | s1);
this.CRC32( 0, 25);
this.CRC32( 25, 18);
this.CRC32( 43, 14);
this.CRC32( 57, 2375);
this.CRC32(2432, 12);
// convert PNG to string
return "\211PNG\r\n\032\n"+this.png.join('');
}
function ReadCSSColor(aoComputedStyle, asColorName, asDefaultValue)
{
let sColor = aoComputedStyle.getPropertyCSSValue(asColorName).cssText;
if (/^rgba\(/.test(sColor))
{
// have rgba values
sColor = sColor.substr(5, sColor.length - 6);
}
else if (/^rgb\(/.test(sColor))
{
// only rgb values, assume opaque
sColor = sColor.substr(4, sColor.length - 5) + ",1";
}
else if (sColor == "transparent")
{
// special value
sColor = "0,0,0,0";
}
else
{
// default: plain opaque white
sColor = asDefaultValue;
}
return sColor;
}
//
// Create data URL for X-Face-PNG
//
let goPNGFace = new PNGFace();
function FaceURL(asFace, aoComputedStyle)
{
UnCompAll(asFace.replace(/[^!-~]/g, "")); // eliminate illegal chars
Gen();
// set colour values:
// #fromBuddyIconXFace
// {
// color: green;
// color: -moz-rgba(50%, 50%, 50%, 0.5);
// background-color: red;
// background-color: transparent;
// padding: 0 ! important;
// margin: 5px;
// }
// Unfortunately, the alpha channel value of -moz-rgba is retrievable
// only on trunk since about 2007-01-24...
// background; defaults to plain opaque white
let sBackColors = ReadCSSColor(aoComputedStyle, "background-color", "255,255,255,1");
goPNGFace.Color(0, sBackColors);
// foreground; defaults to plain opaque black
let oForeColors = ReadCSSColor(aoComputedStyle, "color", "0,0,0,1");
goPNGFace.Color(1, oForeColors);
return "data:image/png;base64," + btoa(goPNGFace.URL(F));
}