program ppma_2_ppmb ! !******************************************************************************* ! !! PPMA_2_PPMB converts an ASCII PPM file to binary PPM format. ! ! ! Purpose: ! ! PPMA_2_PPMB is a sample application of the PBMLIB library. ! ! It calls on the PBMLIB PPMA_READ routine to open and read a ! user-specified file in the ASCII PPM format. ! ! It then calls on the PBMLIB PPMB_WRITE routine to create and write ! a copy of the data in a file in the binary PPM format. ! ! Modified: ! ! 29 August 2000 ! ! Author: ! ! John Burkardt ! ! Usage: ! ! ppma_2_ppmb file.ppma file.ppmb ! ! Parameters: ! ! Character FILE.PPMA, is the name of the input ASCII PPM file to read. ! ! Character FILE.PPMB, is the name of the output binary PPM file to write. ! ! ! MAXP is the maximum number of pixels that the program can handle. ! Simply increase the value of MAXP to handle larger files. ! integer, parameter :: maxp = 500000 ! integer b(maxp) integer g(maxp) integer iarg integer iargc integer ierror integer ilen character ( len = 80 ) input_file_name integer ipxfargc integer maxcol integer ncol integer nrow integer numarg character ( len = 80 ) output_file_name integer r(maxp) ! ierror = 0 ! ! Old style: ! numarg = iargc ( ) ! ! New style: ! ! numarg = ipxfargc ( ) if ( numarg < 2 ) then write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'PPMA_2_PPMB - Error!' write ( *, '(a)' ) ' Usage: ppma_2_ppmb file.ppma file.ppmb' stop end if ! ! Read the input file. ! iarg = 1 ! ! Old style: ! call getarg ( iarg, input_file_name ) ! ! New style: ! ! call pxfgetarg ( iarg, input_file_name, ilen, ierror ) ! ! if ( ierror /= 0 ) then ! write ( *, '(a)' ) ' ' ! write ( *, '(a)' ) 'PPMA_2_PPMB - Error!' ! write ( *, '(a)' ) ' Could not read command line argument!' ! end if call ppma_read ( input_file_name, ierror, maxcol, maxp, nrow, ncol, r, g, b ) if ( ierror /= 0 ) then write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'PPMA_2_PPMB - Error!' write ( *, '(a,i6)' ) ' PPMA_READ returns IERROR = ', ierror end if ! ! Write the output file. ! iarg = 2 ! ! Old style: ! call getarg ( iarg, output_file_name ) ! ! New style: ! ! call pxfgetarg ( iarg, output_file_name, ilen, ierror ) ! ! if ( ierror /= 0 ) then ! write ( *, '(a)' ) ' ' ! write ( *, '(a)' ) 'PPMA_2_PPMB - Error!' ! write ( *, '(a)' ) ' Could not read command line argument!' ! end if call ppmb_write ( output_file_name, ierror, nrow, ncol, r, g, b ) if ( ierror /= 0 ) then write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'PPMA_2_PPMB - Error!' write ( *, '(a,i6)' ) ' PPMB_WRITE returns IERROR = ', ierror end if write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'PPMA_2_PPMB' write ( *, '(a)' ) ' Normal end of execution.' stop end