pixel_size Subroutine

private pure elemental subroutine pixel_size(this, pixel_size_kb, pixel_size_mb)

Calculates imgae size in KB and MB. Required for print_info method.

Arguments

Type IntentOptional Attributes Name
class(format_pnm), intent(in) :: this
real(kind=rk), intent(out) :: pixel_size_kb
real(kind=rk), intent(out) :: pixel_size_mb

Called by

proc~~pixel_size~~CalledByGraph proc~pixel_size pixel_size proc~print_info format_pnm%print_info proc~print_info->proc~pixel_size 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 pure subroutine pixel_size(this, pixel_size_kb, pixel_size_mb)
      class(format_pnm), intent(in) :: this
      real(rk), intent(out) :: pixel_size_kb, pixel_size_mb
      integer :: bits_per_channel, bytes_per_pixel

      bits_per_channel = 8

      select case (this%file_format)
       case ('pbm', 'pgm')
         bytes_per_pixel = bits_per_channel
       case ('ppm')
         bytes_per_pixel = bits_per_channel*3
      end select

      pixel_size_kb = real(this%width*this%height * bytes_per_pixel, kind=rk) / 1024.0_rk
      pixel_size_mb = pixel_size_kb / 1024.0_rk
   end subroutine pixel_size