flip_horizontal Subroutine

private pure elemental subroutine flip_horizontal(this)

Flips the image horizontally.

Type Bound

format_pnm

Arguments

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

Calls

proc~~flip_horizontal~~CallsGraph proc~flip_horizontal format_pnm%flip_horizontal proc~check_pixel_range format_pnm%check_pixel_range proc~flip_horizontal->proc~check_pixel_range proc~set_height format_pnm%set_height proc~flip_horizontal->proc~set_height proc~set_width format_pnm%set_width proc~flip_horizontal->proc~set_width

Called by

proc~~flip_horizontal~~CalledByGraph proc~flip_horizontal format_pnm%flip_horizontal program~demo_ppm demo_ppm program~demo_ppm->proc~flip_horizontal program~test23 test23 program~test23->proc~flip_horizontal

Source Code

   elemental pure subroutine flip_horizontal(this)
      class(format_pnm), intent(inout) :: this

      select case (this%file_format)
       case ('pbm', 'pgm')

         this%pixels(:,:) = this%pixels(:, this%width:1:-1)

         call this%check_pixel_range(this%pixels)

       case ('ppm')

         this%pixels(:, 1:size(this%pixels, 2):3) = this%pixels(:, size(this%pixels, 2)-2:1:-3)
         this%pixels(:, 2:size(this%pixels, 2):3) = this%pixels(:, size(this%pixels, 2)-1:2:-3)
         this%pixels(:, 3:size(this%pixels, 2):3) = this%pixels(:, size(this%pixels, 2)  :3:-3)

         call this%check_pixel_range(this%pixels)

      end select

      call this%set_height(size(this%pixels,1))

      select case (this%file_format)
       case ('pbm', 'pgm')
         call this%set_width(size(this%pixels,2))
       case ('ppm')
         call this%set_width(size(this%pixels,2)/3)
      end select

   end subroutine flip_horizontal