49
344
APPENDIX F. SOURCE CODE LISTINGS
*
Now loop over the directory entries.
*
Look only for the tags we need. These
*
are:
*
ImageLength
*
ImageWidth
*
BitsPerPixel(BitsPerSample)
*
StripOffset
*
*****************************************/
for(i=0; i<entry_count; i++){
bytes_read = fread(buffer, 1, 12, image_file);
extract_short_from_buffer(buffer, lsb, 0,
&tag_type);
switch(tag_type){
case 255: /* Subfile Type */
extract_short_from_buffer(buffer, lsb, 2,
&field_type);
extract_short_from_buffer(buffer, lsb, 4,
&length_of_field);
extract_long_from_buffer(buffer, lsb, 8,
&subfile);
break;
case 256: /* ImageWidth */
extract_short_from_buffer(buffer, lsb, 2,
&field_type);
extract_short_from_buffer(buffer, lsb, 4,
&length_of_field);
if(field_type == 3){
extract_short_from_buffer(buffer, lsb, 8,
&s_image_width);
image_width = s_image_width;
}
else
extract_long_from_buffer(buffer, lsb, 8,
&image_width);
break;
case 257: /* ImageLength */
extract_short_from_buffer(buffer, lsb, 2,
&field_type);
extract_short_from_buffer(buffer, lsb, 4,