Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » Array of Colors to a Media File Format
- MetaLabs
-
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?
- _nix
-
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
-
30 posts
Array of Colors to a Media File Format
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 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.

- Jonathan50
-
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
-
1000+ posts
Array of Colors to a Media File Format
https://en.wikipedia.org/wiki/Netpbm_formatCame 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. You could use PPM, since PPM files can be encoded as plain text:
- MetaLabs
-
30 posts
Array of Colors to a Media File Format
https://en.wikipedia.org/wiki/Netpbm_formatYou could use PPM, since PPM files can be encoded as plain text:
https://en.wikipedia.org/wiki/Netpbm_formatCame 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. You could use PPM, since PPM files can be encoded as plain text:
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)
- Discussion Forums
- » Advanced Topics
-
» Array of Colors to a Media File Format