encode_binary_pbm_pixels Function

private pure function encode_binary_pbm_pixels(this) result(packed_data)

Packs pixel bits into characters to create the binary representation for PBM images.

Arguments

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

Return Value character(len=1), allocatable, (:)


Called by

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

Source Code

   pure function encode_binary_pbm_pixels(this) result(packed_data)
      class(format_pnm), intent(in) :: this
      character(len=1), allocatable :: packed_data(:)
      integer, allocatable :: temp(:)
      integer :: row, col, nbytes

      nbytes = (this%width+7)/8
      allocate(packed_data(this%height*nbytes))
      allocate(temp(nbytes))
      do row = 1, this%height
         temp = 0
         do col = 0, this%width-1
            temp(col/8+1) = temp(col/8+1) + this%pixels(row, col+1) * 2**(7-mod(col, 8))
         end do
         packed_data((row-1)*nbytes+1 : row*nbytes) = achar(temp)
      end do
   end function encode_binary_pbm_pixels