Discuss Scratch

MetaLabs
Scratcher
30 posts

Array of Colors to a Media File Format

Is it possible, if I have an array of colors (ie. an array of hexidecimal colors that are read from an image from left to right), that I can put this all into a variable that can be then saved as a JPG or PNG file?
MetaLabs
Scratcher
30 posts

Array of Colors to a Media File Format

Anyone?
_nix
Scratcher
1000+ posts

Array of Colors to a Media File Format

Well, sure you could; you'd need to learn the file format of JPG and PNG files to make an export, though. Also, Scratch-exported files are always utf-8 text flies, so you'd probably want to export as some kind of hex 32 format and then use an external converter to turn that into the intended binary data. You might also want to look into a simpler format than PNG or JPG – I don't know any of the details but I think those formats are kinda complex. BMP is probably simpler, and nearly as portable; there may be other formats which you could try too.
MetaLabs
Scratcher
30 posts

Array of Colors to a Media File Format

_nix wrote:

Well, sure you could; you'd need to learn the file format of JPG and PNG files to make an export, though. Also, Scratch-exported files are always utf-8 text flies, so you'd probably want to export as some kind of hex 32 format and then use an external converter to turn that into the intended binary data. You might also want to look into a simpler format than PNG or JPG – I don't know any of the details but I think those formats are kinda complex. BMP is probably simpler, and nearly as portable; there may be other formats which you could try too.
I totally forgot that images are typically in a hexidecimal format not utf-8. That might be another issue that I would have to face as I am trying to make this as simple as possible for the end user. That's a shame. Thanks for the help
Jonathan50
Scratcher
1000+ posts

Array of Colors to a Media File Format

You could use PPM, since PPM files can be encoded as plain text: https://en.wikipedia.org/wiki/Netpbm_format
novice27b
Scratcher
1000+ posts

Array of Colors to a Media File Format

Jonathan50 wrote:

You could use PPM, since PPM files can be encoded as plain text: https://en.wikipedia.org/wiki/Netpbm_format
Came here to say the same thing! They also have the binary format, where you have the header as plain text and the main body as just raw RGB bytes.
MetaLabs
Scratcher
30 posts

Array of Colors to a Media File Format

Jonathan50 wrote:

You could use PPM, since PPM files can be encoded as plain text: https://en.wikipedia.org/wiki/Netpbm_format

novice27b wrote:

Jonathan50 wrote:

You could use PPM, since PPM files can be encoded as plain text: https://en.wikipedia.org/wiki/Netpbm_format
Came here to say the same thing! They also have the binary format, where you have the header as plain text and the main body as just raw RGB bytes.

Hey do you have a wikipedia page that contains the header information? Wow I am blind.

Thank you so much.

Last edited by MetaLabs (April 28, 2019 17:17:16)

Powered by DjangoBB