0
Does anyone know how to convert an image into an array?
I'm looking to convert small images into an array.
4 Respuestas
+ 5
Which programming language? Please add it in the tags aswell.
And which image format?
+ 2
Do you mean the direction of the images or the actual pixels?
What do you want to do with that array exactly?
+ 2
Not sure I understood all of that but I have a few thoughts:
Do you know the difference between text data and binary data? Do you know how to read a file in binary mode? Are you familiar with the concept of RGB?
JPG is too hard to decode by hand and so is PNG. The only format that is both common and simple to parse is BMP. It is made of a header, and then the image stored row by row, pixel by pixel.
If you absolutely need JPG support you might want to look into tools like ImageMagick.
Anyway you can start by writing an image class that keeps an array of `char`s or `uint8_t`s. And it stores the image like r,g,b,r,g,b,r,g,b... and maybe some functions that set and get an individual pixel.
Then you can look up how to save that to a BMP file. Or ask me, I have some code lying around.
+ 1
I'm using c++, the direction of the image is how I'm trying to convert into the simple 2d array. I would like to be able to convert into an array, also from the array into an image to perhaps eventually solve a conundrum that allows me to finely line the images after conversion. This is to reattribute the underlying design. Reinforcement, so to speak.