Web Graphics and the Browser

Too see how a web browser processes and organizes images internally, let’s look at the model used by the Mozilla web browser, which is the “open source” release of the Netscape browser. This is a good object of study because the browser’s code is freely available under the Netscape Public License, and the code is amply documented at Mozilla headquarters (http://www.mozilla.org).

Mozilla is written in C++, and is designed as a modular structure with well-defined tasks handled by different modules. Image management is handled by an “image library” that manages the flow, decoding, and eventual display of images. The Image Library takes the following steps in displaying an image:

  1. A URL is requested by the code that handles the layout of the page. This request can be initiated by the parsing of an IMG element or by one of the user interface options, such as the Show Images button on the navigation bar. This request is made with the GetImage( ) function.

  2. The Image Library maintains a cache of previously requested and decoded images. With each image request, the Image Library looks for the image in the cache and, if it finds it, draws the previously requested image from the cache. If the image is not in the cache, the Library opens a data stream to get the image data, create a new image object, decompress and decode the data, and store the object in the cache according to the pragmas associated with the file. A request to the Image Library returns an ImageReq ...

Get Perl Graphics Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.