Meadowcreek_99 wrote: > I need help starting this program...Maybe just an outline of what to do. > I can get the codes myself but here is what is need in the program. > > Write a function that takes as input a string containing HTML source > code and returns both the # of images referenced in the code and the > total screen area (in square pixels) occupied by the images. > > EstImageContent() must be able to detect at least the following HTML > image "tags" > > 1. IMG and its associated WIDTH= and HEIGHT= parameters > 2. BACKGROUND > > You may assume that every IMG tag has a WIDTH= and a HEIGHT= > parameter. Note that the value of these parameters may be expressed in > either quoted (e.g. WIDTH="768") or unquoted (e.g. WIDTH=768) form. > You may also assume that there will be only one BACKGROUND tag in the > entire string. > > You must also write a main() function that tests estImageContent(). > main() should: > > 1. Prompt the user for an input filename > 2. Open the file, read its contents into a string (up to > 20000 bytes), close file > 3. Call estImageContent() > 4. Print the following to the screen: > 1. Input filename > 2. Estimated # of images > 3. Estimated total screen area in square pixels > 5. Loop back to prompt > > > I don't want ppl to write the program but help on how to start would > be nice...
Things you will need: 1) A basic HTML parser. Something that breaks up a document into tags, attributes (part of each tag), and content. 2) Loop over the output of the HTML parser looking for 'img' tags and 'background' attributes. 3) A way to load still image data into memory. A third-party library will help here. This will give you access to dimensions. The 'width' and 'height' attribute tags take precedence - and this looks like a homework assignment so you may not have to actually load the image data. Ask your professor for clarification on what the input data will look like. The assignment says you can _assume_ 'width' and 'height' attributes, but I always prefer killing a housefly with a tactical nuke and assume nothing. 4) The 'background' attribute won't count in width/height calculations...just image count. The hardest part is the HTML parser. Get it right and the rest of the assignment is a walk in the park. -- Thomas Hruska CubicleSoft President Ph: 517-803-4197 *NEW* VerifyMyPC 2.4 Change tracking and management tool. Reduce tech. support times from 2 hours to 5 minutes. http://www.CubicleSoft.com/VerifyMyPC/
