loadImg.js 843 B

1234567891011121314151617181920212223242526
  1. // https://stackoverflow.com/questions/20756042/javascript-how-to-display-image-from-byte-array-using-javascript-or-servlet
  2. window.onload = function () {
  3. console.log('Load img here...');
  4. /*img_data = document.getElementById('expeImg').getAttribute('data-img');
  5. img_data = JSON.parse(img_data);
  6. var p = new PNGlib(800, 800, 256); // construcor takes height, weight and color-depth
  7. var background = p.color(0, 0, 0, 0); // set the background transparent
  8. for (var i = 0; i < 800; i++){
  9. for (var j = 0; j < 800; j++){
  10. let r = img_data[i][j][0]
  11. let g = img_data[i][j][1]
  12. let b = img_data[i][j][2]
  13. p.buffer[i, j] = p.color(r, g, b)
  14. }
  15. }
  16. console.log('done')
  17. document.getElementById('expeImg').src = "data:image/png;base64,"+p.getBase64();*/
  18. }