print_info Subroutine

private impure elemental subroutine print_info(this)

Displays information about the image e.g. dimensions, aspect ratio, etc.

Type Bound

format_pnm

Arguments

Type IntentOptional Attributes Name
class(format_pnm), intent(in) :: this

Calls

proc~~print_info~~CallsGraph proc~print_info format_pnm%print_info proc~aspect_ratio aspect_ratio proc~print_info->proc~aspect_ratio proc~average_colors average_colors proc~print_info->proc~average_colors proc~pixel_size pixel_size proc~print_info->proc~pixel_size

Called by

proc~~print_info~~CalledByGraph proc~print_info format_pnm%print_info program~demo_ppm demo_ppm program~demo_ppm->proc~print_info program~test test program~test->proc~print_info program~test1 test1 program~test1->proc~print_info program~test10 test10 program~test10->proc~print_info program~test11 test11 program~test11->proc~print_info program~test12 test12 program~test12->proc~print_info program~test13 test13 program~test13->proc~print_info program~test14 test14 program~test14->proc~print_info program~test17 test17 program~test17->proc~print_info program~test18 test18 program~test18->proc~print_info program~test19 test19 program~test19->proc~print_info program~test2 test2 program~test2->proc~print_info program~test20 test20 program~test20->proc~print_info program~test21 test21 program~test21->proc~print_info program~test22 test22 program~test22->proc~print_info program~test23 test23 program~test23->proc~print_info program~test24 test24 program~test24->proc~print_info program~test25 test25 program~test25->proc~print_info program~test3 test3 program~test3->proc~print_info program~test4 test4 program~test4->proc~print_info program~test6 test6 program~test6->proc~print_info program~test7 test7 program~test7->proc~print_info program~test8 test8 program~test8->proc~print_info program~test9 test9 program~test9->proc~print_info

Source Code

   elemental impure subroutine print_info(this)
      class(format_pnm), intent(in) :: this
      real(rk) :: avg, avg_red, avg_green, avg_blue
      real(rk) :: asp_ratio
      real(rk) :: pixel_size_kb, pixel_size_mb

      select case (this%file_format)
       case ('pbm', 'pgm')
         call average_colors(this, avg)
       case ('ppm')
         call average_colors(this, avg, avg_red, avg_green, avg_blue)
      end select
      call aspect_ratio(this, asp_ratio)
      call pixel_size(this, pixel_size_kb, pixel_size_mb)

      print '(a)'                           , 'Image Information:'
      print '(a)'                           , '-------------------------------------------'
      print '(a, g0)'                       , 'Magic Number: ', this%magic_number
      print '(a, a)'                        , 'File Format : ', this%file_format
      print '(a, a)'                        , 'Encoding    : ', this%encoding
      print '(a, a)'                        , 'Comment     : ', trim(this%comment)
      print '(a, a, g0, a, g0)'             , 'Dimensions  : ', 'Height: ', this%height, ' Width: ', this%width
      print '(a, g0)'                       , 'Total Pixels: ', this%width * this%height
      print '(a, f6.2)'                     , 'Aspect Ratio: ', asp_ratio
      print '(a, f8.2, a, f8.2, a)'         , 'Pixel Size  : ', pixel_size_kb, ' KB ', pixel_size_mb, ' MB'
      select case (this%file_format)
       case ('pbm', 'pgm')
         print '(a, g0)'                     , 'Average     : ', avg
       case ('ppm')
         print '(a, g0)'                       , 'Max Color   : ', this%max_color
         print '(a, a, f6.2, a, f6.2, a, f6.2)', 'Average RGB : ', 'R:', avg_red, ' G:', avg_green, ' B:', avg_blue
      end select
      print '(a)'                           , '-------------------------------------------'
   end subroutine print_info