What is the difference between the .bmp and .jpg formats? They seem to be interchangeable, and I've noticed Wikidot only accepts jpegs and pngs for your avatar.
GIF files are uncompressed, support transparency and support multiple frames (animated images). A GIF file specifies the colour of every pixel of the image; however, this file format only supports 256 different colours.
BMP files are uncompressed, do not support transparency and do not support multiple frames. A BMP file specifies the colour of every pixel of the image.
JPG files are compressed, do not support transparency and do not support multiple frames. A JPG file specifies the colour of a group of pixels (instead of each individual pixel), and therefore uses less memory. You will noticed that if an image has a lot of dark (or light) areas that the file size is smaller.
PNG files are compressed, support transparency and do not support multiple frames. PNG files were intended to be a compressed lossless format to be used as the standard across the web. Like JPG, it specifies the colour of groups of pixels to save memory.
You may have heard of monochrome, 16 colours, 256 colours and 24-bit files. This is all to do with the limits of each file, and the memory each saves. It has to do with the binary format in which the file is stored.
Monochrome is a 1-bit image. It uses one binary bit to determine the colour of each pixel. 0=Black, 1=White. As one byte is 8 bits, 1 byte could contain an image with an area of 8 pixels.
16 colours is a 4-bit image. It uses four binary bits to determine the colour of each pixel. 4 bits can contain a maximum of 16 unique combinations, so each pixel can have a maximum of 16 different colours. 1 byte can contain an image with an area of 2 pixels.
256 colours is an 8-bit image. It uses eight binary bits to determine the colour of each pixel. As 8 bits is 1 byte, it has a maximum of 256 unique combinations, so each pixel can have a maximum of 256 different colours. 1 byte could contain an image with an area of 1 pixel.
24-bit is a 24-bit image (no way!). It uses 24 binary bits to determine the colour of each pixel. As 24 bits is 3 bytes, it has a maximum of 256³ unique combinations. That means that each pixel can have a maximum of 16 777 216 different colours. This is why Apple uses the term "millions of colours" instead of "24-bit" when specifying the colour output of the screen.
To get more down to the nitty-gritty of 24-bit files, the first 8 bits (the first byte) are used specifically to determine a shade of red. That means there is a maximum of 256 different shades of red. The second set of 8 bits (the second byte) is used to determine a shade of green. That means there is a maximum of 256 different shades of green. The third set of 8 bits (the third byte) is used to determine a shade of blue. That means there is a maximum of 256 different shades of blue. Once each of these three colours are specified, they are mixed together to create a new colour, that determines the colour of a pixel.
That is why we specify colours in the RGB (red, green and blue) method. But why do we specify them in a hex code method?3 bytes | ||||||
---|---|---|---|---|---|---|
First byte | Second byte | Third byte | ||||
1st 4 bits | 2nd 4 bits | 3rd 4 bits | 4th 4 bits | 5th 4 bits | 6th 4 bits | |
Binary | 0000 | 0000 | 0010 | 1010 | 1111 | 1111 |
Hexadecimal | 0 | 0 | 2 | A | F | F |
So every 4 bits of a binary number correspond directly with a hexadecimal value. What about decimal?
3 bytes | |||
---|---|---|---|
First byte | Second byte | Third byte | |
Binary | 00000000 | 00101010 | 11111111 |
Hexadecimal | 00 | 2A | FF |
Decimal | 0 | 42 | 255 |
Nothing seems special about decimal — yet…
1 PIXEL | |||
---|---|---|---|
RED | GREEN | BLUE | |
Binary | 00000000 | 00101010 | 11111111 |
Hexadecimal | 00 | 2A | FF |
Decimal | 0 | 42 | 255 |
Ahhh!
It so happens that the three bytes I specified form together to form the colour RGB(0,42,255). That converts to the hex code #002AFF, which is a nice variation of blue.
If you go to Microsoft Paint, and go to save an image, you will notice it gives many options of BMP files to save in. This is because BMP files can be stored as 1-bit, 4-bit, 8-bit and 24-bit images, to either save on memory or maximise in brilliance of image quality.
I hope I explained EVERYTHING for you!
Oh yes, I forgot to mention. NEVER use Microsoft Paint to save images in JPG format (on ANY Microsoft OS).
Microsoft thought that if they "simplify" each JPG image it would be more beneficial to the user. They do this by reducing the quality of the image so that it isn't noticeable by the human eye, and yet saves memory by being simplified.
The problem with this is that it IS noticeable to the human eye — very noticeable.
As PNG images were designed to be a lossless format across the internet, Microsoft (wisely!) decided NOT to use the same technique on PNG images. You should always save you images in a PNG format.
I also recommend that you change the "quality of image" to 100% in other image manipulating applications whilst saving, to avoid the simplification process.
shory story long:
.bmp files are HUGE
.jpg files are… compressed to death (lol)
.gif files are godly…. IF you use less than 256 colours..
.png files are good, if you want transparant stuff, and high quality
@ james:
"monochrome is a 1-bit image. It uses one binary bit to determine the colour of each pixel. 0=Black, 1=White. As one byte is 8 bits, and one byte can contain 256 unique combinations, 1 byte could contain an image with an area of 256 pixels."
1 bit=256 pixels? you mean 8…
Huh?
I think you misinterpreted what I was trying to say. I was just expressing that if a monochrome image was exactly 1 byte, then the area of the image would be exactly 256 pixels. So the dimensions of the image must be 1×256 or 2×128 or 4×64… etc, etc. This is what I should have said:
Monochrome is a 1-bit image. It uses one binary bit to determine the colour of each pixel. 0=Black, 1=White. As one byte is 8 bits, and one byte can contain 256 unique binary combinations, then a 1 byte 1-bit image would contain an image with an area of 256 pixels.
The information is somewhat useless, but I'm sure it is interesting to know!
I mean, you could expand on that knowledge: If a 1 byte image has an area of 256 pixels, then it would be one image of the 256 possible images of the same dimensions. Based on this expanded information, you could construct every possible image of a particular dimension in monochrome. The formula of the number of combinations would be: n=2a where "n" is the number of combinations for the dimensions of that particular image, and "a" is the area in pixels of the image. "2" is the number of different colours possible.
Expand on this further, you can create every image possible for any dimension. For a 24-bit image: 16 777 216a=n. That is mind-bogglingly huge! If there was one pixel, 16 777 216¹=16 777 216. If there was two pixels, 16 777 216²=281 474 976 710 656. That is phenomenal — and that is only two pixels!
I have often amused myself with the thought that if a computer was powerful enough to do that in seconds for an image the size of an A4 sheet of paper, many of those images would teach us things we haven't discovered yet — and will even tell stories of future events!
That is strange to think. Thank you for the explanation.
i think you are wrong…
tell me, how would you store 9 pixels into 1 byte?
by 256, they mean the possible amount of different combinations, wich is:
2(amount of possible combinations) ^8 (amount of bits) = 256
2^8=256
that means, that 1 pixel can code 8 pixels, and 2 pixels can code 2*8=16 pixels
n=ca
n=number of combinations for the dimensions of that particular image
c=number of different colours possible
a=area in pixels of the image
Monochrome image of area 9 pixels:
n=29
n=512 possible images for an image of those dimensions in monochrome.
i think you are wrong…
tell me, how would you store 9 pixels into 1 byte?
You are correct, I made a miscalculation.
My formula for calculating possible combinations is correct, but the way I worked out how much memory a specified area would take up is incorrect. I'm surprised I didn't pick it up myself, as my formula for possible combinations is based on the [correct] logic of calculating memory taken.
9 monochrome pixels = 9 bits of memory, therefore 8 bits of memory (1 byte) = 8 monochrome pixels
My new correct formula for calculating the number of bits used is:
(1)a=area in pixels of the image
b=bits that the image takes up
c=number of different colours possible
I shall now change my previous comment to display correct data.
Thankyou darkstone knight.
did you get my message?
message? me? no..
@ james: what? you stole the 2log(n) routine i have been using for years? lame
j/k
by the way… it works like this:
Q: how many bits do i need to store a number between 10^3 and 10^4?
A: log(10^4-10^3)/log(2) = 13,1 bits, = 14 bits
message? me? no..
Is he not replying directly to James Kanjo's post? There's a reason that some posts are distinctly inset from the ones before them.
Which begs the question: Does anyone respond to the first post with new insights, or do we all just hit the bottommost "reply" in every thread, which jumbles the conversation?
did you get my message?
Err, no. There are no new messages in my inbox… or my Wikidot inbox…
@ darstone knight
They teach us the $\definecolor{darkgreen}{rgb}{0.90,0.91,0.859}\pagecolor{darkgreen} \ \log_x(y^z) = z \log_x(y)$ trick at school. They showed us that so we could calculate some logarithms without calculators.
They also teach us:
- $\definecolor{darkgreen}{rgb}{0.90,0.91,0.859}\pagecolor{darkgreen} \ \log_x(yz) = \log_x(y) + \log_x(z)$
- $\definecolor{darkgreen}{rgb}{0.90,0.91,0.859}\pagecolor{darkgreen} \ \log_x( \frac {y}{z}) = \log_x(y) - \log_x(z)$
- $\definecolor{darkgreen}{rgb}{0.90,0.91,0.859}\pagecolor{darkgreen} \ \log_x( \frac {1}{y}) = -\log_x(y)$
And we all know that if $\definecolor{darkgreen}{rgb}{0.90,0.91,0.859}\pagecolor{darkgreen} \ x^y = z$ then $\definecolor{darkgreen}{rgb}{0.90,0.91,0.859}\pagecolor{darkgreen} \ \log_x(z) = y$ (yes, I just felt like doing more LaTeX equations XD)