Don't have an account? Register now to chat, post, use our tools, and much more.
Latest Headlines
Online Users
There are 116 users online: 4 members, 80 guests and 32 bots. Members: Ashbad, flyingfisch, hellninjas, Thunderbird336. Bots: VoilaBot (3), Spinn3r (2), Magpie Crawler (4), VoilaBot (2), Googlebot (19), MSN/Bing (1), MSN/Bing (1).
RSS & Social Media
SAX
You must log in to view the SAX chat widget
|
| Author |
Message |
|
Spenceboy98

Super-Expert

Joined: 06 Jan 2012 Posts: 822 Location: In the TARDIS
|
Posted: 16 Apr 2012 08:53:36 pm Post subject: How does a computer read picture files? |
|
|
| Just as the topic name suggests, I'm asking you how a computer reads picture files. As in .png, .bmp, .jpg, and .gif. I'm just wondering. I looked it up on google, but I couldn't find anything that was clear to me. |
|
| Back to top |
|
|
souvik1997

Guru-in-Training

Joined: 19 Apr 2010 Posts: 2870
|
Posted: 16 Apr 2012 08:57:50 pm Post subject: |
|
|
They use libraries (such as libpng and libjpeg) to do the hard part for them, then they just copy the image to the screen. You could look at the source code for those libraries to see how they decompress and read the image data. _________________ CALCnet Tournament-38%
deviantArt
 |
|
| Back to top |
|
|
Spenceboy98

Super-Expert

Joined: 06 Jan 2012 Posts: 822 Location: In the TARDIS
|
|
| Back to top |
|
|
flyingfisch

Super-Expert

Joined: 02 Feb 2012 Posts: 893 Location: Akron, OH
|
Posted: 17 Apr 2012 09:15:25 am Post subject: |
|
|
I was wondering how computers did that too. Thanks you souvik, I now understand it a little better  _________________

 
 |
|
| Back to top |
|
|
KermMartian

Site Admin

Joined: 14 Mar 2005 Posts: 55741 Location: Earth, Sol, Milky Way
|
Posted: 17 Apr 2012 09:18:29 am Post subject: |
|
|
BMP is the easiest one, because it doesn't do any compression. The bytes for the image are stored sequentially, alternating red, green, and blue, and the bytes can then be directly copied to the screen. For compressed types such as JPG and PNG, the data must first be decompressed before it can be shown on the screen. JPG uses lossy compression, which means that the reconstructed image isn't exactly the image that was compressed (but it's close). PNG is lossless, so even though it compresses the picture, when it is decompressed it is identical to the original. _________________
 |
|
| Back to top |
|
|
christop

Power User

Joined: 09 Mar 2011 Posts: 385 Location: Arizona, USA
|
Posted: 17 Apr 2012 10:21:59 am Post subject: |
|
|
| KermMartian wrote: | | BMP is the easiest one, because it doesn't do any compression. The bytes for the image are stored sequentially, alternating red, green, and blue, and the bytes can then be directly copied to the screen. For compressed types such as JPG and PNG, the data must first be decompressed before it can be shown on the screen. JPG uses lossy compression, which means that the reconstructed image isn't exactly the image that was compressed (but it's close). PNG is lossless, so even though it compresses the picture, when it is decompressed it is identical to the original. |
I would say that the raw Portable Pixmap (PPM) format is even easier than BMP to decode, as it has only one pixel format (red/green/blue, 8 or 16 bits per channel). BMP has several different pixel formats and depths to worry about when decoding, eg 1-bit monochrome, 4-, or 8-bit indexed; 16-, 24-, or 32- bit high/true color; etc. BMP can also be RLE compressed. Plus BMP's are stored "upside down", meaning the bottom row of pixels is stored first in the file.
Then there's also the ASCII PPM format, which is the same as the raw PPM format, but the values are stored in plain text, which makes it easier to edit in a text editor or with a programming language that doesn't easily support binary data. The only downside is that an ASCII PPM file is larger than a raw PPM file. _________________ Christopher Williams |
|
| Back to top |
|
|
|
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.
» Go to Registration page
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
© Copyright 2000-2013 Cemetech & Kerm Martian :: Page Execution Time: 0.030720 seconds.
|