I know this is ultra general, but Ive always wondered how pictures or sound is written to a drive. I understand slightly that data is stored as little bits of sequences of on or off switches, but if you were to write out a drive in english what would that look like for pictures. Does each pixel have a specific code like the #F000F4 or however you see them online? Hope there can be some sort of minor explanation. Thanks.
In: Technology
> Does each pixel have a specific code like the #F000F4 or however you see them online?
Yes, though inside the computer that “F000F4” is stored in binary, which would be 111100000000000011110100. That’s one pixel. You would then follow it with the next pixel and so on until the whole picture is represented.
In reality, there’s extra information. You’ll typically have some sort of header for the file, which contains information that tells the computer how to interpret all the data that makes up an image. This could include things like file type, size, any compression information, etc. This is all also done in binary.
The other consideration is that directly representing each pixel of the image as above only occurs in lossless formats. The most commonly used image formats nowadays use some sort of compression, which changes how the data is represented. Exactly how it’s done depends on the compression used.
A very, very rough example might be that any time there’s a bunch of the same colored pixel in a row, the file would have the amount of pixels in the row and the color value of the pixels. It would be the binary equivalent of “there’s 12 red pixels in a row here”.
If you’re not already familiar with how it works, that hex code you used (#F000F4) is easy to “translate into English”. It’s three 2-digit numbers just stuck together: F0-00-F4. In binary that’s 11110000-00000000-11110100. The first chunk is how much red there is in the pixel, the second is how much green, and the third is how much blue. So you can look at it and realize it’s a bunch of red and blue, and not a lot of green, so it should be some sort of purple-ish color.
Latest Answers