Reads the header of the PNM image from a file. Required before reading the pixels from the file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(format_pnm), | intent(inout) | :: | this | |||
integer, | intent(in) | :: | nunit | |||
integer, | intent(out) | :: | pos |
subroutine read_header(this, nunit, pos) class(format_pnm), intent(inout) :: this integer, intent(in) :: nunit integer, intent(out) :: pos character(len=70) :: comment character :: temp integer :: i, k read(nunit,*) k = 0 do read(nunit,'(a)') temp if (temp /= '#') exit k = k + 1 end do inquire(nunit, pos=pos) rewind(nunit) read(nunit,*) this%magic_number this%comment = '' do i = 1, k read(nunit,'(a,a,a)') temp, temp, comment this%comment = this%comment//comment end do read(nunit,*) this%width, this%height inquire(nunit, pos=pos) if (this%file_format == 'pgm' .or. this%file_format == 'ppm') then read(nunit,*) this%max_color inquire(nunit, pos=pos) end if end subroutine read_header