NetLogo / ImportA-Extension

A NetLogo extension for running `import-*` primitives with plain text and base64 strings
1 stars 1 forks source link

NetLogo Web: import-a:pcolors fails if png image not rgba #1

Closed gabriel-wurzer closed 2 years ago

gabriel-wurzer commented 2 years ago

A png dataurl must be rgba for import-a:pcolors to succeed. In all other cases NetLogo reports "ERROR: Failed to construct 'ImageData': The input data length is not a multiple of 4." (tested on Chrome 100.0.4896.127 64-Bit on Windows; and Firefox 99.0.1 64-Bit which gives the rather more cryptic "ERROR: An attempt was made to use an object that is not, or is no longer, usable")

Steps to reproduce:

  1. extract attached files.zip and open import-a-rgb-rgba.html in a browser
  2. open (enlarge) the command center
  3. open the developer console (in Chrome: choose Menu > More Tools.. > Developer Tools and switch to the Console tab)
  4. press the button and choose the file rgb.bin (which contains a base64-encoded RGB png)
  5. see the exception in the Console:

Uncaught DOMException: Failed to construct 'ImageData': The input data length is not a multiple of 4. at window.synchroDecoder (file:///C:/temp/mdab2/preprocessing/import-a-rgb-rgba.html:25286:102375) at file:///C:/temp/mdab2/preprocessing/import-a-rgb-rgba.html:62275:34 at Object.importPColors [as PCOLORS] (file:///C:/temp/mdab2/preprocessing/import-a-rgb-rgba.html:66040:59) at eval (eval at <anonymous> (file:///C:/temp/mdab2/preprocessing/import-a-rgb-rgba.html:79:38), <anonymous>:8:44) at FileReader.reader.onload (file:///C:/temp/mdab2/preprocessing/import-a-rgb-rgba.html:79867:18)

  1. also observe that the output shown in the command center remains empty
  2. now press the button again and choose rgba.bin (which contains a base64-encoded RGBA png)
  3. observe that "OK" is now shown in the command center (and no exception is printed to the console)

Suggestions / possible solutions:

Other notes:

generate_rgb_rgba_1pix_png.py.zip

gabriel-wurzer commented 2 years ago

P.S.: forgot program versions,

NetLogo 6.2.0 (December 22, 2020) and thus probably: Netlogo Web as of October 15th, 2020 - v2.8.1 Extension API version: 6.1 OpenJDK 64-Bit Server VM 1.8.0_275 (BellSoft; 1.8.0_275-b01) operating system: Windows 10 10.0 (amd64 processor) Scala version 2.12.12

TheBizzle commented 2 years ago

Thanks for the very detailed and informative report! :sunglasses:

This seems to be a duplicate of https://github.com/NetLogo/SynchroDecoder/issues/3, which was fixed a couple of weeks ago, but hasn't been deployed to netlogoweb.org yet, so I'll be closing this as a duplicate.

gabriel-wurzer commented 2 years ago

Thanks 👍 great to hear that! Gabriel-- sent from my cell phone --Am 27.04.2022 18:20 schrieb Jason Bertsche @.***>: Closed #1.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>