(FILECREATED "28-Nov-84 13:47:29" {ERIS}<LISPNEW>SOURCES>INTERPRESSBITMAPPATCH.;1 4883   )


(* Copyright (c) 1984 by Xerox Corporation. All rights reserved.)

(PRETTYCOMPRINT INTERPRESSBITMAPPATCHCOMS)

(RPAQQ INTERPRESSBITMAPPATCHCOMS ((FNS SHOWBITMAP1.IP)))
(DEFINEQ

(SHOWBITMAP1.IP
  [LAMBDA (IPSTREAM BITMAP LEFT FIRSTROW XPIXELS YPIXELS SCALEFACTOR ROTATION HEIGHT XBYTES 
		    REGIONBOTTOM)                            (* jds "28-Nov-84 13:31")
                                                             (* Move a segment of bitmap to an INTERPRESS file.)
                                                             (* FIRSTROW is the row count -- STARTING FROM THE TOP 
							     OF THE BITMAP AS ZERO -- for the first row to be 
							     displayed.)
    (PROG [(TOTALBYTES (ITIMES XBYTES YPIXELS))
	   (SCRATCHBM (BITMAPCREATE (CEIL XPIXELS BITSPERCELL)
				    1))
	   (BMBASE (\ADDBASE (fetch (BITMAP BITMAPBASE) of BITMAP)
			     (ITIMES (IDIFFERENCE (IPLUS HEIGHT (OR REGIONBOTTOM 0))
						  (IPLUS FIRSTROW YPIXELS))
				     (fetch (BITMAP BITMAPRASTERWIDTH) of BITMAP]
          (APPENDOP.IP IPSTREAM DOSAVESIMPLEBODY)
          (APPENDOP.IP IPSTREAM {)                           (* Start the SIMPLEBODY for displaying this part of the
							     bitmap.)
          (TRANS.IP IPSTREAM)                                (* Translate to the current position)
          (APPENDNUMBER.IP IPSTREAM YPIXELS)                 (* For the master, this is the number of pixels in the 
							     slow direction)
          (APPENDNUMBER.IP IPSTREAM (CEIL XPIXELS BITSPERCELL))
                                                             (* Number of pixels in the master's fast direction)
          (APPENDINTEGER.IP IPSTREAM 1)                      (* Reserved for future expansion)
          (APPENDINTEGER.IP IPSTREAM 1)
          (APPENDINTEGER.IP IPSTREAM 1)
          (SELECTQ (IMOD (OR ROTATION 0)
			 360)
		   (0                                        (* Bitmaps are really shown on their sides, hanging 
							     from the upper left corner (I think--JDS))
		      (ROTATE.IP IPSTREAM -90)
		      (TRANSLATE.IP IPSTREAM 0 (IDIFFERENCE HEIGHT FIRSTROW))

          (* Push this segment up to its "true" height -- i.e., The first segment gets pushed up all the way 
	  (since it's the top of the bitmap), the next segment gets pushed up HEIGHT-#ofRowsIn1stSeg (to account for the first
	  segment), and so on.)


		      (CONCAT.IP IPSTREAM))
		   (90                                       (* need nop)
		       (TRANSLATE.IP IPSTREAM (IDIFFERENCE HEIGHT (IPLUS FIRSTROW YPIXELS))
				     0)

          (* Push this segment up to its "true" bottom -- i.e., The first segment gets pushed up to 
	  bitmapHeight-HeightOfSegment (since it's the top of the bitmap), the next segment gets pushed up 
	  HEIGHT-RowsIn1stSeg-RowsThisSeg (to account for the first segment), and so on.)


		       )
		   (180                                      (* The translation for this hasn't been tested yet.
							     It may well be the inverse of the rotation-0 
							     correction)
			(ROTATE.IP IPSTREAM 90)
			(TRANSLATE.IP IPSTREAM XPIXELS 0)
			(CONCAT.IP IPSTREAM))
		   (270                                      (* The translation for this hasn't been tested yet.
							     It may well be the inverse of the rotation-90 
							     correction)
			(ROTATE.IP IPSTREAM 180)
			(TRANSLATE.IP IPSTREAM 0 XPIXELS)
			(CONCAT.IP IPSTREAM))
		   (ERROR ROTATION "rotation by other than multiples of 90 degrees not implemented"))
          (SCALE.IP IPSTREAM SCALEFACTOR)                    (* Scale the bitmap to its final size)
          (CONCAT.IP IPSTREAM)
          (APPENDSEQUENCEDESCRIPTOR.IP IPSTREAM SEQPACKEDPIXELVECTOR (IPLUS 4 TOTALBYTES))
          (APPENDINT.IP IPSTREAM 1 2)
          (APPENDINT.IP IPSTREAM XPIXELS 2)

          (* * Now put put the bitmap -- each line must be a 32-bit multiple long)


          (for Y (XWORDS ←(FOLDHI XBYTES BYTESPERWORD)) from 1 to YPIXELS
	     do (BITBLT BITMAP (OR LEFT 0)
			(IDIFFERENCE (IPLUS (OR REGIONBOTTOM 0)
					    FIRSTROW YPIXELS)
				     Y)
			SCRATCHBM 0 0 XPIXELS 1 (QUOTE INPUT)
			(QUOTE REPLACE))
		(\BOUTS IPSTREAM (fetch (BITMAP BITMAPBASE) of SCRATCHBM)
			0
			(CEIL XBYTES BYTESPERCELL)))
          (APPENDOP.IP IPSTREAM MAKEPIXELARRAY)
          (APPENDOP.IP IPSTREAM MASKPIXEL)
          (APPENDOP.IP IPSTREAM }])
)
(PUTPROPS INTERPRESSBITMAPPATCH COPYRIGHT ("Xerox Corporation" 1984))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (271 4791 (SHOWBITMAP1.IP 281 . 4789)))))
STOP