C*****************************************************************************
C  BM.FOR
C
C  This sample program demontsrates the use of the PGL Bitmap functions
C  to save a bitmap image, a row at a time into a PGL drawing file.
C  The example getpixel function returns 0-color values for even rows
C  and 1-color values for odd rows.
C****************************************************************************
      include "pgl.for"
      integer*2 i, j, err, bpp, compress, maxX, maxY, getpixel
      integer*2 data(640)

C	
C	Open A Drawing File.
C	
	call pgInitDrw( "bm.plt"//char(0), 640,480, err) 
      if( err.ne.0)then
        stop ' Error opeing drawing file'
      endif
C
C     Initialize a PGL drawing file bitmap 
C
      maxX    = 640
      maxY    = 480
      bpp     = 1
      compress=1
      call pgBMInit(0,0,maxX,maxY,bpp,compress)
C
C     Save a screen bitmap, for printing.
C     This code sample assumes you have a 'getpixel' function
C     to return each screen pixel color, a dummy 'getpixel' is used
C     below...
C
      do j=1,maxY
        do i=1,maxX
          data(i) = getpixel(i,j) 
        end do
        call pgBMData(j-1,data)
      end do
C
C     Termmiante the bitmap 
C
      call pgBMEnd()
C
C     Close The Drawing File.
C	
      call pgEndDrw() 
C
      END
C
C     dummy getpixel function - replace with one from your screen graphics
C     library
C
      integer*2 function getpixel(i,j)
      integer*2 i,j
        getpixel = mod(j, 2)
      return
      end
