🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.1 KiB

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <title>TinyEXR to Canvas</title>
  8. <script src="tinyexr.js"></script>
  9. <style>
  10. </style>
  11. </head>
  12. <body>
  13. <canvas id="imgCanvas"></canvas>
  14. </body>
  15. <script>
  16. let canvas = document.getElementById('imgCanvas');
  17. let ctx = canvas.getContext('2d');
  18. fetch("./asakusa.exr").then(response => {
  19. return response.arrayBuffer();
  20. }).then(arrayBuffer => {
  21. // let exrImg = parseExr(arrayBuffer);
  22. let data = new Uint8Array(arrayBuffer);
  23. let exrImg = new Module.EXRLoader(data);
  24. canvas.width = exrImg.width();
  25. canvas.height = exrImg.height();
  26. let imageArray = exrImg.getBytes().map(num => {
  27. // Convert values to 0-255 range and apply gamma curve
  28. return Math.pow(num, 0.44) * 256;
  29. });
  30. let image8Array = new Uint8ClampedArray(imageArray);
  31. let imageData = new ImageData(image8Array, exrImg.width(), exrImg.height());
  32. ctx.putImageData(imageData, 0, 0);
  33. });
  34. </script>
  35. </html>