Closed satoshinm closed 7 years ago
Works on the web version, but it opens a new window - can the app instead cause a file download, as to not interrupt gameplay? https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a documents the download
attribute "If the attribute has a value, it is used as the pre-filled file name in the Save prompt (the user can still change the file name if they want).", can it be programmatically clicked?
<a download>
click() works well, this was saved as screenshot-netcraft-Sun May 14 2017 16_48_04 GMT-0700 (PDT).png:
Now for native support. Could change to render to a texture, but as seen in https://github.com/satoshinm/NetCraft/issues/89 many platforms don't support drawBuffers() (hmm, but that's on the web, mobile?). http://stackoverflow.com/questions/5844858/how-to-take-screenshot-in-opengl suggests using glReadPixels()
on the rendered frame instead.
miniz's png writer produces .. what looks like a png file:
native-build $ file screenshot-netcraft.png
screenshot-netcraft.png: PNG image data, 2048 x 0, 8-bit/color RGBA, non-interlaced
but its 555 KB and I can't render it:
pngcrush tells what is wrong:
libpng warning: Image height is zero in IHDR
While converting NetCraft/native-build/screenshot-netcraft.png to /tmp/foo:
pngcrush caught libpng error:
Invalid IHDR data
Critical chunk length, method 151 (ws 0 fm 0 zl 0 zs 0) = 0
CPU time decoding 0.000, encoding 0.000, other 0.002, total 0.002 seconds
pngcheck is more specific - somehow it is 2048x0?!:
native-build $ pngcheck screenshot-netcraft.png
screenshot-netcraft.png invalid IHDR image dimensions (2048x0)
ERROR: screenshot-netcraft.png
supposed to be 2048x1536, that's g->width
x g->height
, where did it go wrong?
Oh this was already fixed upstream in miniz: https://github.com/richgel999/miniz/pull/65/files - it was a bug in miniz 2.0.5 beta.
Now only needs to have the filename timestamped on native (preferably, share date function from native and web, but if not no big deal), then this is ready to merge.
https://github.com/satoshinm/NetCraft/issues/119