ImageViewScreen.js 816 B

1234567891011121314151617181920212223242526272829303132333435
  1. class ImageViewScreen {
  2. constructor(data) {
  3. this.path = data;
  4. }
  5. start() {
  6. // Read TGA image header
  7. const f = hmFS.open_asset(this.path, hmFS.O_RDONLY);
  8. const header = new Uint8Array(18);
  9. hmFS.seek(f, 0, hmFS.SEEK_SET);
  10. hmFS.read(f, header.buffer, 0, 18);
  11. hmFS.close(f);
  12. const width = (header[13] << 8) + header[12];
  13. const height = (header[15] << 8) + header[14];
  14. hmUI.showToast({text: width + "x" + height});
  15. hmUI.createWidget(hmUI.widget.IMG, {
  16. x: (192 - width) / 2,
  17. y: (490 - height) / 2,
  18. src: this.path
  19. });
  20. }
  21. }
  22. let __$$app$$__ = __$$hmAppManager$$__.currentApp;
  23. let __$$module$$__ = __$$app$$__.current;
  24. __$$module$$__.module = DeviceRuntimeCore.Page({
  25. onInit(p) {
  26. new ImageViewScreen(p).start();
  27. }
  28. });