tags:

views:

155

answers:

8

In attempting to understand the concept of binary, my question is "How does a stored image or video look in binary on the hard drive?"

Thanks for all help

+1  A: 

00001010101101010110101010100001100101000111001010...

googletorp
I had a feeling someone would do this after reading the question.
Troggy
It's not a nice reply, but it made me chuckle anyway!
Mark
+1  A: 

Check out the link: Binary File Format

The images are sequential flow of colored dots... But it's not hardware dependent i.e. your hard-disk will store any thing in any format which your OS provide it to... However the OS maintain standards of saving file formats other wise a JPG image will not be valid one across different platforms...

Simillarly the videos are flows of images and voice data multiplexed into a sequential flow.

S M Kamran
+1  A: 

The binary as follows: 000010101011010101101010101 would be stored on a hard drive actual microscopic bumps and troughs by changing the polarity of the metalic grains on the disk in specific regions.Binary is actually read from right to left, obviously the opposite way of how most people read text.

teh_noob
I think you're confusing a harddisk with an optical medium like a CD? As far as I know there are no bump on harddisk platters, just alignments of magnetic particles. But then again, I hardly know anything about harddisk hardware myself.
peSHIr
Come to think of it I think your absolutely right, should seem obvious because disks are read with lasers and a hard drive is read/written by a copper head actuator coil according to Wikipedia. I feel dumb now...
teh_noob
@peSHIr that's correct
Greg
+1  A: 

As for how it is physically stored, it depends on the technology of your storage device. For a hard disk drive you can read about it on Wikipedia.

The next layer is how the controller on the storage device sends the data to the motherboard.

Then how the motherboard sends the data to the operating system.

Then how the operating system stores the data on the disk (what file system it uses; NTFS is common in modern Windows installations.)

Finally, what you'll see when reading the data is groups of 8 bits (bytes) which are basically 8 on/off flags, which together form 256 possible combinations. Which is why most image formats are stored with colors varying from 0-255 for each channel (red, green, blue.) Most raw formats are stored linearly, so you can actually try reading them yourself. A raw image where the first pixel is red (assuming it stores the pixels left-to-right, top-to-bottom) would look like this in bits:

11111111 00000000 00000000
red      green    blue

For more information, you'll have to be more specific.

Blixt
+1  A: 

Every file on disk is basically a number of bits in a row.

The difference between "binary" and "something else" (often called ASCII, or text, or...) is that non-binary is basically human readable when opened in a text editor. In other words: the bytes in the file map to human readable letter (and other) characters in some way a generic text editor knows how to handle.

So called binary files can only be interpreted back to that data that they actually contain when you know the format which was used to map the content (image, sound, movie, whatever) to a stream of zeros and ones. This mapping is called the file format and is usually part of the file name in the form of an extension. You need a piece of software that knows the mapping and can interpret the row of bits back into the original content.

Mind you: this is usually only a hint. Renaming a JPEG image file to have a .mp3 extension doesn't change it into an audio file; it is still just an image file, containing the image (=dimensions of the image in pixels + the color values for each pixel, basically) encoded into a stream of zeros and ones in the way described in the JPEG file format encoding description.

peSHIr
re renaming: As a kid, I renamed a .bmp file to an .exe file, tried to run it, and was confused why it didn't display the picture...
balpha
A: 

If your question is really "how does it look": See Figure 4 on this page; it shows high resolution measurements of a hard drive.

Although googletorp's answer does not look very helpful, it's not totally untrue. To store binary data, the only thing you need is the possibility to have two different states for each storage unit (be it an on/off switch, hole or no hole in a punchcard, or, as in the case of hard drives, the direction of ferromagnetic particles).

balpha
A: 

All data on commercial computer systems are stored in binary format (we'll ignore scientific studies into quantum and optical computing).

At the lowest level all files and processing by a computer are performed in binary. This is because our computing systems are powered by the flow of electrons. They either flow or don't. Electric current is on or off. 1 and 0.

The data stored on a hard disk is there due to pulsing of the hard disk write head coil which magnetises spots of hard disk material. These magnetised spots cause a current pulse in the read coil (in actual fact the read and write coils are the same) as the hard disk head passes over them. Hence the data is read as a stream of current pulses, 1s and 0s.

Now processors are built to accept process a finite number of binary "pulses" or data bits simultaneously (it can be anything from 4 bits upwards). Hence a modern 64bit PC can process 64 binary data bits i.e. 64 1s and 0s, at any one time.

Now at a higher level, although all files are stored as binary and can be read in binary format we help the processing of them by telling the processor what format to read them in. This is so that it process the file data as small chunks e.g. 8 bits or 1 byte for ASCII text.

The operating system provides the processor with a template for any given file. This is set up in an extension relation table. And according to what the file extension is the operating system will expect that data to be in a particular format and link it to code that can be used by the processor to interpret it. Hence changing a file name extension will confuse the processor as it won't interpret the data correctly. That's why changing the filename from *.jpg to *.exe won't show the image, as the processor has been told to expect executable code, which the data within the file clearly isn't.

So back to your original question the image within the jpeg file has been encoded as series of 1s and 0s in a specific order.

I'm not sure how exactly they are arranged, but as an example: A picture was captured and stored as a bitmap at a resoultion of 800 x 600 in 24bit colour. The first pixel is stored as 3 bytes (8 bit binary) representing a red, green and blue value. The value of each byte dictates the intensity of that colour. 0 - 255, with 0 being none at all to 255 being the highest value. Unsigned 255 in binary is 11111111, I won't confuse you with 2's complement for signed values. So the full picture will require a file of minimum 1,440,000 bytes or about 1,406 kilobytes (a kilobyte being 1024 bytes).

ChrisBD
A: 

The Wikipedia page for the BMP File Format contains an example(Including all hex values) of a 2x2 pixel bitmap image, it should be very good at explaining the basis of the binary representation of an image.

In general if you're really curious how the binary looks for a file you could always use a Hex Viewer and take a look yourself :) I normally use od on Linux to dump the binary information of a file. I'm sure you can google a good Hex Editor for Windows (or maybe someone can suggest one.)

Falaina