|
|
| If you do not specify image dimensions using htmlImage:Height() and htmlImage::Width(), the browser will display the image in it's full size.
|
|
|
| Normally, the Height() and Width() methods are used to specify the actual dimensions of an image so that the browser will display a properly-sized placeholder as the image is loaded. As previously mentioned, this is often done in conjunction with the use of alternate text so that the user can see descriptions of the images before they are loaded.
|
|
|
| Images can also be scaled or stretched to any desired size. Note that specifying larger or smaller dimensions can cause distortion or pixelation.
|
|
|
| Many browsers allow dimensions to be specified as a percentage of the available display space. Furthermore, if only the width is specified (as a percentage), the aspect ratio of the image will be maintained, making it convenient to scale images. The Height() and Width() methods accept image dimensions expressed as integer pixels. To specify a percentage, use the base-class SetAttribute() method to pass the percentage as a string:
|
|
|
| |
| htmlImage normal( "/images/logo.gif",
|
| "logo description" ) ;
|
|
|
| // Create a copy, enlarged to 75% of the browser display
|
| htmlImage enlarged( normal ) ;
|
| enlarged.SetAttribute( "WIDTH", "75%" ) ;
|
|
|
| // Create another copy, reduced to a 50 pixel
|
| // wide thumbnail.
|
| htmlImage reduced( normal ) ;
|
| reduced.Width( 50 ) ;
|
|
|
| page << logo << htmlBreak()
|
| << enarged << htmlBreak()
|
| << reduced ;
|
|
|
| |