neosphere icon indicating copy to clipboard operation
neosphere copied to clipboard

Add functions to save images

Open postcasio opened this issue 4 years ago • 2 comments

Not sure what the best design for this API would be - whether to offer a save(filename) method on Texture that directly saves the file or a method that returns JPG/PNG binary data to be passed to FS.writeFile. I lean towards the latter for flexibility.

postcasio avatar Jan 06 '21 14:01 postcasio

There's currently an experimental function Texture#download() that returns the raw uncompressed pixels of an image. It would be easy enough to add an extra parameter to say you want the image in PNG format instead.

Note that Sphere v1 has Surface#save() and it does work in neoSphere; I didn't implement image saving in Sphere v2 initially because it didn't seem super useful given how sandboxed the file system is. What are the use cases you're envisioning for this feature?

fatcerberus avatar Jun 03 '24 13:06 fatcerberus

Sorry only just noticed this reply :) The download function should be enough for what I was thinking. The use case is storing a thumbnail of the current game screen with save data so it can be displayed in a save game list, similar to this: image

It could also be useful for a "photo mode" feature, although I'm sure they're not too common in 2D games.

postcasio avatar Jul 22 '24 15:07 postcasio